Top Description Fields Constructors Methods
javafx.css

public final Class CompoundSelector

extends Selector
Class Inheritance
Imports
com.sun.javafx.css.Combinator, .PseudoClassState, java.io.DataInputStream, .DataOutputStream, .IOException, java.util.ArrayList, .Collections, .List, .Set

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

Field Summary

Modifier and TypeField and Description
private int
private final List<Combinator>
private final List<SimpleSelector>

Constructor Summary

AccessConstructor and Description
pack-priv
CompoundSelector(List<SimpleSelector> selectors, List<Combinator> relationships)

Creates a CompoundSelector from a list of selectors and a list of Combinator relationships.

Method Summary

Modifier and TypeMethod and Description
public boolean
applies(final Styleable
the Styleable to match
styleable
)

Implements abstract javafx.css.Selector.applies.

Gets whether this Selector applies to the given Styleable.

public boolean
applies(final Styleable
the Styleable to match
styleable
,
Set<PseudoClass>[]
a set of PseudoClass states
triggerStates
,
int
depth of the Node heirarchy to look for
depth
)

Implements abstract javafx.css.Selector.applies.

Gets whether this Selector applies to the given Styleable.

private boolean
applies(final Styleable styleable, final int index, Set<PseudoClass>[] triggerStates, int depth)

public Match
createMatch()

Implements abstract javafx.css.Selector.createMatch.

Creates a Match.

public boolean
equals(Object
the reference object with which to compare.
obj
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

public List<SimpleSelector>

Returns:

Immutable List<SimpleSelector>
getSelectors
()

The selectors that make up this compound selector

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

pack-priv static CompoundSelector
readBinary(int
bss version identifier
bssVersion
,
final DataInputStream
DataInputStream to read Selector data from
is
,
final String[]
string array containing selector details
strings
)

Hides javafx.css.Selector.readBinary.

Reads binary Selector data from a given DataInputStream.

public boolean
stateMatches(final Styleable
the styleable
styleable
,
Set<PseudoClass>
the state
states
)

Implements abstract javafx.css.Selector.stateMatches.

Determines whether the current state of the Node and its parents matches the pseudo-classes defined (if any) for this selector.

private boolean
stateMatches(Styleable styleable, Set<PseudoClass> states, int index)

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

protected final void
writeBinary(final DataOutputStream
DataOutputStream to write Selector data to
os
,
final StyleConverter.StringStore
unused
stringStore
)

Overrides javafx.css.Selector.writeBinary.

Writes Selector data in binary form to given DataOutputStream.

Inherited from javafx.css.Selector:
createSelectorgetOrdinalgetRulegetUniversalSelectorsetOrdinalsetRule

Field Detail

hashback to summary
private int hash
relationshipsback to summary
private final List<Combinator> relationships
selectorsback to summary
private final List<SimpleSelector> selectors

Constructor Detail

CompoundSelectorback to summary
pack-priv CompoundSelector(List<SimpleSelector> selectors, List<Combinator> relationships)

Creates a CompoundSelector from a list of selectors and a list of Combinator relationships. There must be exactly one less Combinator than there are selectors.

Method Detail

appliesback to summary
public boolean applies(final Styleable styleable)

Implements abstract javafx.css.Selector.applies.

Doc from javafx.css.Selector.applies.

Gets whether this Selector applies to the given Styleable.

Parameters
styleable:Styleable

the Styleable to match

Returns:boolean

true if this Selector applies to the given Styleable

Annotations
@Override
appliesback to summary
public boolean applies(final Styleable styleable, Set<PseudoClass>[] triggerStates, int depth)

Implements abstract javafx.css.Selector.applies.

Doc from javafx.css.Selector.applies.

Gets whether this Selector applies to the given Styleable. It is the same as the applies(Styleable) method except it also returns PseudoClass state that it finds along the way.

Parameters
styleable:Styleable

the Styleable to match

triggerStates:Set<PseudoClass>[]

a set of PseudoClass states

depth:int

depth of the Node heirarchy to look for

Returns:boolean

true if this Selector and a set of PseudoClass applies to the given Styleable

Annotations
@Override
appliesback to summary
private boolean applies(final Styleable styleable, final int index, Set<PseudoClass>[] triggerStates, int depth)
createMatchback to summary
public Match createMatch()

Implements abstract javafx.css.Selector.createMatch.

Doc from javafx.css.Selector.createMatch.

Creates a Match.

Returns:Match

a match, never null

Annotations
@Override
equalsback to summary
public boolean equals(Object obj)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
obj:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
getSelectorsback to summary
public List<SimpleSelector> getSelectors()

The selectors that make up this compound selector

Returns:List<SimpleSelector>

Immutable List<SimpleSelector>

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

Annotations
@Override
readBinaryback to summary
pack-priv static CompoundSelector readBinary(int bssVersion, final DataInputStream is, final String[] strings) throws IOException

Hides javafx.css.Selector.readBinary.

Doc from javafx.css.Selector.readBinary.

Reads binary Selector data from a given DataInputStream.

Parameters
bssVersion:int

bss version identifier

is:DataInputStream

DataInputStream to read Selector data from

strings:String[]

string array containing selector details

Exceptions
IOException:
if reading from DataInputStream fails
stateMatchesback to summary
public boolean stateMatches(final Styleable styleable, Set<PseudoClass> states)

Implements abstract javafx.css.Selector.stateMatches.

Doc from javafx.css.Selector.stateMatches.

Determines whether the current state of the Node and its parents matches the pseudo-classes defined (if any) for this selector.

Parameters
styleable:Styleable

the styleable

states:Set<PseudoClass>

the state

Returns:boolean

true if the current state of the node and its parents matches the pseudo-classes defined (if any) for this selector

Annotations
@Override
stateMatchesback to summary
private boolean stateMatches(Styleable styleable, Set<PseudoClass> states, int index)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
writeBinaryback to summary
protected final void writeBinary(final DataOutputStream os, final StyleConverter.StringStore stringStore) throws IOException

Overrides javafx.css.Selector.writeBinary.

Doc from javafx.css.Selector.writeBinary.

Writes Selector data in binary form to given DataOutputStream.

Parameters
os:DataOutputStream

DataOutputStream to write Selector data to

stringStore:StyleConverter.StringStore

unused

Annotations
@Override
Exceptions
IOException:
if writing to DataOutputStream fails