Package javafx.css

Class CompoundSelector

java.lang.Object
javafx.css.Selector
javafx.css.CompoundSelector

public final class CompoundSelector extends Selector
A compound selector which behaves according to the CSS standard. The selector is composed of one or more Selectors, along with an array of CompoundSelectorRelationships indicating the required relationship at each stage. There must be exactly one less Combinator than there are selectors.

For example, the parameters [selector1, selector2, selector3] and [Combinator.CHILD, Combinator.DESCENDANT] will match a component when all of the following conditions hold:

  1. The component itself is matched by selector3
  2. The component has an ancestor which is matched by selector2
  3. The ancestor matched in step 2 is a direct CHILD of a component matched by selector1
In other words, the compound selector specified above is (in CSS syntax) selector1 > selector2 selector3. The greater-than (>) between selector1 and selector2 specifies a direct CHILD, whereas the whitespace between selector2 and selector3 corresponds to Combinator.DESCENDANT.
Since:
9
  • Method Details

    • getSelectors

      public List<SimpleSelector> getSelectors()
      The selectors that make up this compound selector
      Returns:
      Immutable List<SimpleSelector>
    • createMatch

      public Match createMatch()
      Description copied from class: Selector
      Creates a Match.
      Specified by:
      createMatch in class Selector
      Returns:
      a match, never null
    • applies

      public boolean applies(Styleable styleable)
      Description copied from class: Selector
      Gets whether this Selector applies to the given Styleable.
      Specified by:
      applies in class Selector
      Parameters:
      styleable - the Styleable to match
      Returns:
      true if this Selector applies to the given Styleable
    • applies

      public boolean applies(Styleable styleable, Set<PseudoClass>[] triggerStates, int depth)
      Description copied from class: Selector
      Gets whether this Selector applies to the given Styleable. It is the same as the Selector.applies(javafx.css.Styleable) method except it also returns PseudoClass state that it finds along the way.
      Specified by:
      applies in class Selector
      Parameters:
      styleable - the Styleable to match
      triggerStates - a set of PseudoClass states
      depth - depth of the Node heirarchy to look for
      Returns:
      true if this Selector and a set of PseudoClass applies to the given Styleable
    • stateMatches

      public boolean stateMatches(Styleable styleable, Set<PseudoClass> states)
      Description copied from class: Selector
      Determines whether the current state of the Node and its parents matches the pseudo-classes defined (if any) for this selector.
      Specified by:
      stateMatches in class Selector
      Parameters:
      styleable - the styleable
      states - the state
      Returns:
      true if the current state of the node and its parents matches the pseudo-classes defined (if any) for this selector
    • writeBinary

      protected final void writeBinary(DataOutputStream os, StyleConverter.StringStore stringStore) throws IOException
      Description copied from class: Selector
      Writes Selector data in binary form to given DataOutputStream.
      Overrides:
      writeBinary in class Selector
      Parameters:
      os - DataOutputStream to write Selector data to
      stringStore - unused
      Throws:
      IOException - if writing to DataOutputStream fails