public interface IMarkupHandler extends IDocumentHandler, IXMLDeclarationHandler, IDocTypeHandler, ICDATASectionHandler, ICommentHandler, ITextHandler, IElementHandler, IProcessingInstructionHandler
Interface to be implemented by all Markup Handlers.
Markup handlers are the objects that receive the events produced during parsing and perform the operations the users need. This interface is the main entry point to use AttoParser.
Markup handlers can be stateful, which means that a new instance of the markup handler class should be created for each parsing operation. In such case, it is not required that these implementations are thread-safe.
There is an abstract, basic, no-op implementation of this interface called
AbstractMarkupHandler
which can be used for easily creating new handlers by overriding
only the relevant event handling methods.
Note also there is a simplified version of this interface that reduces the number of events
and also simplifies the operations on textual buffers, called ISimpleMarkupHandler
,
which can be easily used with the convenience ad-hoc parser class
SimpleMarkupParser
.
AttoParser provides several useful implementations of this interface out-of-the-box:
OutputMarkupHandler
Writer
object, without any loss of information (case, whitespaces, etc.). This
handler is useful for performing filtering/transformation operations on the parsed markup, placing this
handler at the end of the handler chain so that it outputs the final results of such operation.
TextOutputMarkupHandler
Writer
object as mere text, ignoring all non-text events. This will effectively
strip all markup elements, comments, DOCTYPEs, etc. from the original markup.
DOMBuilderMarkupHandler
DOMMarkupParser
.
SimplifierMarkupHandler
ISimpleMarkupHandler
interface. Note this handler can be more easily
applied by using the convenience ad-hoc parser class SimpleMarkupParser
.
MinimizeHtmlMarkupHandler
BlockSelectorMarkupHandler
org.attoparser.select
).
NodeSelectorMarkupHandler
org.attoparser.select
).
AttributeSelectionMarkingMarkupHandler
DuplicateMarkupHandler
IMarkupHandler
.
PrettyHtmlMarkupHandler
TraceBuilderMarkupHandler
MarkupTraceEvent
objects) detailing all the events launched
during the parsing of a document.
Modifier and Type | Method and Description |
---|---|
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. |
handleDocumentEnd, handleDocumentStart
handleXmlDeclaration
handleDocType
handleCDATASection
handleComment
handleText
handleAutoCloseElementEnd, handleAutoCloseElementStart, handleAutoOpenElementEnd, handleAutoOpenElementStart, handleCloseElementEnd, handleCloseElementStart, handleOpenElementEnd, handleOpenElementStart, handleStandaloneElementEnd, handleStandaloneElementStart, handleUnmatchedCloseElementEnd, handleUnmatchedCloseElementStart
handleAttribute, handleInnerWhiteSpace
handleProcessingInstruction
void setParseConfiguration(ParseConfiguration parseConfiguration)
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.
parseConfiguration
- the configuration object.void setParseStatus(ParseStatus status)
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.
status
- the status object.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.
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.
selection
- the selection object.Copyright © 2023 The ATTOPARSER team. All rights reserved.