org.attoparser
Class AbstractBufferedAttoParser

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

public abstract class AbstractBufferedAttoParser
extends AbstractAttoParser

Base abstract class for IAttoParser implementations reading the parsed document using a buffer.

Subclasses of this abstract class should only implement the abstract parseBuffer(char[], int, int, IAttoHandler, int, int) method.

This class closes the document Reader provided after parsing.

Since:
1.0
Author:
Daniel Fernández

Nested Class Summary
static class AbstractBufferedAttoParser.BufferParseResult
           This class encapsulates the results of parsing a fragment (a buffer) of a document.
 
Field Summary
static int BUFFER_SIZE
           Default buffer size to be used (buffer size will grow at runtime if an artifact (structure or text) is bigger than the whole buffer).
 
Constructor Summary
protected AbstractBufferedAttoParser()
           
 
Method Summary
protected abstract  AbstractBufferedAttoParser.BufferParseResult parseBuffer(char[] buffer, int offset, int len, IAttoHandler handler, int line, int col)
           Parse a buffer segment and return a AbstractBufferedAttoParser.BufferParseResult reporting the results of this parsing.
protected  void parseDocument(Reader reader, IAttoHandler handler)
           Parse the document, as a Reader.
 
Methods inherited from class org.attoparser.AbstractAttoParser
parse, parse, parse, parse
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BUFFER_SIZE

public static final int BUFFER_SIZE

Default buffer size to be used (buffer size will grow at runtime if an artifact (structure or text) is bigger than the whole buffer). Value: 4096 chars.

See Also:
Constant Field Values
Constructor Detail

AbstractBufferedAttoParser

protected AbstractBufferedAttoParser()
Method Detail

parseDocument

protected final void parseDocument(Reader reader,
                                   IAttoHandler handler)
                            throws AttoParseException
Description copied from class: AbstractAttoParser

Parse the document, as a Reader.

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

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

parseBuffer

protected abstract AbstractBufferedAttoParser.BufferParseResult parseBuffer(char[] buffer,
                                                                            int offset,
                                                                            int len,
                                                                            IAttoHandler handler,
                                                                            int line,
                                                                            int col)
                                                                     throws AttoParseException

Parse a buffer segment and return a AbstractBufferedAttoParser.BufferParseResult reporting the results of this parsing.

Parameters:
buffer - the document buffer.
offset - the offset (in the document buffer) of the segment to be parsed.
len - the length (in chars) of the segment to be parsed.
handler - the IAttoHandler implementation to be used for reporting events.
line - the line of the first position (offset) in buffer.
col - the column of the first position (offset) in buffer.
Returns:
a AbstractBufferedAttoParser.BufferParseResult reporting the parsing status.
Throws:
AttoParseException - if an error occurs.


Copyright © 2013 The ATTOPARSER team. All Rights Reserved.