toolbox.parsers
Class DelimitedParser

Package class diagram package DelimitedParser
java.lang.Object
  extended by toolbox.parsers.DelimitedParser

public class DelimitedParser
extends java.lang.Object

Generic parser to parse delimited data.


Nested Class Summary
(package private)  class DelimitedParser.DelimParseThread
          Thread that creates TextEvent objects from a StreamTokenizer and presents the events to a TextListener instance.
 
Constructor Summary
DelimitedParser(char delim, char quote, TextListener listener)
          Creates a new parse with the given delimiter, quote charactor and event listener.
DelimitedParser(TextListener listener)
          Creates a new parser with the given listener, a ',' as delimiter and '"' as quote character.
 
Method Summary
 char getDelimiter()
          Returns the the delimiter that this parser uses to delimit input data.
 char getQuote()
          Returns the the quote character that this parser uses to denote constant strings.
 void parse(java.io.InputStream is, boolean wait)
          Parses the given InputStream and notifies the listener of parsing events.
 void setDelimiter(char delim)
          Set the delimiter for this parser.
 void setQuote(char quote)
          Set the quote character for this parser.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DelimitedParser

public DelimitedParser(TextListener listener)
Creates a new parser with the given listener, a ',' as delimiter and '"' as quote character.

Parameters:
listener - TextListener that will receive notification of events.

DelimitedParser

public DelimitedParser(char delim,
                       char quote,
                       TextListener listener)
                throws java.io.IOException
Creates a new parse with the given delimiter, quote charactor and event listener.

Parameters:
delim - Delimiter that will be used to delimit input data.
quote - Indicates what character denotes constant strings.
listener - TextListener that will receive notification of events.
Throws:
java.io.IOException
Method Detail

getDelimiter

public char getDelimiter()
Returns the the delimiter that this parser uses to delimit input data.

Returns:
char containing this parser's delimiter.

setDelimiter

public void setDelimiter(char delim)
Set the delimiter for this parser.

Parameters:
delim - New delimiter.

getQuote

public char getQuote()
Returns the the quote character that this parser uses to denote constant strings.

Returns:
char containing this parser's quote character.

setQuote

public void setQuote(char quote)
Set the quote character for this parser.

Parameters:
quote - New quote character.

parse

public void parse(java.io.InputStream is,
                  boolean wait)
           throws java.io.IOException
Parses the given InputStream and notifies the listener of parsing events. A parsing event is generated when a newline character is encountered.

Parameters:
is - InputStream containing data to parse
wait - boolean to indicate whether not this method should wait for parsing to stop before returning.
Throws:
java.io.IOException - if a an exception occurs during parsing.