Class ParseSelection

java.lang.Object
org.attoparser.select.ParseSelection

public final class ParseSelection extends 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 and NodeSelectorMarkupHandler 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
  • Field Details

  • Constructor Details

    • 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 Details

    • 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 and NodeSelectorMarkupHandler handler instances registered at the current handler chain being executed by the parser.

      Returns:
      the total amount of selection levels.
    • getSelectors

      public 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 or NodeSelectorMarkupHandler at the handler chain.

      Parameters:
      level - the selection level.
      Returns:
      all the selectors active for that level (not only the matching ones).
    • getCurrentSelection

      public 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 String toString()
      Overrides:
      toString in class Object