|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Object org.attoparser.AbstractAttoHandler org.attoparser.markup.AbstractBasicMarkupAttoHandler org.attoparser.markup.AbstractDetailedMarkupAttoHandler org.attoparser.markup.xml.AbstractDetailedXmlAttoHandler org.attoparser.markup.xml.AbstractStandardXmlAttoHandler org.attoparser.markup.xml.DOMXmlAttoHandler
public final class DOMXmlAttoHandler
Implementation of IAttoHandler
that considers input
as XML code and builds an attoDOM tree with objects from package
org.attoparser.markup.dom.
Use of this handler requires the document to be well-formed from the XML standpoint.
Constructor Summary | |
---|---|
DOMXmlAttoHandler()
Creates a new instance of this handler. |
|
DOMXmlAttoHandler(String documentName)
Creates a new instance of this handler. |
Method Summary | |
---|---|
Document |
getDocument()
Returns the attoDOM Document created during parsing. |
long |
getParsingEndTimeNanos()
Returns the time (in nanoseconds) when parsing ended. |
long |
getParsingStartTimeNanos()
Returns the time (in nanoseconds) when parsing started. |
long |
getParsingTotalTimeNanos()
Returns the difference (in nanoseconds) between parsing start and end. |
void |
handleCDATASection(char[] buffer,
int offset,
int len,
int line,
int col)
Called when a CDATA section is found. |
void |
handleComment(char[] buffer,
int offset,
int len,
int line,
int col)
Called when a comment is found. |
void |
handleDocType(String elementName,
String publicId,
String systemId,
String internalSubset,
int line,
int col)
Called when a DOCTYPE clause is found. |
void |
handleProcessingInstruction(String target,
String content,
int line,
int col)
Called when a Processing Instruction is found. |
void |
handleText(char[] buffer,
int offset,
int len,
int line,
int col)
Called when a text artifact is found. |
void |
handleXmlCloseElement(String elementName,
int line,
int col)
Called when a close element (a close tag) is found. |
void |
handleXmlDeclaration(String version,
String encoding,
String standalone,
int line,
int col)
Called when an XML Declaration is found. |
void |
handleXmlDocumentEnd(long endTimeNanos,
long totalTimeNanos,
int line,
int col)
|
void |
handleXmlDocumentStart(long startTimeNanos,
int line,
int col)
|
void |
handleXmlOpenElement(String elementName,
Map<String,String> attributes,
int line,
int col)
Called when an open element (an open tag) is found. |
void |
handleXmlStandaloneElement(String elementName,
Map<String,String> attributes,
int line,
int col)
Called when a standalone element (a minimized tag) is found. |
boolean |
isParsingFinished()
Returns whether parsing has already finished or not. |
Methods inherited from class org.attoparser.markup.xml.AbstractDetailedXmlAttoHandler |
---|
handleAutoCloseElementEnd, handleAutoCloseElementStart, handleCloseElementEnd, handleCloseElementStart, handleDocumentEnd, handleDocumentStart, handleOpenElementEnd, handleOpenElementStart, handleStandaloneElementEnd, handleStandaloneElementStart |
Methods inherited from class org.attoparser.markup.AbstractDetailedMarkupAttoHandler |
---|
handleCloseElement, handleDocType, handleDocumentEnd, handleDocumentStart, handleOpenElement, handleStandaloneElement, handleUnmatchedCloseElementEnd, handleUnmatchedCloseElementStart, handleXmlDeclaration |
Methods inherited from class org.attoparser.markup.AbstractBasicMarkupAttoHandler |
---|
handleStructure |
Methods inherited from class org.attoparser.AbstractAttoHandler |
---|
getEndTimeNanos, getStartTimeNanos, getTotalTimeNanos, handleDocumentEnd, handleDocumentStart |
Methods inherited from class Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DOMXmlAttoHandler()
Creates a new instance of this handler.
public DOMXmlAttoHandler(String documentName)
Creates a new instance of this handler.
Method Detail |
---|
public Document getDocument()
Returns the attoDOM Document
created during parsing.
public long getParsingStartTimeNanos()
Returns the time (in nanoseconds) when parsing started.
public long getParsingEndTimeNanos()
Returns the time (in nanoseconds) when parsing ended.
public long getParsingTotalTimeNanos()
Returns the difference (in nanoseconds) between parsing start and end.
public boolean isParsingFinished()
Returns whether parsing has already finished or not.
public void handleXmlDocumentStart(long startTimeNanos, int line, int col) throws AttoParseException
handleXmlDocumentStart
in class AbstractDetailedXmlAttoHandler
AttoParseException
public void handleXmlDocumentEnd(long endTimeNanos, long totalTimeNanos, int line, int col) throws AttoParseException
handleXmlDocumentEnd
in class AbstractDetailedXmlAttoHandler
AttoParseException
public void handleXmlDeclaration(String version, String encoding, String standalone, int line, int col) throws AttoParseException
AbstractStandardXmlAttoHandler
Called when an XML Declaration is found.
handleXmlDeclaration
in class AbstractStandardXmlAttoHandler
version
- the version value specified (cannot be null).encoding
- the encoding value specified (can be null).standalone
- the standalone value specified (can be null).line
- the line in the document where this elements appears.col
- the column in the document where this element appears.
AttoParseException
public void handleDocType(String elementName, String publicId, String systemId, String internalSubset, int line, int col) throws AttoParseException
AbstractStandardXmlAttoHandler
Called when a DOCTYPE clause is found.
handleDocType
in class AbstractStandardXmlAttoHandler
elementName
- the root element name present in the DOCTYPE clause (e.g. "html").publicId
- the public ID specified, if present (might be null).systemId
- the system ID specified, if present (might be null).internalSubset
- the internal subset specified, if present (might be null).line
- the line in the document where this elements appears.col
- the column in the document where this element appears.
AttoParseException
public void handleXmlStandaloneElement(String elementName, Map<String,String> attributes, int line, int col) throws AttoParseException
AbstractStandardXmlAttoHandler
Called when a standalone element (a minimized tag) is found.
Note that the element attributes map can be null if no attributes are present.
handleXmlStandaloneElement
in class AbstractStandardXmlAttoHandler
elementName
- the element name (e.g. "<img src="logo.png">" -> "img").attributes
- the element attributes map, or null if no attributes are present.line
- the line in the document where this elements appears.col
- the column in the document where this element appears.
AttoParseException
public void handleXmlOpenElement(String elementName, Map<String,String> attributes, int line, int col) throws AttoParseException
AbstractStandardXmlAttoHandler
Called when an open element (an open tag) is found.
Note that the element attributes map can be null if no attributes are present.
handleXmlOpenElement
in class AbstractStandardXmlAttoHandler
elementName
- the element name (e.g. "<div class="content">" -> "div").attributes
- the element attributes map, or null if no attributes are present.line
- the line in the document where this elements appears.col
- the column in the document where this element appears.
AttoParseException
public void handleXmlCloseElement(String elementName, int line, int col) throws AttoParseException
AbstractStandardXmlAttoHandler
Called when a close element (a close tag) is found.
handleXmlCloseElement
in class AbstractStandardXmlAttoHandler
elementName
- the element name (e.g. "</div>" -> "div").line
- the line in the document where this elements appears.col
- the column in the document where this element appears.
AttoParseException
public void handleComment(char[] buffer, int offset, int len, int line, int col) throws AttoParseException
AbstractStandardXmlAttoHandler
Called when a comment is found.
This artifact is returned as a char[] instead of a String because its content can be large. In order to convert it into a String, just do new String(buffer, offset, len).
handleComment
in class AbstractStandardXmlAttoHandler
buffer
- the document buffer.offset
- the offset of the artifact in the document buffer.len
- the length (in chars) of the artifact.line
- the line in the document where this elements appears.col
- the column in the document where this element appears.
AttoParseException
public void handleCDATASection(char[] buffer, int offset, int len, int line, int col) throws AttoParseException
AbstractStandardXmlAttoHandler
Called when a CDATA section is found.
This artifact is returned as a char[] instead of a String because its content can be large. In order to convert it into a String, just do new String(buffer, offset, len).
handleCDATASection
in class AbstractStandardXmlAttoHandler
buffer
- the document buffer.offset
- the offset of the artifact in the document buffer.len
- the length (in chars) of the artifact.line
- the line in the document where this elements appears.col
- the column in the document where this element appears.
AttoParseException
public void handleText(char[] buffer, int offset, int len, int line, int col) throws AttoParseException
IAttoHandler
Called 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 IAttoHandler
handleText
in class AbstractAttoHandler
buffer
- 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 handleProcessingInstruction(String target, String content, int line, int col) throws AttoParseException
AbstractStandardXmlAttoHandler
Called when a Processing Instruction is found.
handleProcessingInstruction
in class AbstractStandardXmlAttoHandler
target
- the target specified in the processing instruction.content
- the content of the processing instruction, if specified (might be null).line
- the line in the document where this elements appears.col
- the column in the document where this element appears.
AttoParseException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |