org.attoparser
Class AbstractAttoParser

Object
  extended by org.attoparser.AbstractAttoParser
All Implemented Interfaces:
IAttoParser
Direct Known Subclasses:
AbstractBufferedAttoParser

public abstract class AbstractAttoParser
extends Object
implements IAttoParser

Base abstract class for all IAttoParser implementations, providing common code for unifying all the supported document formats (String, char[], char[] segment, Reader) into just one (Reader).

Subclasses of this class should only implement the abstract parseDocument(Reader, IAttoHandler) method.

Since:
1.0
Author:
Daniel Fernández

Constructor Summary
protected AbstractAttoParser()
           
 
Method Summary
 void parse(char[] document, IAttoHandler handler)
           Parse a document using the specified IAttoHandler.
 void parse(char[] document, int offset, int len, IAttoHandler handler)
           Parse a document using the specified IAttoHandler.
 void parse(Reader reader, IAttoHandler handler)
           Parse a document using the specified IAttoHandler.
 void parse(String document, IAttoHandler handler)
           Parse a document using the specified IAttoHandler.
protected abstract  void parseDocument(Reader reader, IAttoHandler handler)
           Parse the document, as a Reader.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractAttoParser

protected AbstractAttoParser()
Method Detail

parse

public final void parse(String document,
                        IAttoHandler handler)
                 throws AttoParseException
Description copied from interface: IAttoParser

Parse a document using the specified IAttoHandler.

Specified by:
parse in interface IAttoParser
Parameters:
document - the document to be parsed, as a String.
handler - the handler to be used, an IAttoHandler implementation.
Throws:
AttoParseException - if the document cannot be parsed.

parse

public final void parse(char[] document,
                        IAttoHandler handler)
                 throws AttoParseException
Description copied from interface: IAttoParser

Parse a document using the specified IAttoHandler.

Specified by:
parse in interface IAttoParser
Parameters:
document - the document to be parsed, as a char[].
handler - the handler to be used, an IAttoHandler implementation.
Throws:
AttoParseException - if the document cannot be parsed.

parse

public final void parse(char[] document,
                        int offset,
                        int len,
                        IAttoHandler handler)
                 throws AttoParseException
Description copied from interface: IAttoParser

Parse a document using the specified IAttoHandler.

Specified by:
parse in interface IAttoParser
Parameters:
document - the document to be parsed, as a char[].
offset - the offset to be applied on the char[] document to determine the start of the document contents.
len - the length (in chars) of the document stored in the char[].
handler - the handler to be used, an IAttoHandler implementation.
Throws:
AttoParseException - if the document cannot be parsed.

parse

public final void parse(Reader reader,
                        IAttoHandler handler)
                 throws AttoParseException
Description copied from interface: IAttoParser

Parse a document using the specified IAttoHandler.

Implementations of this interface must close the provided Reader object after parsing.

Specified by:
parse in interface IAttoParser
Parameters:
reader - a Reader on the document.
handler - the handler to be used, an IAttoHandler implementation.
Throws:
AttoParseException - if the document cannot be parsed.

parseDocument

protected abstract void parseDocument(Reader reader,
                                      IAttoHandler handler)
                               throws AttoParseException

Parse the document, as a Reader.

This method is meant for overriding, and is the only parsing method that subclasses need to implement.

Parameters:
reader - a Reader on the document.
handler - the handler to be used, an IAttoHandler implementation.
Throws:
AttoParseException - if the document cannot be parsed.


Copyright © 2012 The ATTOPARSER team. All Rights Reserved.