Class ParseSelection
- java.lang.Object
-
- org.attoparser.select.ParseSelection
-
public final class ParseSelection extends java.lang.Object
Class used for reporting the current selectors matching the different levels of selection specified at the handler chain by means of instances of
BlockSelectorMarkupHandler
andNodeSelectorMarkupHandler
instances.Each selection level represents a selection handler (block or node), in the order that they have been setup for execution in the handler chain.
The
toString()
method of this class provides a visual representation of all the selection levels currently being used, as well as the selectors that are matching at each level.- Since:
- 2.0.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
ParseSelection.ParseSelectionLevel
-
Field Summary
Fields Modifier and Type Field Description private int
levelCounter
(package private) ParseSelection.ParseSelectionLevel[]
levels
-
Constructor Summary
Constructors Constructor Description ParseSelection()
Create a new instance of this class.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String[]
getCurrentSelection(int level)
Returns the matching selectors for a specific selection level, or null if no selector is currently matching at that level.int
getSelectionLevels()
Get the amount of levels that have been registered at the handler chain.java.lang.String[]
getSelectors(int level)
Returns all the selectors (not only the matching ones) active for a specific selection level, ie for a specific instance ofBlockSelectorMarkupHandler
orNodeSelectorMarkupHandler
at the handler chain.boolean
isMatchingAny()
Returns whether any selectors are currently matching, at any level.boolean
isMatchingAny(int level)
Returns whether any selectors are currently matching at the specified selection level.(package private) int
subscribeLevel()
java.lang.String
toString()
-
-
-
Field Detail
-
levelCounter
private int levelCounter
-
levels
ParseSelection.ParseSelectionLevel[] levels
-
-
Constructor Detail
-
ParseSelection
public ParseSelection()
Create a new instance of this class. Instances of this class are normally created by the parser implementation objects (e.g.
MarkupParser
), so there is no need to ever call this constructor from the user's code.
-
-
Method Detail
-
subscribeLevel
int subscribeLevel()
-
getSelectionLevels
public int getSelectionLevels()
Get the amount of levels that have been registered at the handler chain. This will be the amount of
BlockSelectorMarkupHandler
andNodeSelectorMarkupHandler
handler instances registered at the current handler chain being executed by the parser.- Returns:
- the total amount of selection levels.
-
getSelectors
public java.lang.String[] getSelectors(int level)
Returns all the selectors (not only the matching ones) active for a specific selection level, ie for a specific instance of
BlockSelectorMarkupHandler
orNodeSelectorMarkupHandler
at the handler chain.- Parameters:
level
- the selection level.- Returns:
- all the selectors active for that level (not only the matching ones).
-
getCurrentSelection
public java.lang.String[] getCurrentSelection(int level)
Returns the matching selectors for a specific selection level, or null if no selector is currently matching at that level.
This method should only be called from event handlers or other code called from these, given the information about matching selectors will only be updated before (and after) calling the events relevant for that selection.
- Parameters:
level
- the selection level.- Returns:
- the currently matching selectors for that level.
-
isMatchingAny
public boolean isMatchingAny(int level)
Returns whether any selectors are currently matching at the specified selection level.
- Parameters:
level
- the selection level.- Returns:
- true if any selectors are matching at the specified level, false if not.
-
isMatchingAny
public boolean isMatchingAny()
Returns whether any selectors are currently matching, at any level.
- Returns:
- true if any selectors are matching at any level, false if not.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-