net.sf.ofx4j.io
Class BaseOFXReader

java.lang.Object
  extended by net.sf.ofx4j.io.BaseOFXReader
All Implemented Interfaces:
OFXReader
Direct Known Subclasses:
NanoXMLOFXReader, TagSoupOFXReader

public abstract class BaseOFXReader
extends java.lang.Object
implements OFXReader

Base class for an OFX reader. Parses the headers and determines whether we're parsing an OFX v2 or OFX v1 element. For OFX v2, uses a standard SAX library.

Author:
Ryan Heaton

Field Summary
static java.util.regex.Pattern OFX_2_PROCESSING_INSTRUCTION_PATTERN
           
 
Constructor Summary
BaseOFXReader()
           
 
Method Summary
 OFXHandler getContentHandler()
          The content handler.
protected  char[] getFirstElementStart()
          The first characters of the first OFX element, '<', 'O', 'F', 'X'
 void parse(java.io.InputStream stream)
          Parses the stream as UTF-8 encoded data.
 void parse(java.io.Reader reader)
          Parse the reader, including the headers.
protected abstract  void parseV1FromFirstElement(java.io.Reader reader)
          Parse an OFX version 1 stream from the first OFX element (defined by the first element characters).
protected  void parseV2FromFirstElement(java.io.Reader reader)
          Parse an OFX version 2 stream from the first OFX element (defined by the first element characters).
protected  void processOFXv1Headers(java.lang.String chars)
          Process the given characters as OFX version 1 headers.
protected  void processOFXv2Headers(java.lang.String chars)
          Process the given characters as OFX version 2 headers.
 void setContentHandler(OFXHandler handler)
          The content handler.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OFX_2_PROCESSING_INSTRUCTION_PATTERN

public static final java.util.regex.Pattern OFX_2_PROCESSING_INSTRUCTION_PATTERN
Constructor Detail

BaseOFXReader

public BaseOFXReader()
Method Detail

getContentHandler

public OFXHandler getContentHandler()
The content handler.

Returns:
The content handler.

setContentHandler

public void setContentHandler(OFXHandler handler)
The content handler.

Specified by:
setContentHandler in interface OFXReader
Parameters:
handler - The content handler.

parse

public void parse(java.io.InputStream stream)
           throws java.io.IOException,
                  OFXParseException
Parses the stream as UTF-8 encoded data.

Specified by:
parse in interface OFXReader
Parameters:
stream - The stream to parse.
Throws:
java.io.IOException
OFXParseException

parse

public void parse(java.io.Reader reader)
           throws java.io.IOException,
                  OFXParseException
Parse the reader, including the headers.

Specified by:
parse in interface OFXReader
Parameters:
reader - The reader.
Throws:
java.io.IOException
OFXParseException

getFirstElementStart

protected char[] getFirstElementStart()
The first characters of the first OFX element, '<', 'O', 'F', 'X'

Returns:
The first characters of the OFX element.

parseV1FromFirstElement

protected abstract void parseV1FromFirstElement(java.io.Reader reader)
                                         throws java.io.IOException,
                                                OFXParseException
Parse an OFX version 1 stream from the first OFX element (defined by the first element characters).

Parameters:
reader - The reader.
Throws:
java.io.IOException
OFXParseException

parseV2FromFirstElement

protected void parseV2FromFirstElement(java.io.Reader reader)
                                throws java.io.IOException,
                                       OFXParseException
Parse an OFX version 2 stream from the first OFX element (defined by the first element characters).

Parameters:
reader - The reader.
Throws:
java.io.IOException
OFXParseException

processOFXv1Headers

protected void processOFXv1Headers(java.lang.String chars)
                            throws java.io.IOException,
                                   OFXParseException
Process the given characters as OFX version 1 headers.

Parameters:
chars - The characters to process.
Throws:
java.io.IOException
OFXParseException

processOFXv2Headers

protected void processOFXv2Headers(java.lang.String chars)
                            throws OFXParseException
Process the given characters as OFX version 2 headers.

Parameters:
chars - The characters to process.
Throws:
OFXParseException


Copyright © 2008. All Rights Reserved.