org.attoparser.markup.trace
Class TextTracingStandardMarkupAttoHandler

Object
  extended by org.attoparser.AbstractAttoHandler
      extended by org.attoparser.markup.AbstractBasicMarkupAttoHandler
          extended by org.attoparser.markup.AbstractDetailedMarkupAttoHandler
              extended by org.attoparser.markup.AbstractStandardMarkupAttoHandler
                  extended by org.attoparser.markup.trace.TextTracingStandardMarkupAttoHandler
All Implemented Interfaces:
IAttoHandler, ITimedDocumentHandling, IAttributeSequenceHandling, IBasicDocTypeHandling, IBasicElementHandling, ICDATASectionHandling, ICommentHandling, IDetailedDocTypeHandling, IDetailedElementHandling, IProcessingInstructionHandling, IXmlDeclarationHandling

public final class TextTracingStandardMarkupAttoHandler
extends AbstractStandardMarkupAttoHandler

Since:
1.0
Author:
Daniel Fernández

Constructor Summary
TextTracingStandardMarkupAttoHandler(Writer writer)
           
TextTracingStandardMarkupAttoHandler(Writer writer, MarkupParsingConfiguration markupParsingConfiguration)
           
 
Method Summary
 void handleAutoClosedElement(String elementName, int line, int col)
           Called when a close element (a close tag) is needed in order to correctly balance the markup.
 void handleCDATASection(char[] buffer, int offset, int len, int line, int col)
           Called when a CDATA section is found.
 void handleCloseElement(String elementName, int line, int col)
           Called when a close element (a close tag) 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 handleDocumentEnd(long endTimeNanos, long totalTimeNanos, int line, int col, MarkupParsingConfiguration markupParsingConfiguration)
           Called when document parsing ends.
 void handleDocumentStart(long startTimeNanos, int line, int col, MarkupParsingConfiguration markupParsingConfiguration)
           Called when document parsing starts.
 void handleOpenElement(String elementName, Map<String,String> attributes, int line, int col)
           Called when an open element (an open tag) is found.
 void handleProcessingInstruction(String target, String content, int line, int col)
           Called when a Processing Instruction is found.
 void handleStandaloneElement(String elementName, Map<String,String> attributes, int line, int col)
           Called when a standalone element (a minimized tag) is found.
 void handleText(char[] buffer, int offset, int len, int line, int col)
           Called when a text artifact is found.
 void handleUnmatchedClosedElement(String elementName, int line, int col)
           Called when a close element (a close tag) appears without a corresponding open element.
 void handleXmlDeclaration(String version, String encoding, String standalone, int line, int col)
           Called when an XML Declaration is found.
 
Methods inherited from class org.attoparser.markup.AbstractStandardMarkupAttoHandler
handleAttribute, handleAutoCloseElementEnd, handleAutoCloseElementStart, handleCDATASection, handleCloseElementEnd, handleCloseElementStart, handleComment, handleDocType, handleInnerWhiteSpace, handleOpenElementEnd, handleOpenElementStart, handleProcessingInstruction, handleStandaloneElementEnd, handleStandaloneElementStart, handleUnmatchedCloseElementEnd, handleUnmatchedCloseElementStart, handleXmlDeclarationDetail
 
Methods inherited from class org.attoparser.markup.AbstractDetailedMarkupAttoHandler
handleCloseElement, handleDocType, handleDocumentEnd, handleDocumentStart, handleOpenElement, handleStandaloneElement, 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

TextTracingStandardMarkupAttoHandler

public TextTracingStandardMarkupAttoHandler(Writer writer)

TextTracingStandardMarkupAttoHandler

public TextTracingStandardMarkupAttoHandler(Writer writer,
                                            MarkupParsingConfiguration markupParsingConfiguration)
Method Detail

handleDocumentStart

public void handleDocumentStart(long startTimeNanos,
                                int line,
                                int col,
                                MarkupParsingConfiguration markupParsingConfiguration)
                         throws AttoParseException
Description copied from class: AbstractDetailedMarkupAttoHandler

Called when document parsing starts.

Overrides:
handleDocumentStart in class AbstractDetailedMarkupAttoHandler
Parameters:
startTimeNanos - the starting time, in nanoseconds.
markupParsingConfiguration - the document restrictions being applied.
Throws:
AttoParseException

handleDocumentEnd

public void handleDocumentEnd(long endTimeNanos,
                              long totalTimeNanos,
                              int line,
                              int col,
                              MarkupParsingConfiguration markupParsingConfiguration)
                       throws AttoParseException
Description copied from class: AbstractDetailedMarkupAttoHandler

Called when document parsing ends.

