Top Description Inners Fields Constructors Methods
com.sun.javafx.css

public final Class SelectorPartitioning

extends Object
Class Inheritance
Imports
javafx.css.Selector, java.util.ArrayList, .Collections, .Comparator, .HashMap, .List, .Map, .Set

Code to partition selectors into a tree-like structure for faster matching.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
SelectorPartitioning.Partition

A Partition corresponds to a selector type, id or styleclass.

private static class
private static class
SelectorPartitioning.Slot

A Slot is pointer to the next piece of the selector.

Field Summary

Modifier and TypeField and Description
private static final Comparator<Selector>
private static final int
private final Map<SelectorPartitioning.PartitionKey<K>, SelectorPartitioning.Partition>
private int
ordinal

Keep track of the order in which a selector is added to the mapping so the original order can be restored for the cascade.

private static final int
private final Map<SelectorPartitioning.PartitionKey<K>, SelectorPartitioning.Partition>
private static final int
private final Map<SelectorPartitioning.PartitionKey<K>, SelectorPartitioning.Partition>
private static final SelectorPartitioning.PartitionKey<K>

Constructor Summary

AccessConstructor and Description
public
SelectorPartitioning()

package accessible

Method Summary

Modifier and TypeMethod and Description
private static SelectorPartitioning.Partition
getPartition(SelectorPartitioning.PartitionKey<K> id, Map<SelectorPartitioning.PartitionKey<K>, SelectorPartitioning.Partition> map)

Helper to lookup an id in the given map, creating and adding a Partition

public List<Selector>
match(String selectorId, String selectorType, Set<String> selectorStyleClass)

Get the list of selectors that match this selector.

public void
partition(Selector selector)

public void
reset()

clear current partitioning

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

COMPARATORback to summary
private static final Comparator<Selector> COMPARATOR
ID_BITback to summary
private static final int ID_BIT
idMapback to summary
private final Map<SelectorPartitioning.PartitionKey<K>, SelectorPartitioning.Partition> idMap
ordinalback to summary
private int ordinal

Keep track of the order in which a selector is added to the mapping so the original order can be restored for the cascade.

STYLECLASS_BITback to summary
private static final int STYLECLASS_BIT
styleClassMapback to summary
private final Map<SelectorPartitioning.PartitionKey<K>, SelectorPartitioning.Partition> styleClassMap
TYPE_BITback to summary
private static final int TYPE_BIT
typeMapback to summary
private final Map<SelectorPartitioning.PartitionKey<K>, SelectorPartitioning.Partition> typeMap
WILDCARDback to summary
private static final SelectorPartitioning.PartitionKey<K> WILDCARD

Constructor Detail

SelectorPartitioningback to summary
public SelectorPartitioning()

package accessible

Method Detail

getPartitionback to summary
private static SelectorPartitioning.Partition getPartition(SelectorPartitioning.PartitionKey<K> id, Map<SelectorPartitioning.PartitionKey<K>, SelectorPartitioning.Partition> map)

Helper to lookup an id in the given map, creating and adding a Partition

matchback to summary
public List<Selector> match(String selectorId, String selectorType, Set<String> selectorStyleClass)

Get the list of selectors that match this selector. Package accessible

partitionback to summary
public void partition(Selector selector)
Annotations
@SuppressWarnings:removal
resetback to summary
public void reset()

clear current partitioning

com.sun.javafx.css back to summary

private final Class SelectorPartitioning.Partition

extends Object
Class Inheritance

A Partition corresponds to a selector type, id or styleclass. For any given id (for example) there will be one Partition held in the corresponding map (idMap, for example). Each Partition has Slots which define a path from one Partition to the next. For example, if we have A.b#c, there will be a Partition for each of A, .b and #c. The partition for #c will have a Slot pointing to A. Likewise, A will have a Slot corresponding to .b. Each Slot is capable of pointing to more than one Partition. If another selector A.#c.z were partitioned, then the Slot for A in Partition #c would now have Slots for both .b and .z.

Rules are added to the last Slot or to the Partition. If there is a selector #c { -fx-fill: red; }, then the selector will be added to the Partition for #c. If the selector were for A.b#c, then selector would be added to the slot for '.b' which is in the slot for A in partion #c.

When Node is matched, it picks up the Selectors from the Partition and Slot as the graph is traversed.

Field Summary

Modifier and TypeField and Description
private final SelectorPartitioning.PartitionKey<K>
private List<Selector>
private final Map<SelectorPartitioning.PartitionKey<K>, SelectorPartitioning.Slot>

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private void
private SelectorPartitioning.Slot
partition(SelectorPartitioning.PartitionKey<K> id, Map<SelectorPartitioning.PartitionKey<K>, SelectorPartitioning.Partition> map)

This routine finds the slot corresponding to the PartitionKey, creating a Partition and Slot if necessary.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

keyback to summary
private final SelectorPartitioning.PartitionKey<K> key
selectorsback to summary
private List<Selector> selectors
slotsback to summary
private final Map<SelectorPartitioning.PartitionKey<K>, SelectorPartitioning.Slot> slots

Constructor Detail

Partitionback to summary
private Partition(SelectorPartitioning.PartitionKey<K> key)

Method Detail

addSelectorback to summary
private void addSelector(Selector pair)
partitionback to summary
private SelectorPartitioning.Slot partition(SelectorPartitioning.PartitionKey<K> id, Map<SelectorPartitioning.PartitionKey<K>, SelectorPartitioning.Partition> map)

This routine finds the slot corresponding to the PartitionKey, creating a Partition and Slot if necessary.

com.sun.javafx.css back to summary

private final Class SelectorPartitioning.PartitionKey<K>

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final K

Constructor Summary

AccessConstructor and Description
private
PartitionKey(K key)

Method Summary

Modifier and TypeMethod and Description
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 int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAlltoStringwaitwaitwait

Field Detail

keyback to summary
private final K key

Constructor Detail

PartitionKeyback to summary
private PartitionKey(K key)

Method Detail

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
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
com.sun.javafx.css back to summary

private final Class SelectorPartitioning.Slot

extends Object
Class Inheritance

A Slot is pointer to the next piece of the selector.

Field Summary

Modifier and TypeField and Description
private final SelectorPartitioning.Partition
private final Map<SelectorPartitioning.PartitionKey<K>, SelectorPartitioning.Slot>
private List<Selector>

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private void
private SelectorPartitioning.Slot
partition(SelectorPartitioning.PartitionKey<K> id, Map<SelectorPartitioning.PartitionKey<K>, SelectorPartitioning.Partition> map)

This routine finds the slot corresponding to the PartitionKey, creating a Partition and Slot if necessary.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

partitionback to summary
private final SelectorPartitioning.Partition partition
referentsback to summary
private final Map<SelectorPartitioning.PartitionKey<K>, SelectorPartitioning.Slot> referents
selectorsback to summary
private List<Selector> selectors

Constructor Detail

Slotback to summary
private Slot(SelectorPartitioning.Partition partition)

Method Detail

addSelectorback to summary
private void addSelector(Selector pair)
partitionback to summary
private SelectorPartitioning.Slot partition(SelectorPartitioning.PartitionKey<K> id, Map<SelectorPartitioning.PartitionKey<K>, SelectorPartitioning.Partition> map)

This routine finds the slot corresponding to the PartitionKey, creating a Partition and Slot if necessary.