|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
Objectorg.attoparser.AbstractAttoHandler
public abstract class AbstractAttoHandler
Base abstract class for IAttoHandler implementations,
providing timing.
This class provides empty implementations for all event handlers, so that subclasses can override only the methods they need.
| Constructor Summary | |
|---|---|
protected |
AbstractAttoHandler()
|
| Method Summary | |
|---|---|
long |
getEndTimeNanos()
Return the current time (in nanoseconds) obtained when parsing ends. |
long |
getStartTimeNanos()
Return the current time (in nanoseconds) obtained when parsing starts. |
long |
getTotalTimeNanos()
Return the difference (in nanoseconds) between parsing start and end times. |
void |
handleDocumentEnd(int line,
int col)
Called at the end of document parsing. |
void |
handleDocumentEnd(long endTimeNanos,
long totalTimeNanos,
int line,
int col)
Called at the end of document parsing, adding timing information. |
void |
handleDocumentStart(int line,
int col)
Called at the beginning of document parsing. |
void |
handleDocumentStart(long startTimeNanos,
int line,
int col)
Called at the beginning of document parsing, adding timing information. |
void |
handleStructure(char[] buffer,
int offset,
int len,
int line,
int col)
Called when a structure artifact is found. |
void |
handleText(char[] buffer,
int offset,
int len,
int line,
int col)
Called when a text artifact is found. |
| Methods inherited from class Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
protected AbstractAttoHandler()
| Method Detail |
|---|
public final void handleDocumentStart(int line,
int col)
throws AttoParseException
IAttoHandlerCalled at the beginning of document parsing.
handleDocumentStart in interface IAttoHandlerline - the line of the document where parsing starts (usually number 1)col - the column of the document where parsing starts (usually number 1)
AttoParseException
public final void handleDocumentEnd(int line,
int col)
throws AttoParseException
IAttoHandlerCalled at the end of document parsing.
handleDocumentEnd in interface IAttoHandlerline - the line of the document where parsing ends (usually the last one)col - the column of the document where the parsing ends (usually the last one)
AttoParseException
public void handleText(char[] buffer,
int offset,
int len,
int line,
int col)
throws AttoParseException
IAttoHandlerCalled when a text artifact is found.
A sequence of chars is considered to be text when no structures of any kind are contained inside it. In markup parsers, for example, this means no tags (a.k.a. elements), DOCTYPE's, processing instructions, etc. are contained in the sequence.
Text sequences might include any number of new line and/or control characters.
Text artifacts are reported using the document buffer directly, and this buffer should not be considered to be immutable, so reported texts should be copied if they need to be stored (either by copying len chars from the buffer char[] starting in offset or by creating a String from it using the same specification).
Implementations of this handler should never modify the document buffer.
handleText in interface IAttoHandlerbuffer - the document buffer (not copied)offset - the offset (position in buffer) where the text artifact starts.len - the length (in chars) of the text artifact, starting in offset.line - the line in the original document where this text artifact starts.col - the column in the original document where this text artifact starts.
AttoParseException
public void handleStructure(char[] buffer,
int offset,
int len,
int line,
int col)
throws AttoParseException
IAttoHandlerCalled when a structure artifact is found.
Depending on the specific IAttoParser implementation being used,
"structure" might have a different meaning. In markup-oriented parsers (like the default
MarkupAttoParser) implementation provided, structures
like tags (a.k.a. elements), DOCTYPEs, XML Declarations, processing instructions,
etc. are reported using this event handler.
Lower-level IAttoHandler implementations will usually provide a finer-grained
differentiation among the different types of structures (see for example
AbstractBasicMarkupAttoHandler or
AbstractDetailedMarkupAttoHandler).
Structure artifacts are reported using the document buffer directly, and this buffer should not be considered to be immutable, so reported structures should be copied if they need to be stored (either by copying len chars from the buffer char[] starting in offset or by creating a String from it using the same specification).
Implementations of this handler should never modify the document buffer.
handleStructure in interface IAttoHandlerbuffer - the document buffer (not copied)offset - the offset (position in buffer) where the structure artifact starts.len - the length (in chars) of the structure artifact, starting in offset.line - the line in the original document where this structure artifact starts.col - the column in the original document where this structure artifact starts.
AttoParseException
public void handleDocumentStart(long startTimeNanos,
int line,
int col)
throws AttoParseException
ITimedDocumentHandlingCalled at the beginning of document parsing, adding timing information.
handleDocumentStart in interface ITimedDocumentHandlingstartTimeNanos - the current time (in nanoseconds) obtained when parsing starts.line - the line of the document where parsing starts (usually number 1)col - the column of the document where parsing starts (usually number 1)
AttoParseException
public void handleDocumentEnd(long endTimeNanos,
long totalTimeNanos,
int line,
int col)
throws AttoParseException
ITimedDocumentHandlingCalled at the end of document parsing, adding timing information.
handleDocumentEnd in interface ITimedDocumentHandlingendTimeNanos - the current time (in nanoseconds) obtained when parsing ends.totalTimeNanos - the difference between current times at the start and end of
parsing (in nanoseconds)line - the line of the document where parsing ends (usually the last one)col - the column of the document where the parsing ends (usually the last one)
AttoParseExceptionpublic final long getStartTimeNanos()
ITimedDocumentHandlingReturn the current time (in nanoseconds) obtained when parsing starts.
getStartTimeNanos in interface ITimedDocumentHandlingpublic final long getEndTimeNanos()
ITimedDocumentHandlingReturn the current time (in nanoseconds) obtained when parsing ends.
getEndTimeNanos in interface ITimedDocumentHandlingpublic final long getTotalTimeNanos()
ITimedDocumentHandlingReturn the difference (in nanoseconds) between parsing start and end times.
getTotalTimeNanos in interface ITimedDocumentHandling
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||