Overrides:
handleDocumentEnd in class AbstractDetailedMarkupAttoHandler
Parameters:
endTimeNanos - the parsing end time, in nanoseconds.
totalTimeNanos - the difference between parsing start and end times.
markupParsingConfiguration - the document restrictions being applied.
Throws:
AttoParseException

handleStandaloneElement

public void handleStandaloneElement(String elementName,
                                    Map<String,String> attributes,
                                    int line,
                                    int col)
                             throws AttoParseException
Description copied from class: AbstractStandardMarkupAttoHandler

Called when a standalone element (a minimized tag) is found.

Note that the element attributes map can be null if no attributes are present.

Overrides:
handleStandaloneElement in class AbstractStandardMarkupAttoHandler
Parameters:
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.
Throws:
AttoParseException

handleOpenElement

public void handleOpenElement(String elementName,
                              Map<String,String> attributes,
                              int line,
                              int col)
                       throws AttoParseException
Description copied from class: AbstractStandardMarkupAttoHandler

Called when an open element (an open tag) is found.

Note that the element attributes map can be null if no attributes are present.

Overrides:
handleOpenElement in class AbstractStandardMarkupAttoHandler
Parameters:
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.
Throws:
AttoParseException

handleCloseElement

public void handleCloseElement(String elementName,
                               int line,
                               int col)
                        throws AttoParseException
Description copied from class: AbstractStandardMarkupAttoHandler

Called when a close element (a close tag) is found.

Overrides:
handleCloseElement in class AbstractStandardMarkupAttoHandler
Parameters:
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.
Throws:
AttoParseException

handleAutoClosedElement

public void handleAutoClosedElement(String elementName,
                                    int line,
                                    int col)
                             throws AttoParseException
Description copied from class: AbstractStandardMarkupAttoHandler

Called when a close element (a close tag) is needed in order to correctly balance the markup. This is called autoclosing.

Implementors might choose to ignore these autoclosing events.

Overrides:
handleAutoClosedElement in class AbstractStandardMarkupAttoHandler
Parameters:
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.
Throws:
AttoParseException

handleUnmatchedClosedElement

public void handleUnmatchedClosedElement(String elementName,
                                         int line,
                                         int col)
                                  throws AttoParseException
Description copied from class: AbstractStandardMarkupAttoHandler

Called when a close element (a close tag) appears without a corresponding open element.

Implementors might choose to ignore these events.

Overrides:
handleUnmatchedClosedElement in class AbstractStandardMarkupAttoHandler
Parameters:
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.
Throws:
AttoParseException

handleDocType

public void handleDocType(String elementName,
                          String publicId,
                          String systemId,
                          String internalSubset,
                          int line,
                          int col)
                   throws AttoParseException
Description copied from class: AbstractStandardMarkupAttoHandler

Called when a DOCTYPE clause is found.

Overrides:
handleDocType in class AbstractStandardMarkupAttoHandler
Parameters:
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.
Throws:
AttoParseException

handleComment

public void handleComment(char[] buffer,
                          int offset,
                          int len,
                          int line,
                          int col)
                   throws AttoParseException
Description copied from class: AbstractStandardMarkupAttoHandler

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).

Overrides:
handleComment in class AbstractStandardMarkupAttoHandler
Parameters:
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.
Throws:
AttoParseException

handleCDATASection

public void handleCDATASection(char[] buffer,
                               int offset,
                               int len,
                               int line,
                               int col)
                        throws AttoParseException
Description copied from class: AbstractStandardMarkupAttoHandler

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).

Overrides:
handleCDATASection in class AbstractStandardMarkupAttoHandler
Parameters:
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.
Throws:
AttoParseException

handleText

public void handleText(char[] buffer,
                       int offset,
                       int len,
                       int line,
                       int col)
                throws AttoParseException
Description copied from interface: 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.

Specified by:
handleText in interface IAttoHandler
Overrides:
handleText in class AbstractAttoHandler
Parameters:
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.
Throws:
AttoParseException

handleXmlDeclaration

public void handleXmlDeclaration(String version,
                                 String encoding,
                                 String standalone,
                                 int line,
                                 int col)
                          throws AttoParseException
Description copied from class: AbstractStandardMarkupAttoHandler

Called when an XML Declaration is found.

Overrides:
handleXmlDeclaration in class AbstractStandardMarkupAttoHandler
Parameters:
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.
Throws:
AttoParseException

handleProcessingInstruction

public void handleProcessingInstruction(String target,
                                        String content,
                                        int line,
                                        int col)
                                 throws AttoParseException
Description copied from class: AbstractStandardMarkupAttoHandler

Called when a Processing Instruction is found.

Overrides:
handleProcessingInstruction in class AbstractStandardMarkupAttoHandler
Parameters:
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.
Throws:
AttoParseException


Copyright © 2013 The ATTOPARSER team. All Rights Reserved.