public final class ParseStatus
extends Object
Class used for reporting the status of current parsing operations to handlers.
Instances of this class operate at a very low level, and are only useful in very specific scenarios,
so most IMarkupHandler
implementations should just ignore its existence and
consider it only for internal use.
Constructor | Description |
---|---|
ParseStatus() |
Builds a new instance of this class.
|
Modifier and Type | Method | Description |
---|---|---|
int |
getCol() |
Returns the column in the current line in the document the parser is currently located at.
|
int |
getLine() |
Returns the line in the document the parser is currently located at.
|
boolean |
isAutoOpenCloseDone() |
Indicates whether the parser has already performed a required auto-open or auto-close operation.
|
boolean |
isParsingDisabled() |
Determines whether parsing is currently disabled or not.
|
void |
setAutoCloseRequired(char[][] autoCloseRequired,
char[][] autoCloseLimits) |
Force the parser to (possibly) perform a series of auto-close operations for elements that might be open
at the moment in the element stack.
|
void |
setAutoOpenRequired(char[][] autoOpenParents,
char[][] autoOpenLimits) |
Force the parser to (possibly) perform a series of auto-open operations for elements that should be
considered parents of the one being open at a specific moment per the markup spec (made for HTML).
|
void |
setAvoidStacking(boolean avoidStacking) |
Indicate the parser whether the element being handled (in the start event of a standalone
or open element) should be stacked or not.
|
void |
setParsingDisabled(char[] limitSequence) |
Disable parsing until the specified sequence is found in markup.
|
public ParseStatus()
Builds a new instance of this class.
This constructor is for internal use. As a general rule of thumb, there is no reason why any user of this class would need to call this constructor.
public int getLine()
Returns the line in the document the parser is currently located at.
Note this should not be used for event reference, because the parser cursor might be ahead of the events it is reporting. In order to know the lines and cols an event was found at, use the (line,col) pairs reported with every event handler.
public int getCol()
Returns the column in the current line in the document the parser is currently located at.
Note this should not be used for event reference, because the parser cursor might be ahead of the events it is reporting. In order to know the lines and cols an event was found at, use the (line,col) pairs reported with every event handler.
public boolean isParsingDisabled()
Determines whether parsing is currently disabled or not. This only happens if an event handler calls the
setParsingDisabled(char[])
method. In such case, every Text event that will be reported until
the specified limit sequence is found will return false for this method.
public void setParsingDisabled(char[] limitSequence)
Disable parsing until the specified sequence is found in markup. All markup found between the event handler that calls this method and the limit sequence will be reported as Text.
This is used by HTML parsers (like MarkupParser
itself, internally) in order to being
able to correctly report HTML elements such as <script> or <style>, which bodies
should not be parsed (they are CDATA).
limitSequence
- the char sequence that, once found in markup, will enable parsing again.public boolean isAutoOpenCloseDone()
Indicates whether the parser has already performed a required auto-open or auto-close operation. This flag set to true means that these operations have already been performed and that the event is being relaunched after that (so the event can be propagated if needed).
public void setAutoOpenRequired(char[][] autoOpenParents, char[][] autoOpenLimits)
Force the parser to (possibly) perform a series of auto-open operations for elements that should be considered parents of the one being open at a specific moment per the markup spec (made for HTML).
These attributes instruct the event processor to make sure an element is correctly stacked inside the elements it needs to. For example, a <tr> element will ask for the auto-opening of a <tbody> element as its parent, but it will specify as limits also <thead> and <tfoot> because these two elements are also valid parents for it (just not default).
The limits array will be used for specifying: if not null, the IMMEDIATE parents that will be considered valid. If not null, that the parent element sequence should only be considered from the document root, and that it should be completed if something is missing (e.g. there is <html> but no <body>).
When in HTML, the auto-open elements will be:
autoOpenParents
- the parent sequence to be (potentially) auto-open.autoOpenLimits
- the names of the elements that will serve as limits for the auto-open operation. If null,
the parent sequence will only be applied if at root level, or of the sequence is incomplete.public void setAutoCloseRequired(char[][] autoCloseRequired, char[][] autoCloseLimits)
Force the parser to (possibly) perform a series of auto-close operations for elements that might be open at the moment in the element stack.
The parser will auto-close all elements which names match one from the autoCloseRequired array, popping them from the stack until it finds an element with any of the names in the autoCloseLimits array.
For example, when parsing HTML an open <li> will require closing all currently open <li>'s until an <ul> or <ol> is found.
These flags will only be honored by the parser in start events for standalone or open elements, and
after setting them the handler should never propagate the event to its delegate handler (if it exists),
returning control back to the parser instead and letting the parser re-launch the event. When the event
is re-launched, the parser will have set the autoOpenCloseDone flag to true, which can be
checked with the isAutoOpenCloseDone()
method.
autoCloseRequired
- the names of the elements that should be auto-closed.autoCloseLimits
- the names of the elements that will serve as limits for the auto-closing operation.public void setAvoidStacking(boolean avoidStacking)
Indicate the parser whether the element being handled (in the start event of a standalone or open element) should be stacked or not.
Minimized elements (e.g. <hr />) will never be stacked, and it might happen that some open tags that represent HTML void elements should not be stacked either, like <hr>.
This flag will only be honored by the parser in start events for standalone or open elements.
avoidStacking
- whether the parser should avoid stacking this element or not.Copyright © 2018 The ATTOPARSER team. All rights reserved.