bill.util.csv
Class CSVLineParserAssociated

java.lang.Object
  |
  +--bill.util.csv.CSVLineParser
        |
        +--bill.util.csv.CSVLineParserAssociated

public class CSVLineParserAssociated
extends CSVLineParser

Class for parsing line of CSV data, typically from a file. Extends the standard CSVLineParser class to provide an association with a CSVParser. This functionality is in here rather than in CSVLineParser so that class can be used without depending on any other classes from the csv package.


Constructor Summary
CSVLineParserAssociated(CSVLineParser line, CSVParser parser)
          Copy constructor that performs a deep copy by reparsing the input CSV line.
CSVLineParserAssociated(CSVParser parser)
          'Empty' constructor, calls super class's base contructor and sets the parser.
CSVLineParserAssociated(String line, boolean trim, CSVParser parser)
          Alternate constructor, calls super class's main constructor and sets the parser.
CSVLineParserAssociated(String line, CSVParser parser)
          Main constructor, calls super class's main constructor and sets the parser.
 
Method Summary
 void addLinePart(int partNum, String part)
          Inserts the specified line part at the specified index.
 void addLinePart(String part)
          Appends the specified line part to the current list of line parts.
 CSVParser getParser()
          Retrieves the parser associated with this line.
 void removeLinePart(int partNum)
          Deletes the line part at the specified index.
 void setLine(String line)
          Allows the caller to specify the 'raw' line to be parsed.
 void setLinePart(int partNum, String part)
          Sets the value of the given line part to the specified string.
 void setLineParts(Vector parts)
          Sets the list of parts parsed from the line.
 void setParser(CSVParser parser)
          Sets the parser associated with this line.
 
Methods inherited from class bill.util.csv.CSVLineParser
dumpParts, getLine, getLinePart, getLineParts, getNumberOfLineParts, getUnformattedLine, isTrimmed, main, parseLine, parseLine, setTrimmed
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CSVLineParserAssociated

public CSVLineParserAssociated(CSVParser parser)
'Empty' constructor, calls super class's base contructor and sets the parser. The setLine method should be called when this creator is used to specify the line to be parsed and perform the parsing.
Parameters:
parser - The CSVParser to associate this instance with.
See Also:
setLine(String)

CSVLineParserAssociated

public CSVLineParserAssociated(String line,
                               CSVParser parser)
Main constructor, calls super class's main constructor and sets the parser.
Parameters:
line - The line to split up into its parts.
parser - The CSVParser to associate this instance with.
See Also:
setLine(String)

CSVLineParserAssociated

public CSVLineParserAssociated(String line,
                               boolean trim,
                               CSVParser parser)
Alternate constructor, calls super class's main constructor and sets the parser.
Parameters:
line - The line to split up into its parts.
trim - When set to true the column value that is parsed out is trimmed of leading and trailing spaces. This is only relevant for quoted values, as non quoted values are always trimmed.
parser - The CSVParser to associate this instance with.
See Also:
setLine(String)

CSVLineParserAssociated

public CSVLineParserAssociated(CSVLineParser line,
                               CSVParser parser)
Copy constructor that performs a deep copy by reparsing the input CSV line.
Parameters:
line - The CSV line to be copied.
parser - The CSVParser to associate this instance with.
Method Detail

getParser

public CSVParser getParser()
Retrieves the parser associated with this line.
Returns:
The line's associated parser.

setParser

public void setParser(CSVParser parser)
Sets the parser associated with this line.
Parameters:
parser - The line's associated parser.

setLine

public void setLine(String line)
Allows the caller to specify the 'raw' line to be parsed. Typically only used when using the default constructor as the other constructor take the line as a parameter.
Overrides:
setLine in class CSVLineParser
Parameters:
line - The line to split up into its parts.

setLinePart

public void setLinePart(int partNum,
                        String part)
Sets the value of the given line part to the specified string.
Overrides:
setLinePart in class CSVLineParser
Parameters:
partNum - The index of the part to be set, this is a 0 (zero) based value, so 0 = first part.
part - The string value to set the line part to.

setLineParts

public void setLineParts(Vector parts)
Sets the list of parts parsed from the line.
Overrides:
setLineParts in class CSVLineParser
Parameters:
parts - List of parts to be assigned.

addLinePart

public void addLinePart(String part)
Appends the specified line part to the current list of line parts.
Overrides:
addLinePart in class CSVLineParser
Parameters:
part - The line part to add.

addLinePart

public void addLinePart(int partNum,
                        String part)
Inserts the specified line part at the specified index. Each line part in this line with an index greater or equal to the specified index is shifted upward to have an index one greater than the value it had previously.
The index must be a value greater than or equal to 0 and less than or equal to the current number of line parts. (If the index is equal to the current number of line parts, the new line part is appended to the existing line parts.)
Overrides:
addLinePart in class CSVLineParser
Parameters:
partNum - The index to insert the new line part at.
part - The line part to add.

removeLinePart

public void removeLinePart(int partNum)
Deletes the line part at the specified index. Each line part in this line with an index greater or equal to the specified index is shifted downward to have an index one smaller than the value it had previously.
The index must be a value greater than or equal to 0 and less than the current number of line parts.
Overrides:
removeLinePart in class CSVLineParser
Parameters:
partNum - The index of the line part to remove.