org.databene.document.csv
Class CSVTokenizer

java.lang.Object
  extended by org.databene.document.csv.CSVTokenizer
All Implemented Interfaces:
java.io.Closeable

public class CSVTokenizer
extends java.lang.Object
implements java.io.Closeable

Parses a CSV file token by token as specified in RFC 4180. It returns parsed values as CSVTokensType of type CELL, EOL and EOF. The current cell content is accessible by the public attribute 'cell'.

Created: 26.08.2006 17:19:35

See Also:
CSVTokenType

Field Summary
 java.lang.String cell
          String representation of the cell at the cursor position.
static char DEFAULT_SEPARATOR
          The default separator to use
 int endColumn
           
 CSVTokenType lastType
           
 int line
           
 int startColumn
           
 CSVTokenType ttype
          The token at the cursor position
 
Constructor Summary
CSVTokenizer(java.io.Reader reader)
          Creates a tokenizer that reads from a java.io.Reader.
CSVTokenizer(java.io.Reader reader, char separator)
          Creates a tokenizer that reads from a java.io.Reader.
CSVTokenizer(java.lang.String uri)
          Creates a tokenizer that reads from a URL.
CSVTokenizer(java.lang.String uri, char separator)
          Creates a tokenizer that reads from a uri.
CSVTokenizer(java.lang.String uri, char separator, java.lang.String encoding)
           
 
Method Summary
 void close()
          Closes the source
 CSVTokenType lastTtype()
           
 CSVTokenType next()
          Returns the next token.
 void skipLine()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_SEPARATOR

public static final char DEFAULT_SEPARATOR
The default separator to use

See Also:
Constant Field Values

ttype

public CSVTokenType ttype
The token at the cursor position


lastType

public CSVTokenType lastType

cell

public java.lang.String cell
String representation of the cell at the cursor position. If the cursor is at a EOL/EOF position, this is null


line

public int line

startColumn

public int startColumn

endColumn

public int endColumn
Constructor Detail

CSVTokenizer

public CSVTokenizer(java.lang.String uri)
             throws java.io.IOException
Creates a tokenizer that reads from a URL.

Parameters:
uri - the URL to read from
Throws:
java.io.IOException

CSVTokenizer

public CSVTokenizer(java.lang.String uri,
                    char separator)
             throws java.io.IOException
Creates a tokenizer that reads from a uri.

Parameters:
uri - the uri to read from
separator - character used for separating CSV cells
Throws:
java.io.IOException

CSVTokenizer

public CSVTokenizer(java.lang.String uri,
                    char separator,
                    java.lang.String encoding)
             throws java.io.IOException
Throws:
java.io.IOException

CSVTokenizer

public CSVTokenizer(java.io.Reader reader)
Creates a tokenizer that reads from a java.io.Reader.

Parameters:
reader - the reader to use as input

CSVTokenizer

public CSVTokenizer(java.io.Reader reader,
                    char separator)
Creates a tokenizer that reads from a java.io.Reader.

Parameters:
reader - the reader to use as input
separator - character used for separating CSV cells
Method Detail

next

public CSVTokenType next()
                  throws java.io.IOException
Returns the next token.

Returns:
the next token
Throws:
java.io.IOException - if source access fails

skipLine

public void skipLine()
              throws java.io.IOException
Throws:
java.io.IOException

close

public void close()
Closes the source

Specified by:
close in interface java.io.Closeable

lastTtype

public CSVTokenType lastTtype()


Copyright © 2010. All Rights Reserved.