scratch.scott
Class CSVParser

java.lang.Object
  extended by scratch.scott.CSVParser

public class CSVParser
extends Object

Author:
Scott

Field Summary
static char DEFAULT_SEP
           
protected  char fieldSep
          the separator char for this parser
protected  ArrayList list
          The fields in the current String
 
Constructor Summary
CSVParser()
          Construct a CSV parser, with the default separator (`,').
CSVParser(char sep)
          Construct a CSV parser with a given separator.
 
Method Summary
protected  int advPlain(String s, StringBuffer sb, int i)
          advPlain: unquoted field; return index of next separator
protected  int advQuoted(String s, StringBuffer sb, int i)
          advQuoted: quoted field; return index of next separator
 Iterator parse(String line)
          parse: break the input String into fields
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_SEP

public static final char DEFAULT_SEP
See Also:
Constant Field Values

list

protected ArrayList list
The fields in the current String


fieldSep

protected char fieldSep
the separator char for this parser

Constructor Detail

CSVParser

public CSVParser()
Construct a CSV parser, with the default separator (`,').


CSVParser

public CSVParser(char sep)
Construct a CSV parser with a given separator. Must be exactly the string that is the separator, not a list of separator characters!

Method Detail

parse

public Iterator parse(String line)
parse: break the input String into fields

Returns:
java.util.Iterator containing each field from the original as a String, in order.

advQuoted

protected int advQuoted(String s,
                        StringBuffer sb,
                        int i)
advQuoted: quoted field; return index of next separator


advPlain

protected int advPlain(String s,
                       StringBuffer sb,
                       int i)
advPlain: unquoted field; return index of next separator