org.kuali.kfs.module.endow.util
Class LineParserBase

java.lang.Object
  extended by org.kuali.kfs.module.endow.util.LineParserBase
All Implemented Interfaces:
LineParser

public class LineParserBase
extends Object
implements LineParser


Field Summary
protected static String[] DEFAULT_LINE_FORMAT
          The default format defines the expected line property names and their order in the import file.
 
Constructor Summary
LineParserBase()
           
 
Method Summary
protected  void checkLineClass(Class<? extends EndowmentTransactionLine> lineClass)
          Checks whether the specified Line class is a subclass of EndowmentTransactionLine; throws exceptions if not.
protected  void checkLineFile(org.apache.struts.upload.FormFile lineFile)
          Checks whether the specified line import file is not null and of a valid format; throws exceptions if conditions not satisfied.
protected  EndowmentTransactionLine genLineWithRetrievedAttributes(Map<String,String> lineMap, Class<? extends EndowmentTransactionLine> lineClass)
          Generates an line instance and populates it with the specified attribute map.
protected  String getAttributeLabel(Class clazz, String attributeName)
          Retrieves the attribute label for the specified attribute.
 String[] getLineFormat()
           
 List<EndowmentTransactionLine> importLines(org.apache.struts.upload.FormFile lineFile, Class<? extends EndowmentTransactionLine> lineClass, String documentNumber)
          Parses the items from the specified import file line by line, and generates items of the specified type from the parsed data.
 EndowmentTransactionLine parseLine(String transactionLine, Class<? extends EndowmentTransactionLine> lineClass, String documentNumber)
           
protected  Map<String,String> retrieveLineAttributes(String line, Class<? extends EndowmentTransactionLine> lineClass)
          Parses a line of transactions data from a csv file and retrieves the attributes as key-value string pairs into a map.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_LINE_FORMAT

protected static final String[] DEFAULT_LINE_FORMAT
The default format defines the expected line property names and their order in the import file. Please update this if the import file format changes (i.e. adding/deleting line properties, changing their order).

Constructor Detail

LineParserBase

public LineParserBase()
Method Detail

getLineFormat

public String[] getLineFormat()
See Also:
ItemParser.getItemFormat()

getAttributeLabel

protected String getAttributeLabel(Class clazz,
                                   String attributeName)
Retrieves the attribute label for the specified attribute.

Parameters:
clazz - the class in which the specified attribute is defined
attributeName - the name of the specified attribute
Returns:
the attribute label for the specified attribute

checkLineClass

protected void checkLineClass(Class<? extends EndowmentTransactionLine> lineClass)
Checks whether the specified Line class is a subclass of EndowmentTransactionLine; throws exceptions if not.

Parameters:
lineClass - the specified line class

checkLineFile

protected void checkLineFile(org.apache.struts.upload.FormFile lineFile)
Checks whether the specified line import file is not null and of a valid format; throws exceptions if conditions not satisfied.

Parameters:
lineClass - the specified line import file

retrieveLineAttributes

protected Map<String,String> retrieveLineAttributes(String line,
                                                    Class<? extends EndowmentTransactionLine> lineClass)
Parses a line of transactions data from a csv file and retrieves the attributes as key-value string pairs into a map.

Parameters:
line - a string read from a line in the line import file
Returns:
a map containing line attribute name-value string pairs

genLineWithRetrievedAttributes

protected EndowmentTransactionLine genLineWithRetrievedAttributes(Map<String,String> lineMap,
                                                                  Class<? extends EndowmentTransactionLine> lineClass)
Generates an line instance and populates it with the specified attribute map.

Parameters:
lineMap - the specified attribute map from which attributes are populated
lineClass - the class of which the new line instance shall be created
Returns:
the populated line

importLines

public List<EndowmentTransactionLine> importLines(org.apache.struts.upload.FormFile lineFile,
                                                  Class<? extends EndowmentTransactionLine> lineClass,
                                                  String documentNumber)
Description copied from interface: LineParser
Parses the items from the specified import file line by line, and generates items of the specified type from the parsed data.

Specified by:
importLines in interface LineParser
documentNumber - the number of the docment that contains the items to be imported
Returns:
a list of items of a subclass of PurApItem.
See Also:
org.kuali.kfs.module.purap.util.ItemParser#parseItem(org.apache.struts.upload.FormFile,java.lang.Class,java.lang.String)

parseLine

public EndowmentTransactionLine parseLine(String transactionLine,
                                          Class<? extends EndowmentTransactionLine> lineClass,
                                          String documentNumber)
See Also:
ItemParser.parseItem(java.lang.String,java.lang.Class,java.lang.String)


Copyright © 2005-2012 The Kuali Foundation. All Rights Reserved.