org.jplate.tabular.csv.parser.impl.defaults
Class DefaultJPlateCsvParser<B extends CsvBuilderIfc<?>>

java.lang.Object
  extended by org.jplate.foundation.parser.javacc.impl.AbstractJavaccParser<B>
      extended by org.jplate.tabular.csv.parser.impl.defaults.DefaultJPlateCsvParser<B>
All Implemented Interfaces:
JavaccParserIfc<B>, JPlateParserIfc<B>, CsvParserIfc<B>, DefaultJPlateCsvParserConstants, TabularParserIfc<B>

public final class DefaultJPlateCsvParser<B extends CsvBuilderIfc<?>>
extends AbstractJavaccParser<B>
implements CsvParserIfc<B>, DefaultJPlateCsvParserConstants

This implementation of a CSV parser deviates from RFC 4180 in that a record may end with a comma as well as allow fields to be denoted as empty using double commas or preceeding/postceeding commas. For example:

Please note: The above is the only deviation with RFC 4180. For a strict implementation, use the parser DefaultRfc4180CsvParser also found in this package. Additionally: This class is not thread-safe.

The following are some examples on how to use this class. Assume some implemention of CsvBuilderIfc exists.

Modifications:
    $Date: 2008-12-02 12:32:45 -0500 (Tue, 02 Dec 2008) $
    $Revision: 479 $
    $Author: sfloess $
    $HeadURL: https://jplate.svn.sourceforge.net/svnroot/jplate/trunk/src/dev/javacc/org/jplate/tabular/csv/parser/impl/defaults/DefaultJPlateCsvParser.jj $
    

See Also:
DefaultRfc4180CsvParser

Field Summary
private  org.apache.commons.logging.Log _log
          Used for logging.
private  java.util.Vector jj_expentries
           
private  int[] jj_expentry
           
private  int jj_gen
           
(package private)  SimpleCharStream jj_input_stream
           
private  int jj_kind
           
private  int[] jj_la1
           
private static int[] jj_la1_0
           
 Token jj_nt
           
private  int jj_ntk
           
 Token token
           
 DefaultJPlateCsvParserTokenManager token_source
           
 
Fields inherited from interface org.jplate.tabular.csv.parser.impl.defaults.DefaultJPlateCsvParserConstants
CR, DEFAULT, DELIMITER, DOUBLE_QUOTE, EOF, EOL, LF, NON_QUOTED_FIELD, QUOTED_FIELD, TEXT, tokenImage, TWO_DOUBLE_QUOTES
 
Fields inherited from interface org.jplate.foundation.parser.javacc.JavaccParserIfc
BUILDER_IS_NULL_MSG, FILE_DOES_NOT_EXIST_MSG, FILE_IS_NULL_MSG, INPUT_STREAM_IS_NULL_MSG, READER_IS_NULL_MSG, STRING_IS_EMPTY_MSG
 
Constructor Summary
DefaultJPlateCsvParser()
          Default constructor.
DefaultJPlateCsvParser(DefaultJPlateCsvParserTokenManager tm)
           
DefaultJPlateCsvParser(java.io.InputStream stream)
           
DefaultJPlateCsvParser(java.io.InputStream stream, java.lang.String encoding)
           
DefaultJPlateCsvParser(java.io.Reader stream)
           
 
Method Summary
 void disable_tracing()
           
 void enable_tracing()
           
 ParseException generateParseException()
           
 Token getNextToken()
           
 Token getToken(int index)
           
private  Token jj_consume_token(int kind)
           
private static void jj_la1_0()
           
private  int jj_ntk()
           
protected  void parse(B builder)
          Is called by self to start parsing.
 void ReInit(DefaultJPlateCsvParserTokenManager tm)
           
 void ReInit(java.io.InputStream stream)
          JavaCC will generate this method so it is not needed to be implemented.
 void ReInit(java.io.InputStream stream, java.lang.String encoding)
          JavaCC will generate this method so it is not needed to be implemented.
 void ReInit(java.io.Reader stream)
          JavaCC will generate this method so it is not needed to be implemented.
 
Methods inherited from class org.jplate.foundation.parser.javacc.impl.AbstractJavaccParser
parse, parse, parse, parse
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jplate.foundation.parser.JPlateParserIfc
parse, parse, parse, parse
 

Field Detail

_log

private final transient org.apache.commons.logging.Log _log
Used for logging.


token_source

public DefaultJPlateCsvParserTokenManager token_source

jj_input_stream

SimpleCharStream jj_input_stream

token

public Token token

jj_nt

public Token jj_nt

jj_ntk

private int jj_ntk

jj_gen

private int jj_gen

jj_la1

private final int[] jj_la1

jj_la1_0

private static int[] jj_la1_0

jj_expentries

private java.util.Vector jj_expentries

jj_expentry

private int[] jj_expentry

jj_kind

private int jj_kind
Constructor Detail

DefaultJPlateCsvParser

public DefaultJPlateCsvParser()
Default constructor.


DefaultJPlateCsvParser

public DefaultJPlateCsvParser(java.io.InputStream stream)

DefaultJPlateCsvParser

public DefaultJPlateCsvParser(java.io.InputStream stream,
                              java.lang.String encoding)

DefaultJPlateCsvParser

public DefaultJPlateCsvParser(java.io.Reader stream)

DefaultJPlateCsvParser

public DefaultJPlateCsvParser(DefaultJPlateCsvParserTokenManager tm)
Method Detail

parse

protected final void parse(B builder)
                    throws ParseException,
                           java.lang.Exception
Description copied from class: AbstractJavaccParser
Is called by self to start parsing.

Specified by:
parse in class AbstractJavaccParser<B extends CsvBuilderIfc<?>>
Parameters:
builder - The object who can create objects from data contained in parser input stream/reader.
Throws:
java.lang.Exception - If any issue arise during parsing.
ParseException

jj_la1_0

private static void jj_la1_0()

ReInit

public void ReInit(java.io.InputStream stream)
Description copied from interface: JavaccParserIfc
JavaCC will generate this method so it is not needed to be implemented.

Specified by:
ReInit in interface JavaccParserIfc<B extends CsvBuilderIfc<?>>
Parameters:
stream - The stream from which parsing will commence.

ReInit

public void ReInit(java.io.InputStream stream,
                   java.lang.String encoding)
Description copied from interface: JavaccParserIfc
JavaCC will generate this method so it is not needed to be implemented.

Specified by:
ReInit in interface JavaccParserIfc<B extends CsvBuilderIfc<?>>
Parameters:
stream - The stream from which parsing will commence.
encoding - The character encoding to use when parsing.

ReInit

public void ReInit(java.io.Reader stream)
Description copied from interface: JavaccParserIfc
JavaCC will generate this method so it is not needed to be implemented.

Specified by:
ReInit in interface JavaccParserIfc<B extends CsvBuilderIfc<?>>
Parameters:
stream - The reader from which parsing will commence.

ReInit

public void ReInit(DefaultJPlateCsvParserTokenManager tm)

jj_consume_token

private final Token jj_consume_token(int kind)
                              throws ParseException
Throws:
ParseException

getNextToken

public final Token getNextToken()

getToken

public final Token getToken(int index)

jj_ntk

private final int jj_ntk()

generateParseException

public ParseException generateParseException()

enable_tracing

public final void enable_tracing()

disable_tracing

public final void disable_tracing()