org.databene.document.csv
Class CSVLineIterator

java.lang.Object
  extended by org.databene.document.csv.CSVLineIterator
All Implemented Interfaces:
java.io.Closeable, java.util.Iterator<java.lang.String[]>, HeavyweightIterator<java.lang.String[]>

public class CSVLineIterator
extends java.lang.Object
implements HeavyweightIterator<java.lang.String[]>

Gives accesses to content of a CSV file by String arrays that represent the CSV rows as specified in RFC 4180.

Author:
Volker Bergmann

Field Summary
static char DEFAULT_SEPARATOR
          The default separator to use
 
Constructor Summary
CSVLineIterator(java.io.Reader reader)
          Creates a parser that reads from a reader
CSVLineIterator(java.io.Reader reader, char separator)
          Creates a parser that reads from a reader and used a special separator character
CSVLineIterator(java.io.Reader reader, char separator, boolean ignoreEmptyLines)
           
CSVLineIterator(java.lang.String uri)
          Creates a parser that reads from a uri
CSVLineIterator(java.lang.String uri, char separator)
          Creates a parser that reads from a uri
CSVLineIterator(java.lang.String uri, char separator, boolean ignoreEmptyLines)
           
CSVLineIterator(java.lang.String uri, char separator, boolean ignoreEmptyLines, java.lang.String encoding)
           
CSVLineIterator(java.lang.String uri, char separator, java.lang.String encoding)
           
 
Method Summary
 void close()
          Closes the source
 boolean hasNext()
           
 int lineCount()
           
 java.lang.String[] next()
          Parses a CSV row into an array of Strings
static void process(java.lang.String uri, char separator, java.lang.String encoding, boolean ignoreEmptyLines, CSVLineHandler lineHandler)
           
 void remove()
           
 
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
Constructor Detail

CSVLineIterator

public CSVLineIterator(java.lang.String uri)
                throws java.io.IOException
Creates a parser that reads from a uri

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

CSVLineIterator

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

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

CSVLineIterator

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

CSVLineIterator

public CSVLineIterator(java.lang.String uri,
                       char separator,
                       boolean ignoreEmptyLines)
                throws java.io.IOException
Throws:
java.io.IOException

CSVLineIterator

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

CSVLineIterator

public CSVLineIterator(java.io.Reader reader)
                throws java.io.IOException
Creates a parser that reads from a reader

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

CSVLineIterator

public CSVLineIterator(java.io.Reader reader,
                       char separator)
                throws java.io.IOException
Creates a parser that reads from a reader and used a special separator character

Parameters:
reader - the reader to use
separator - the separator character
Throws:
java.io.IOException

CSVLineIterator

public CSVLineIterator(java.io.Reader reader,
                       char separator,
                       boolean ignoreEmptyLines)
                throws java.io.IOException
Throws:
java.io.IOException
Method Detail

hasNext

public boolean hasNext()
Specified by:
hasNext in interface java.util.Iterator<java.lang.String[]>

next

public java.lang.String[] next()
Parses a CSV row into an array of Strings

Specified by:
next in interface java.util.Iterator<java.lang.String[]>
Returns:
an array of Strings that represents a CSV row

remove

public void remove()
Specified by:
remove in interface java.util.Iterator<java.lang.String[]>

close

public void close()
Closes the source

Specified by:
close in interface java.io.Closeable

lineCount

public int lineCount()

process

public static void process(java.lang.String uri,
                           char separator,
                           java.lang.String encoding,
                           boolean ignoreEmptyLines,
                           CSVLineHandler lineHandler)
                    throws java.io.IOException
Throws:
java.io.IOException


Copyright © 2010. All Rights Reserved.