IAttributeSequenceHandler
, ICDATASectionHandler
, ICommentHandler
, IDocTypeHandler
, IDocumentHandler
, IElementHandler
, IMarkupHandler
, IProcessingInstructionHandler
, ITextHandler
, IXMLDeclarationHandler
public final class BlockSelectorMarkupHandler extends AbstractMarkupHandler
Implementation of IMarkupHandler
able to apply block selection based on a set
of specified markup selectors (see org.attoparser.select
).
Block selection means that once an element is selected by any of the specified selectors, the entire subtree of that element is also considered selected.
This markup handler will apply the specified markup selectors and divide parsing events
between two (possibly different) chained markup handlers implementing IMarkupHandler
:
the selectedHandler and the nonSelectedHandler. Also, document start/end events will be
sent to the selectedHandler unless specified otherwise by means of the
setDocumentStartEndHandler(org.attoparser.IMarkupHandler)
method.
Additionally, this handler will update the ParseSelection
object currently in use
by the handler chain (which has been set to handlers by means of the
IMarkupHandler.setParseSelection(ParseSelection)
method). For every event fired
on the delegated handlers, the parse selection object will contain up-to-date information about the selectors
(at every active selection level) that are currently matching the delegated events.
Also note that this filtering will be done in the most memory-efficient way, without the need to create any large extra String or char[] objects apart from a minimal element buffer object which will be reused throughout all the parsing process. This makes the execution of this handler extremely fast and integrated with the parsing process itself.
In order to see how this handler works we can see some examples. For instance, given the following markup:
<!DOCTYPE html>
<html>
<body>
<h1>AttoParser</h1>
<div class="content">
AttoParser is able to select <strong>just a fragment of markup</strong>.
</div>
</body>
</html>
...and a BlockSelectorMarkupHandler
initialized with:
OutputMarkupHandler
object as selectedHandler.DiscardMarkupHandler
object as nonSelectedHandler. This
is the default non-selected handler used when none is specified.Using selector "div.content", we would get:
<div class="content">
AttoParser is able to select <strong>just a fragment of markup</strong>.
</div>
If we had two selectors, "h1" and "div//text()", we would get:
<h1>AttoParser</h1>
AttoParser is able to select just a fragment of markup.
Have a look at the package info for org.attoparser.select
for a complete explanation on
markup selector syntax.
Note that, as with most handlers, this class is not thread-safe. Also, instances of this class should not be reused across parsing operations.
Constructor | Description |
---|---|
BlockSelectorMarkupHandler(IMarkupHandler selectedHandler,
String selector) |
Create a new instance of this handler, specifying the selected
handler and the selector to be used.
|
BlockSelectorMarkupHandler(IMarkupHandler selectedHandler,
String[] selectors) |
Create a new instance of this handler, specifying the selected
handler and the selectors to be used.
|
BlockSelectorMarkupHandler(IMarkupHandler selectedHandler,
String[] selectors,
IMarkupSelectorReferenceResolver referenceResolver) |
Create a new instance of this handler, specifying the selected
handler, as well as a markup selector reference resolver and the selectors to be used.
|
BlockSelectorMarkupHandler(IMarkupHandler selectedHandler,
String selector,
IMarkupSelectorReferenceResolver referenceResolver) |
Create a new instance of this handler, specifying the selected
handler, as well as a markup selector reference resolver and the selector to be used.
|
BlockSelectorMarkupHandler(IMarkupHandler selectedHandler,
IMarkupHandler nonSelectedHandler,
String selector) |
Create a new instance of this handler, specifying both the selected and non-selected
handlers, and the selector to be used.
|
BlockSelectorMarkupHandler(IMarkupHandler selectedHandler,
IMarkupHandler nonSelectedHandler,
String[] selectors) |
Create a new instance of this handler, specifying both the selected and non-selected
handlers, and the selectors to be used.
|
BlockSelectorMarkupHandler(IMarkupHandler selectedHandler,
IMarkupHandler nonSelectedHandler,
String[] selectors,
IMarkupSelectorReferenceResolver referenceResolver) |
Create a new instance of this handler, specifying both the selected and non-selected
handlers, as well as a markup selector reference resolver and the selectors to be used.
|
BlockSelectorMarkupHandler(IMarkupHandler selectedHandler,
IMarkupHandler nonSelectedHandler,
String selector,
IMarkupSelectorReferenceResolver referenceResolver) |
Create a new instance of this handler, specifying both the selected and non-selected
handlers, as well as a markup selector reference resolver and the selector to be used.
|
Modifier and Type | Method | Description |
---|---|---|
void |
handleAttribute(char[] buffer,
int nameOffset,
int nameLen,
int nameLine,
int nameCol,
int operatorOffset,
int operatorLen,
int operatorLine,
int operatorCol,
int valueContentOffset,
int valueContentLen,
int valueOuterOffset,
int valueOuterLen,
int valueLine,
int valueCol) |
Called when an attribute is found.
|
void |
handleAutoCloseElementEnd(char[] buffer,
int nameOffset,
int nameLen,
int line,
int col) |
Called for signaling the end of an auto-close element, created for
balancing an unclosed tag.
|
void |
handleAutoCloseElementStart(char[] buffer,
int nameOffset,
int nameLen,
int line,
int col) |
Called for signaling the start of an auto-close element (a synthetic close tag),
created for balancing an unclosed tag.
|
void |
handleAutoOpenElementEnd(char[] buffer,
int nameOffset,
int nameLen,
int line,
int col) |
Called for signaling the end of an auto-open element (a synthetic open tag),
created for adapting parsed markup to a specification such as, for example, HTML5.
|
void |
handleAutoOpenElementStart(char[] buffer,
int nameOffset,
int nameLen,
int line,
int col) |
Called for signaling the start of an auto-open element (a synthetic open tag),
created for adapting parsed markup to a specification such as, for example, HTML5.
|
void |
handleCDATASection(char[] buffer,
int contentOffset,
int contentLen,
int outerOffset,
int outerLen,
int line,
int col) |
Called when a CDATA section is found.
|
void |
handleCloseElementEnd(char[] buffer,
int nameOffset,
int nameLen,
int line,
int col) |
Called when the end of a close element (a close tag) is found.
|
void |
handleCloseElementStart(char[] buffer,
int nameOffset,
int nameLen,
int line,
int col) |
Called when the start of a close element (a close tag) is found.
|
void |
handleComment(char[] buffer,
int contentOffset,
int contentLen,
int outerOffset,
int outerLen,
int line,
int col) |
Called when a comment is found.
|
void |
handleDocType(char[] buffer,
int keywordOffset,
int keywordLen,
int keywordLine,
int keywordCol,
int elementNameOffset,
int elementNameLen,
int elementNameLine,
int elementNameCol,
int typeOffset,
int typeLen,
int typeLine,
int typeCol,
int publicIdOffset,
int publicIdLen,
int publicIdLine,
int publicIdCol,
int systemIdOffset,
int systemIdLen,
int systemIdLine,
int systemIdCol,
int internalSubsetOffset,
int internalSubsetLen,
int internalSubsetLine,
int internalSubsetCol,
int outerOffset,
int outerLen,
int outerLine,
int outerCol) |
Called when a DOCTYPE clause is found.
|
void |
handleDocumentEnd(long endTimeNanos,
long totalTimeNanos,
int line,
int col) |
Called at the end of document parsing.
|
void |
handleDocumentStart(long startTimeNanos,
int line,
int col) |
Called at the beginning of document parsing.
|
void |
handleInnerWhiteSpace(char[] buffer,
int offset,
int len,
int line,
int col) |
Called when an amount of white space is found inside an element.
|
void |
handleOpenElementEnd(char[] buffer,
int nameOffset,
int nameLen,
int line,
int col) |
Called when the end of an open element (an open tag) is found.
|
void |
handleOpenElementStart(char[] buffer,
int nameOffset,
int nameLen,
int line,
int col) |
Called when an open element (an open tag) is found.
|
void |
handleProcessingInstruction(char[] buffer,
int targetOffset,
int targetLen,
int targetLine,
int targetCol,
int contentOffset,
int contentLen,
int contentLine,
int contentCol,
int outerOffset,
int outerLen,
int line,
int col) |
Called when a Processing Instruction is found.
|
void |
handleStandaloneElementEnd(char[] buffer,
int nameOffset,
int nameLen,
boolean minimized,
int line,
int col) |
Called when the end of a standalone element (an element with no closing tag) is found
|
void |
handleStandaloneElementStart(char[] buffer,
int nameOffset,
int nameLen,
boolean minimized,
int line,
int col) |
Called when a standalone element (an element with no closing tag) is found.
|
void |
handleText(char[] buffer,
int offset,
int len,
int line,
int col) |
Called when a text artifact is found.
|
void |
handleUnmatchedCloseElementEnd(char[] buffer,
int nameOffset,
int nameLen,
int line,
int col) |
Called when the end of an unmatched close element (close tag) is found.
|
void |
handleUnmatchedCloseElementStart(char[] buffer,
int nameOffset,
int nameLen,
int line,
int col) |
Called when the start of an unmatched close element (close tag) is found.
|
void |
handleXmlDeclaration(char[] buffer,
int keywordOffset,
int keywordLen,
int keywordLine,
int keywordCol,
int versionOffset,
int versionLen,
int versionLine,
int versionCol,
int encodingOffset,
int encodingLen,
int encodingLine,
int encodingCol,
int standaloneOffset,
int standaloneLen,
int standaloneLine,
int standaloneCol,
int outerOffset,
int outerLen,
int line,
int col) |
Called when a XML Declaration is found.
|
void |
setDocumentStartEndHandler(IMarkupHandler documentStartEndHandler) |
Sets the
IMarkupHandler instance to which the document start and
document end events should be delegated. |
void |
setParseConfiguration(ParseConfiguration parseConfiguration) |
Sets the
ParseConfiguration object that will be used during the parsing
operation. |
void |
setParseSelection(ParseSelection selection) |
Sets the
ParseSelection object that represents the different levels of
selectors (if any) that are currently active for the fired events. |
void |
setParseStatus(ParseStatus status) |
Sets the
ParseStatus object that will be used during the parsing operation. |
public BlockSelectorMarkupHandler(IMarkupHandler selectedHandler, String selector)
Create a new instance of this handler, specifying the selected handler and the selector to be used.
Given no non-selected handler is specified, an instance of
DiscardMarkupHandler
is used. So all non-selected events will be just
discarded.
selectedHandler
- the handler to which selected events will be delegated.selector
- the selector to be used. Cannot be null.public BlockSelectorMarkupHandler(IMarkupHandler selectedHandler, String selector, IMarkupSelectorReferenceResolver referenceResolver)
Create a new instance of this handler, specifying the selected handler, as well as a markup selector reference resolver and the selector to be used.
Given no non-selected handler is specified, an instance of
DiscardMarkupHandler
is used. So all non-selected events will be just
discarded.
selectedHandler
- the handler to which selected events will be delegated.selector
- the selector to be used. Cannot be null.referenceResolver
- the reference resolver to be used. Can be null if none is required.public BlockSelectorMarkupHandler(IMarkupHandler selectedHandler, IMarkupHandler nonSelectedHandler, String selector)
Create a new instance of this handler, specifying both the selected and non-selected handlers, and the selector to be used.
selectedHandler
- the handler to which selected events will be delegated.nonSelectedHandler
- the handler to which non-selected events will be delegated.selector
- the selector to be used. Cannot be null.public BlockSelectorMarkupHandler(IMarkupHandler selectedHandler, IMarkupHandler nonSelectedHandler, String selector, IMarkupSelectorReferenceResolver referenceResolver)
Create a new instance of this handler, specifying both the selected and non-selected handlers, as well as a markup selector reference resolver and the selector to be used.
selectedHandler
- the handler to which selected events will be delegated.nonSelectedHandler
- the handler to which non-selected events will be delegated.selector
- the selector to be used. Cannot be null.referenceResolver
- the reference resolver to be used. Can be null if none is required.public BlockSelectorMarkupHandler(IMarkupHandler selectedHandler, String[] selectors)
Create a new instance of this handler, specifying the selected handler and the selectors to be used.
Given no non-selected handler is specified, an instance of
DiscardMarkupHandler
is used. So all non-selected events will be just
discarded.
selectedHandler
- the handler to which selected events will be delegated.selectors
- the selectors to be used. Cannot be neither null nor empty.public BlockSelectorMarkupHandler(IMarkupHandler selectedHandler, String[] selectors, IMarkupSelectorReferenceResolver referenceResolver)
Create a new instance of this handler, specifying the selected handler, as well as a markup selector reference resolver and the selectors to be used.
Given no non-selected handler is specified, an instance of
DiscardMarkupHandler
is used. So all non-selected events will be just
discarded.
selectedHandler
- the handler to which selected events will be delegated.selectors
- the selectors to be used. Cannot be neither null nor empty.referenceResolver
- the reference resolver to be used. Can be null if none is required.public BlockSelectorMarkupHandler(IMarkupHandler selectedHandler, IMarkupHandler nonSelectedHandler, String[] selectors)
Create a new instance of this handler, specifying both the selected and non-selected handlers, and the selectors to be used.
selectedHandler
- the handler to which selected events will be delegated.nonSelectedHandler
- the handler to which non-selected events will be delegated.selectors
- the selectors to be used. Cannot be neither null nor empty.public BlockSelectorMarkupHandler(IMarkupHandler selectedHandler, IMarkupHandler nonSelectedHandler, String[] selectors, IMarkupSelectorReferenceResolver referenceResolver)
Create a new instance of this handler, specifying both the selected and non-selected handlers, as well as a markup selector reference resolver and the selectors to be used.
selectedHandler
- the handler to which selected events will be delegated.nonSelectedHandler
- the handler to which non-selected events will be delegated.selectors
- the selectors to be used. Cannot be neither null nor empty.referenceResolver
- the reference resolver to be used. Can be null if none is required.public void setDocumentStartEndHandler(IMarkupHandler documentStartEndHandler)
Sets the IMarkupHandler
instance to which the document start and
document end events should be delegated.
This is specified separately in order to avoid undesired event duplicities. By default, the selected handler specified during construction will be the one receiving these events.
If sending these events to both selected and non-selected handlers is required, developers can make use of
DuplicateMarkupHandler
.
documentStartEndHandler
- the handler these events will be delegated to.public void setParseConfiguration(ParseConfiguration parseConfiguration)
IMarkupHandler
Sets the ParseConfiguration
object that will be used during the parsing
operation. This object will normally have been specified to the parser object during its instantiation
or initialization.
This method is always called by the parser before calling any other event handling method.
Note that this method can be safely ignored by most implementations, as there are very few scenarios in which this kind of interaction would be consisdered relevant.
setParseConfiguration
in interface IMarkupHandler
setParseConfiguration
in class AbstractMarkupHandler
parseConfiguration
- the configuration object.public void setParseStatus(ParseStatus status)
IMarkupHandler
Sets the ParseStatus
object that will be used during the parsing operation. This
object can be used for instructing the parser about specific low-level conditions arisen during event
handling.
This method is always called by the parser before calling any other event handling method.
Note that this method can be safely ignored by most implementations, as there are very few and very specific scenarios in which this kind of interaction with the parser would be needed. It is therefore mainly for internal use.
setParseStatus
in interface IMarkupHandler
setParseStatus
in class AbstractMarkupHandler
status
- the status object.public void setParseSelection(ParseSelection selection)
IMarkupHandler
Sets the ParseSelection
object that represents the different levels of
selectors (if any) that are currently active for the fired events.
This method is always called by the parser before calling any other event handling method.
Note that this method can be safely ignored by most implementations, as there are very few scenarios in which this kind of interaction would be consisdered relevant.
setParseSelection
in interface IMarkupHandler
setParseSelection
in class AbstractMarkupHandler
selection
- the selection object.public void handleDocumentStart(long startTimeNanos, int line, int col) throws ParseException
IDocumentHandler
Called at the beginning of document parsing.
handleDocumentStart
in interface IDocumentHandler
handleDocumentStart
in class AbstractMarkupHandler
startTimeNanos
- 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).ParseException
- if any exceptions occur during handling.public void handleDocumentEnd(long endTimeNanos, long totalTimeNanos, int line, int col) throws ParseException
IDocumentHandler
Called at the end of document parsing.
handleDocumentEnd
in interface IDocumentHandler
handleDocumentEnd
in class AbstractMarkupHandler
endTimeNanos
- 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).ParseException
- if any exceptions occur during handling.public void handleXmlDeclaration(char[] buffer, int keywordOffset, int keywordLen, int keywordLine, int keywordCol, int versionOffset, int versionLen, int versionLine, int versionCol, int encodingOffset, int encodingLen, int encodingLine, int encodingCol, int standaloneOffset, int standaloneLen, int standaloneLine, int standaloneCol, int outerOffset, int outerLen, int line, int col) throws ParseException
IXMLDeclarationHandler
Called when a XML Declaration is found.
Five [offset, len] pairs are provided for five partitions (outer, keyword, version, encoding and standalone):
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
| [K] [V] [ENC] [S] |
[OUTER------------------------------------------------]
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.
handleXmlDeclaration
in interface IXMLDeclarationHandler
handleXmlDeclaration
in class AbstractMarkupHandler
buffer
- the document buffer (not copied)keywordOffset
- offset for the keyword partition.keywordLen
- length of the keyword partition.keywordLine
- the line in the original document where the keyword partition starts.keywordCol
- the column in the original document where the keyword partition starts.versionOffset
- offset for the version partition.versionLen
- length of the version partition.versionLine
- the line in the original document where the version partition starts.versionCol
- the column in the original document where the version partition starts.encodingOffset
- offset for the encoding partition.encodingLen
- length of the encoding partition.encodingLine
- the line in the original document where the encoding partition starts.encodingCol
- the column in the original document where the encoding partition starts.standaloneOffset
- offset for the standalone partition.standaloneLen
- length of the standalone partition.standaloneLine
- the line in the original document where the standalone partition starts.standaloneCol
- the column in the original document where the standalone partition starts.outerOffset
- offset for the outer partition.outerLen
- length of the outer partition.line
- the line in the original document where this artifact starts.col
- the column in the original document where this artifact starts.ParseException
- if any exceptions occur during handling.public void handleDocType(char[] buffer, int keywordOffset, int keywordLen, int keywordLine, int keywordCol, int elementNameOffset, int elementNameLen, int elementNameLine, int elementNameCol, int typeOffset, int typeLen, int typeLine, int typeCol, int publicIdOffset, int publicIdLen, int publicIdLine, int publicIdCol, int systemIdOffset, int systemIdLen, int systemIdLine, int systemIdCol, int internalSubsetOffset, int internalSubsetLen, int internalSubsetLine, int internalSubsetCol, int outerOffset, int outerLen, int outerLine, int outerCol) throws ParseException
IDocTypeHandler
Called when a DOCTYPE clause is found.
This method reports the DOCTYPE clause splitting it into its different parts.
Seven [offset, len] pairs are provided for seven partitions (outer, keyword, elementName, type, publicId, systemId and internalSubset) of the DOCTYPE clause:
<!DOCTYPE html PUBLIC ".........." ".........." [................]>
| [KEYWO] [EN] [TYPE] [PUBLICID] [SYSTEMID] [INTERNALSUBSET] |
[OUTER------------------------------------------------------------]
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.
handleDocType
in interface IDocTypeHandler
handleDocType
in class AbstractMarkupHandler
buffer
- the document buffer (not copied)keywordOffset
- offset for the keyword partition.keywordLen
- length of the keyword partition.keywordLine
- the line in the original document where the keyword partition starts.keywordCol
- the column in the original document where the keyword partition starts.elementNameOffset
- offset for the elementName partition.elementNameLen
- length of the elementName partition.elementNameLine
- the line in the original document where the elementName partition starts.elementNameCol
- the column in the original document where the elementName partition starts.typeOffset
- offset for the type partition.typeLen
- length of the type partition.typeLine
- the line in the original document where the type partition starts.typeCol
- the column in the original document where the type partition starts.publicIdOffset
- offset for the publicId partition.publicIdLen
- length of the publicId partition.publicIdLine
- the line in the original document where the publicId partition starts.publicIdCol
- the column in the original document where the publicId partition starts.systemIdOffset
- offset for the systemId partition.systemIdLen
- length of the systemId partition.systemIdLine
- the line in the original document where the systemId partition starts.systemIdCol
- the column in the original document where the systemId partition starts.internalSubsetOffset
- offset for the internalSubsetId partition.internalSubsetLen
- length of the internalSubsetId partition.internalSubsetLine
- the line in the original document where the internalSubsetId partition starts.internalSubsetCol
- the column in the original document where the internalSubsetId partition starts.outerOffset
- offset for the outer partition.outerLen
- length of the outer partition.outerLine
- the line in the original document where this artifact starts.outerCol
- the column in the original document where this artifact starts.ParseException
- if any exceptions occur during handling.public void handleCDATASection(char[] buffer, int contentOffset, int contentLen, int outerOffset, int outerLen, int line, int col) throws ParseException
ICDATASectionHandler
Called when a CDATA section is found.
Two [offset, len] pairs are provided for two partitions (outer and content):
<![CDATA[ this is a CDATA section ]]>
| [CONTENT----------------] |
[OUTER------------------------------]
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.
handleCDATASection
in interface ICDATASectionHandler
handleCDATASection
in class AbstractMarkupHandler
buffer
- the document buffer (not copied)contentOffset
- offset for the content partition.contentLen
- length of the content partition.outerOffset
- offset for the outer partition.outerLen
- length of the outer partition.line
- the line in the original document where this artifact starts.col
- the column in the original document where this artifact starts.ParseException
- if any exceptions occur during handling.public void handleText(char[] buffer, int offset, int len, int line, int col) throws ParseException
ITextHandler
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 ITextHandler
handleText
in class AbstractMarkupHandler
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.ParseException
- if any exceptions occur during handling.public void handleComment(char[] buffer, int contentOffset, int contentLen, int outerOffset, int outerLen, int line, int col) throws ParseException
ICommentHandler
Called when a comment is found.
Two [offset, len] pairs are provided for two partitions (outer and content):
<!-- this is a comment -->
| [CONTENT----------] |
[OUTER-------------------]
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.
handleComment
in interface ICommentHandler
handleComment
in class AbstractMarkupHandler
buffer
- the document buffer (not copied)contentOffset
- offset for the content partition.contentLen
- length of the content partition.outerOffset
- offset for the outer partition.outerLen
- length of the outer partition.line
- the line in the original document where this artifact starts.col
- the column in the original document where this artifact starts.ParseException
- if any exceptions occur during handling.public void handleAttribute(char[] buffer, int nameOffset, int nameLen, int nameLine, int nameCol, int operatorOffset, int operatorLen, int operatorLine, int operatorCol, int valueContentOffset, int valueContentLen, int valueOuterOffset, int valueOuterLen, int valueLine, int valueCol) throws ParseException
IAttributeSequenceHandler
Called when an attribute is found.
Three [offset, len] pairs are provided for three partitions (name, operator, valueContent and valueOuter):
class="basic_column"
[NAM]* [VALUECONTE]| (*) = [OPERATOR]
| [VALUEOUTER--]
[OUTER-------------]
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.
handleAttribute
in interface IAttributeSequenceHandler
handleAttribute
in class AbstractMarkupHandler
buffer
- the document buffer (not copied)nameOffset
- offset for the name partition.nameLen
- length of the name partition.nameLine
- the line in the original document where the name partition starts.nameCol
- the column in the original document where the name partition starts.operatorOffset
- offset for the operator partition.operatorLen
- length of the operator partition.operatorLine
- the line in the original document where the operator partition starts.operatorCol
- the column in the original document where the operator partition starts.valueContentOffset
- offset for the valueContent partition.valueContentLen
- length of the valueContent partition.valueOuterOffset
- offset for the valueOuter partition.valueOuterLen
- length of the valueOuter partition.valueLine
- the line in the original document where the value (outer) partition starts.valueCol
- the column in the original document where the value (outer) partition starts.ParseException
- if any exceptions occur during handling.public void handleStandaloneElementStart(char[] buffer, int nameOffset, int nameLen, boolean minimized, int line, int col) throws ParseException
IElementHandler
Called when a standalone element (an element with no closing tag) is found. The name of the element is also reported.
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.
handleStandaloneElementStart
in interface IElementHandler
handleStandaloneElementStart
in class AbstractMarkupHandler
buffer
- the document buffer (not copied)nameOffset
- the offset (position in buffer) where the element name appears.nameLen
- the length (in chars) of the element name.minimized
- whether the element has been found minimized (<element/>)in code or not.line
- the line in the original document where this artifact starts.col
- the column in the original document where this artifact starts.ParseException
- if any exceptions occur during handling.public void handleStandaloneElementEnd(char[] buffer, int nameOffset, int nameLen, boolean minimized, int line, int col) throws ParseException
IElementHandler
Called when the end of a standalone element (an element with no closing tag) is found
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.
handleStandaloneElementEnd
in interface IElementHandler
handleStandaloneElementEnd
in class AbstractMarkupHandler
buffer
- the document buffer (not copied)nameOffset
- the offset (position in buffer) where the element name appears.nameLen
- the length (in chars) of the element name.minimized
- whether the element has been found minimized (<element/>)in code or not.line
- the line in the original document where the element ending structure appears.col
- the column in the original document where the element ending structure appears.ParseException
- if any exceptions occur during handling.public void handleOpenElementStart(char[] buffer, int nameOffset, int nameLen, int line, int col) throws ParseException
IElementHandler
Called when an open element (an open tag) is found. The name of the element is also reported.
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.
handleOpenElementStart
in interface IElementHandler
handleOpenElementStart
in class AbstractMarkupHandler
buffer
- the document buffer (not copied)nameOffset
- the offset (position in buffer) where the element name appears.nameLen
- the length (in chars) of the element name.line
- the line in the original document where this artifact starts.col
- the column in the original document where this artifact starts.ParseException
- if any exceptions occur during handling.public void handleOpenElementEnd(char[] buffer, int nameOffset, int nameLen, int line, int col) throws ParseException
IElementHandler
Called when the end of an open element (an open tag) is found.
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.
handleOpenElementEnd
in interface IElementHandler
handleOpenElementEnd
in class AbstractMarkupHandler
buffer
- the document buffer (not copied)nameOffset
- the offset (position in buffer) where the element name appears.nameLen
- the length (in chars) of the element name.line
- the line in the original document where the element ending structure appears.col
- the column in the original document where the element ending structure appears.ParseException
- if any exceptions occur during handling.public void handleAutoOpenElementStart(char[] buffer, int nameOffset, int nameLen, int line, int col) throws ParseException
IElementHandler
Called for signaling the start of an auto-open element (a synthetic open tag), created for adapting parsed markup to a specification such as, for example, HTML5. The name of the element is also reported.
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.
handleAutoOpenElementStart
in interface IElementHandler
handleAutoOpenElementStart
in class AbstractMarkupHandler
buffer
- the document buffer (not copied)nameOffset
- the offset (position in buffer) where the element name appears.nameLen
- the length (in chars) of the element name.line
- the line in the original document where this artifact starts.col
- the column in the original document where this artifact starts.ParseException
- if any exceptions occur during handling.public void handleAutoOpenElementEnd(char[] buffer, int nameOffset, int nameLen, int line, int col) throws ParseException
IElementHandler
Called for signaling the end of an auto-open element (a synthetic open tag), created for adapting parsed markup to a specification such as, for example, HTML5. The name of the element is also reported.
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.
handleAutoOpenElementEnd
in interface IElementHandler
handleAutoOpenElementEnd
in class AbstractMarkupHandler
buffer
- the document buffer (not copied)nameOffset
- the offset (position in buffer) where the element name appears.nameLen
- the length (in chars) of the element name.line
- the line in the original document where the element ending structure appears.col
- the column in the original document where the element ending structure appears.ParseException
- if any exceptions occur during handling.public void handleCloseElementStart(char[] buffer, int nameOffset, int nameLen, int line, int col) throws ParseException
IElementHandler
Called when the start of a close element (a close tag) is found. The name of the element is also reported.
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.
handleCloseElementStart
in interface IElementHandler
handleCloseElementStart
in class AbstractMarkupHandler
buffer
- the document buffer (not copied)nameOffset
- the offset (position in buffer) where the element name appears.nameLen
- the length (in chars) of the element name.line
- the line in the original document where this artifact starts.col
- the column in the original document where this artifact starts.ParseException
- if any exceptions occur during handling.public void handleCloseElementEnd(char[] buffer, int nameOffset, int nameLen, int line, int col) throws ParseException
IElementHandler
Called when the end of a close element (a close tag) is found.
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.
handleCloseElementEnd
in interface IElementHandler
handleCloseElementEnd
in class AbstractMarkupHandler
buffer
- the document buffer (not copied)nameOffset
- the offset (position in buffer) where the element name appears.nameLen
- the length (in chars) of the element name.line
- the line in the original document where the element ending structure appears.col
- the column in the original document where the element ending structure appears.ParseException
- if any exceptions occur during handling.public void handleAutoCloseElementStart(char[] buffer, int nameOffset, int nameLen, int line, int col) throws ParseException
IElementHandler
Called for signaling the start of an auto-close element (a synthetic close tag), created for balancing an unclosed tag. The name of the element is also reported.
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.
handleAutoCloseElementStart
in interface IElementHandler
handleAutoCloseElementStart
in class AbstractMarkupHandler
buffer
- the document buffer (not copied)nameOffset
- the offset (position in buffer) where the element name appears.nameLen
- the length (in chars) of the element name.line
- the line in the original document where this artifact starts.col
- the column in the original document where this artifact starts.ParseException
- if any exceptions occur during handling.public void handleAutoCloseElementEnd(char[] buffer, int nameOffset, int nameLen, int line, int col) throws ParseException
IElementHandler
Called for signaling the end of an auto-close element, created for balancing an unclosed tag.
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.
handleAutoCloseElementEnd
in interface IElementHandler
handleAutoCloseElementEnd
in class AbstractMarkupHandler
buffer
- the document buffer (not copied)nameOffset
- the offset (position in buffer) where the element name appears.nameLen
- the length (in chars) of the element name.line
- the line in the original document where the element ending structure appears.col
- the column in the original document where the element ending structure appears.ParseException
- if any exceptions occur during handling.public void handleUnmatchedCloseElementStart(char[] buffer, int nameOffset, int nameLen, int line, int col) throws ParseException
IElementHandler
Called when the start of an unmatched close element (close tag) is found. The name of the element is also reported.
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.
handleUnmatchedCloseElementStart
in interface IElementHandler
handleUnmatchedCloseElementStart
in class AbstractMarkupHandler
buffer
- the document buffer (not copied)nameOffset
- the offset (position in buffer) where the element name appears.nameLen
- the length (in chars) of the element name.line
- the line in the original document where this artifact starts.col
- the column in the original document where this artifact starts.ParseException
- if any exceptions occur during handling.public void handleUnmatchedCloseElementEnd(char[] buffer, int nameOffset, int nameLen, int line, int col) throws ParseException
IElementHandler
Called when the end of an unmatched close element (close tag) is found.
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.
handleUnmatchedCloseElementEnd
in interface IElementHandler
handleUnmatchedCloseElementEnd
in class AbstractMarkupHandler
buffer
- the document buffer (not copied)nameOffset
- the offset (position in buffer) where the element name appears.nameLen
- the length (in chars) of the element name.line
- the line in the original document where the element ending structure appears.col
- the column in the original document where the element ending structure appears.ParseException
- if any exceptions occur during handling.public void handleInnerWhiteSpace(char[] buffer, int offset, int len, int line, int col) throws ParseException
IAttributeSequenceHandler
Called when an amount of white space is found inside an element.
This attribute separators can contain any amount of whitespace, including line feeds:
<div id="main" class="basic_column">
[INNWSP]
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.
handleInnerWhiteSpace
in interface IAttributeSequenceHandler
handleInnerWhiteSpace
in class AbstractMarkupHandler
buffer
- the document buffer (not copied)offset
- offset for the artifact.len
- length of the artifact.line
- the line in the original document where the artifact starts.col
- the column in the original document where the artifact starts.ParseException
- if any exceptions occur during handling.public void handleProcessingInstruction(char[] buffer, int targetOffset, int targetLen, int targetLine, int targetCol, int contentOffset, int contentLen, int contentLine, int contentCol, int outerOffset, int outerLen, int line, int col) throws ParseException
IProcessingInstructionHandler
Called when a Processing Instruction is found.
Three [offset, len] pairs are provided for three partitions (outer, target and content):
<?xls-stylesheet somePar1="a" somePar2="b"?>
| [TARGET------] [CONTENT----------------] |
[OUTER-------------------------------------]
Note that, although XML Declarations have the same format as processing instructions, they are not considered as such and therefore are handled through a different handling method.
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.
handleProcessingInstruction
in interface IProcessingInstructionHandler
handleProcessingInstruction
in class AbstractMarkupHandler
buffer
- the document buffer (not copied)targetOffset
- offset for the target partition.targetLen
- length of the target partition.targetLine
- the line in the original document where the target partition starts.targetCol
- the column in the original document where the target partition starts.contentOffset
- offset for the content partition.contentLen
- length of the content partition.contentLine
- the line in the original document where the content partition starts.contentCol
- the column in the original document where the content partition starts.outerOffset
- offset for the outer partition.outerLen
- length of the outer partition.line
- the line in the original document where this artifact starts.col
- the column in the original document where this artifact starts.ParseException
- if any exceptions occur during handling.Copyright © 2018 The ATTOPARSER team. All rights reserved.