org.skife.csv
Class SimpleReader

java.lang.Object
  extended byorg.skife.csv.SimpleReader
All Implemented Interfaces:
CSVReader

public class SimpleReader
extends java.lang.Object
implements CSVReader

Provides a means to read CSV files


Field Summary
 
Fields inherited from interface org.skife.csv.CSVReader
BACKSLASH, COMMA, DOUBLE_QUOTE, SINGLE_QUOTE, TAB
 
Constructor Summary
SimpleReader()
           
 
Method Summary
 java.util.List parse(java.io.File in)
          Opens, parses, and closes a file
 void parse(java.io.File in, ReaderCallback callback)
          Opens, parses, and closes a file
 java.util.List parse(java.io.InputStream in)
          Returns a List of String[]
 void parse(java.io.InputStream in, ReaderCallback callback)
          Invoke the callback for each row of the CSV, passing in the fields.
 java.util.List parse(java.io.Reader in)
          Returns a List of String[]
 void parse(java.io.Reader in, ReaderCallback callback)
          Invoke the callback for each row of the CSV, passing in the fields.
 java.util.List parse(java.lang.String raw)
          Returns a List of String[] where it is passed the raw (including line breaks) content of the csv
 void parse(java.lang.String raw, ReaderCallback callback)
          Calls onRow for each row in the raw (including line breaks) content of the csv, passed as a String
 void setEscapeCharacter(char escape)
          Specify an escape character within a field, default is \
 void setLineCommentIndicator(java.lang.String token)
          Specify a string that is used to indicate that a line should be passed over without processing.
 void setQuoteCharacters(char[] quotes)
          Specify an array of chars that will be treated as quotes, ie, will be ignored and everything between them is one field.
 void setSeperator(char seperator)
          Specify the field seperator character, defaults to a comma
 void setTrim(boolean b)
          Trim whitespace around fields, defaults to false
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleReader

public SimpleReader()
Method Detail

parse

public void parse(java.lang.String raw,
                  ReaderCallback callback)
Calls onRow for each row in the raw (including line breaks) content of the csv, passed as a String

Specified by:
parse in interface CSVReader

parse

public java.util.List parse(java.lang.String raw)
Returns a List of String[] where it is passed the raw (including line breaks) content of the csv

Specified by:
parse in interface CSVReader

parse

public java.util.List parse(java.io.File in)
                     throws java.io.IOException
Opens, parses, and closes a file

Specified by:
parse in interface CSVReader
Throws:
java.io.IOException - if there is an error reading
java.io.FileNotFoundException - if the file does not exist

parse

public void parse(java.io.File in,
                  ReaderCallback callback)
           throws java.io.IOException
Opens, parses, and closes a file

Specified by:
parse in interface CSVReader
Throws:
java.io.IOException - if there is an error reading
java.io.FileNotFoundException - if the file does not exist

parse

public java.util.List parse(java.io.Reader in)
                     throws java.io.IOException
Returns a List of String[]

Specified by:
parse in interface CSVReader
Parameters:
in - will not be closed by the reader
Throws:
java.io.IOException

parse

public java.util.List parse(java.io.InputStream in)
                     throws java.io.IOException
Returns a List of String[]

Specified by:
parse in interface CSVReader
Parameters:
in - will not be closed by the reader
Throws:
java.io.IOException

parse

public void parse(java.io.InputStream in,
                  ReaderCallback callback)
           throws java.io.IOException
Invoke the callback for each row of the CSV, passing in the fields.

Specified by:
parse in interface CSVReader
Parameters:
in - will not be closed by the reader
Throws:
java.io.IOException

parse

public void parse(java.io.Reader in,
                  ReaderCallback callback)
           throws java.io.IOException
Invoke the callback for each row of the CSV, passing in the fields.

Specified by:
parse in interface CSVReader
Parameters:
in - will not be closed by the reader
Throws:
java.io.IOException

setEscapeCharacter

public void setEscapeCharacter(char escape)
Specify an escape character within a field, default is \

Specified by:
setEscapeCharacter in interface CSVReader

setSeperator

public void setSeperator(char seperator)
Specify the field seperator character, defaults to a comma

Specified by:
setSeperator in interface CSVReader

setQuoteCharacters

public void setQuoteCharacters(char[] quotes)
Specify an array of chars that will be treated as quotes, ie, will be ignored and everything between them is one field. Default is ' and "

Specified by:
setQuoteCharacters in interface CSVReader

setTrim

public void setTrim(boolean b)
Trim whitespace around fields, defaults to false

Specified by:
setTrim in interface CSVReader
Parameters:
b -

setLineCommentIndicator

public void setLineCommentIndicator(java.lang.String token)
Specify a string that is used to indicate that a line should be passed over without processing. When the passed String is the very first thing on the line, the whole line will be skipped.

Passing null indicates all lines should be processed

Processing all lines is the default behavior

Specified by:
setLineCommentIndicator in interface CSVReader