uk.org.ogsadai.converters.csv
Class CSVParser.CSVReader

java.lang.Object
  |
  +--uk.org.ogsadai.converters.csv.CSVParser.CSVReader
Enclosing class:
CSVParser

private class CSVParser.CSVReader
extends java.lang.Object

Private inner class encapsulating data structure used by the parsing algorithm.


Field Summary
private  int BUFFER_SIZE
           
private  char[] charBlock
           
private  char[] charBlockTemp
           
private  int charsInCharBlock
           
private  int cursorIdx
           
private  int fieldStart
           
private  boolean headerParsed
           
private  boolean nextFieldIncludesDblQuotes
           
private  boolean nextFieldInDblQuotes
           
private  int numberOfColumns
           
private  int numberOfRows
           
private  java.util.Vector recordFields
           
 
Constructor Summary
CSVParser.CSVReader()
          Constructor.
 
Method Summary
protected  void addField(boolean lineBreak)
          Constructs a new field.
protected  void addRow(boolean lineBreak)
          Adds a new row to the output.
private  java.lang.String extractFromDblQuotes(java.lang.String field)
          Removes double quotes from a field value.
protected  char getChar()
          Returns the current character.
protected  boolean next()
          Moves cursor to the next position in the input.
 void nextFieldIncludesDblQuotes()
          Indicates whether the next fields includes double quotes.
 void nextFieldInDblQuotes()
          Indicates whether the next field is in double quotes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BUFFER_SIZE

private int BUFFER_SIZE

fieldStart

private int fieldStart

cursorIdx

private int cursorIdx

charBlock

private char[] charBlock

charBlockTemp

private char[] charBlockTemp

charsInCharBlock

private int charsInCharBlock

nextFieldInDblQuotes

private boolean nextFieldInDblQuotes

nextFieldIncludesDblQuotes

private boolean nextFieldIncludesDblQuotes

numberOfColumns

private int numberOfColumns

numberOfRows

private int numberOfRows

headerParsed

private boolean headerParsed

recordFields

private java.util.Vector recordFields
Constructor Detail

CSVParser.CSVReader

public CSVParser.CSVReader()
Constructor.

Method Detail

next

protected boolean next()
                throws java.io.IOException,
                       CSVParseException,
                       java.sql.SQLException
Moves cursor to the next position in the input.

Returns:
A boolean value indicating whether there is a next position
Throws:
java.io.IOException - if there was a problem reading from the input
java.sql.SQLException
CSVParseException

getChar

protected char getChar()
Returns the current character.

Returns:
current character

addField

protected void addField(boolean lineBreak)
Constructs a new field.

Parameters:
lineBreak - true if there is a line break character at the end of the field.

addRow

protected void addRow(boolean lineBreak)
               throws CSVParseException,
                      java.sql.SQLException
Adds a new row to the output.

Parameters:
lineBreak - true if there is a line break character at the end of the field
Throws:
CSVParseException
java.sql.SQLException

extractFromDblQuotes

private java.lang.String extractFromDblQuotes(java.lang.String field)
Removes double quotes from a field value.

Parameters:
field - field value
Returns:
value where double quotes have been replaced by single quotes

nextFieldIncludesDblQuotes

public void nextFieldIncludesDblQuotes()
Indicates whether the next fields includes double quotes.


nextFieldInDblQuotes

public void nextFieldInDblQuotes()
Indicates whether the next field is in double quotes.