Top Description Fields Constructors Methods
com.openhtmltopdf.css.newmatch

public Class Selector

extends Object
Class Inheritance
Imports
com.openhtmltopdf.css.extend.AttributeResolver, .TreeResolver, com.openhtmltopdf.css.sheet.Ruleset, com.openhtmltopdf.util.LogMessageId, .XRLog, java.util.List, .Set, java.util.logging.Level

A Selector is really a chain of CSS selectors that all need to be valid for the selector to match.
Author
Torbjoern Gannholm

Field Summary

Modifier and TypeField and Description
private Selector
private int
private String
private String
private Ruleset
private int
private String
private int
private int
private int
private int
public static final int
private Selector
public static final int
private List<Condition>
public static final int
public static final int
public static final int
public static final int
private static int
private int
selectorID

Give each a unique ID to be able to create a key to internalize Matcher.Mappers

private Selector
public static final int

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
addAttributeEqualsCondition(String namespaceURI, String name, String value)

the CSS condition [attribute=value]

public void
addAttributeExistsCondition(String namespaceURI, String name)

the CSS condition [attribute]

public void
addAttributeMatchesFirstPartCondition(String namespaceURI, String name, String value)

the CSS condition [attribute|=value]

public void
addAttributeMatchesListCondition(String namespaceURI, String name, String value)

the CSS condition [attribute~=value]

public void
addAttributePrefixCondition(String namespaceURI, String name, String value)

the CSS condition [attribute^=value]

public void
addAttributeSubstringCondition(String namespaceURI, String name, String value)

the CSS condition [attribute*=value]

public void
addAttributeSuffixCondition(String namespaceURI, String name, String value)

the CSS condition [attribute$=value]

public void
addClassCondition(String className)

the CSS condition .class

private void
addCondition(Condition
The feature to be added to the Condition attribute
c
)

Adds a feature to the Condition attribute of the Selector object

public void
addEvenChildCondition()

the CSS condition that element has pseudo-class :even

public void
addFirstChildCondition()

the CSS condition that element has pseudo-class :first-child

public void
addIDCondition(String id)

the CSS condition #ID

public void
addLangCondition(String lang)

the CSS condition :lang(Xx)

public void
addLastChildCondition()

the CSS condition that element has pseudo-class :last-child

public void
addLinkCondition()

the CSS condition that element has pseudo-class :link

public void
addNthChildCondition(String number)

the CSS condition that element has pseudo-class :nth-child(an+b)

public void
addOddChildCondition()

the CSS condition that element has pseudo-class :odd

public void
addUnsupportedCondition()

for unsupported or invalid CSS

public Selector
pack-priv Object

Returns:

The appropriateSibling value
getAppropriateSibling
(Object
PARAM
e
,
TreeResolver treeRes)

Gets the appropriateSibling attribute of the Selector object

public int

Returns:

The axis value
getAxis
()

get the axis that this selector should be evaluated on

public Selector

Returns:

The chainedSelector value
getChainedSelector
()

get the next selector in the chain, for matching against elements along the appropriate axis

pack-priv static String

Returns:

The elementStylingOrder value
getElementStylingOrder
()

Gets the elementStylingOrder attribute of the Selector class

pack-priv String

Returns:

The order value
getOrder
()

returns "a number in a large base" with specificity and specification order of selector

public String

Returns:

The pseudoElement value
getPseudoElement
()

Gets the pseudoElement attribute of the Selector object

public Ruleset

Returns:

The ruleset value
getRuleset
()

get the Ruleset that this Selector is part of

public int
public int
getSpecificityB()

The correct specificity value for this selector and its sibling-axis selectors

public int
getSpecificityC()

The correct specificity value for this selector and its sibling-axis selectors

public int
getSpecificityD()

The correct specificity value for this selector and its sibling-axis selectors

public boolean

Returns:

The pseudoClass value
isPseudoClass
(int
the values from AttributeResolver should be used.
pc
)

query if a pseudoclass must apply for this selector

public boolean
matches(Object e, AttributeResolver attRes, TreeResolver treeRes)

Check if the given Element matches this selector.

public boolean
matchesDynamic(Object e, AttributeResolver attRes, TreeResolver treeRes)

Check if the given Element matches this selector's dynamic properties.

public void
public void
setAxis(int axis)

public void
public void
public void
setNamespaceURI(String namespaceURI)

public void
setParent(Ruleset ruleset)

public void
setPos(int pos)

public void
setPseudoClass(int
the values from AttributeResolver should be used. Once set they cannot be unset. Note that the pseudo-classes should be set one at a time, otherwise specificity of declaration becomes wrong.
pc
)

set which pseudoclasses must apply for this selector

public void
setPseudoElement(String
The new pseudoElement value
pseudoElement
)

check if selector queries for dynamic properties

public void
public void
public void
public void
public void
toCSS(StringBuilder sb, Set<Selector> stopAt)

Prints the selector chain to a StringBuilder, stopping when it hits a selector in the stopAt set.

public String
toString()

Overrides java.lang.Object.toString.

For debugging, prints the entire selector chain.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

_ancestorSelectorback to summary
private Selector _ancestorSelector
_axisback to summary
private int _axis
_nameback to summary
private String _name
_namespaceURIback to summary
private String _namespaceURI
_parentback to summary
private Ruleset _parent
_pcback to summary
private int _pc
_peback to summary
private String _pe
_posback to summary
private int _pos
_specificityBback to summary
private int _specificityB
_specificityCback to summary
private int _specificityC
_specificityDback to summary
private int _specificityD
ACTIVE_PSEUDOCLASSback to summary
public static final int ACTIVE_PSEUDOCLASS
chainedSelectorback to summary
private Selector chainedSelector
CHILD_AXISback to summary
public static final int CHILD_AXIS
conditionsback to summary
private List<Condition> conditions
DESCENDANT_AXISback to summary
public static final int DESCENDANT_AXIS
FOCUS_PSEUDOCLASSback to summary
public static final int FOCUS_PSEUDOCLASS
HOVER_PSEUDOCLASSback to summary
public static final int HOVER_PSEUDOCLASS
IMMEDIATE_SIBLING_AXISback to summary
public static final int IMMEDIATE_SIBLING_AXIS
selectorCountback to summary
private static int selectorCount
selectorIDback to summary
private int selectorID

Give each a unique ID to be able to create a key to internalize Matcher.Mappers

siblingSelectorback to summary
private Selector siblingSelector
VISITED_PSEUDOCLASSback to summary
public static final int VISITED_PSEUDOCLASS

Constructor Detail

Selectorback to summary
public Selector()

Method Detail

addAttributeEqualsConditionback to summary
public void addAttributeEqualsCondition(String namespaceURI, String name, String value)

the CSS condition [attribute=value]

addAttributeExistsConditionback to summary
public void addAttributeExistsCondition(String namespaceURI, String name)

the CSS condition [attribute]

addAttributeMatchesFirstPartConditionback to summary
public void addAttributeMatchesFirstPartCondition(String namespaceURI, String name, String value)

the CSS condition [attribute|=value]

addAttributeMatchesListConditionback to summary
public void addAttributeMatchesListCondition(String namespaceURI, String name, String value)

the CSS condition [attribute~=value]

addAttributePrefixConditionback to summary
public void addAttributePrefixCondition(String namespaceURI, String name, String value)

the CSS condition [attribute^=value]

addAttributeSubstringConditionback to summary
public void addAttributeSubstringCondition(String namespaceURI, String name, String value)

the CSS condition [attribute*=value]

addAttributeSuffixConditionback to summary
public void addAttributeSuffixCondition(String namespaceURI, String name, String value)

the CSS condition [attribute$=value]

addClassConditionback to summary
public void addClassCondition(String className)

the CSS condition .class

addConditionback to summary
private void addCondition(Condition c)

Adds a feature to the Condition attribute of the Selector object

Parameters
c:Condition

The feature to be added to the Condition attribute

addEvenChildConditionback to summary
public void addEvenChildCondition()

the CSS condition that element has pseudo-class :even

addFirstChildConditionback to summary
public void addFirstChildCondition()

the CSS condition that element has pseudo-class :first-child

addIDConditionback to summary
public void addIDCondition(String id)

the CSS condition #ID

addLangConditionback to summary
public void addLangCondition(String lang)

the CSS condition :lang(Xx)

addLastChildConditionback to summary
public void addLastChildCondition()

the CSS condition that element has pseudo-class :last-child

addLinkConditionback to summary
public void addLinkCondition()

the CSS condition that element has pseudo-class :link

addNthChildConditionback to summary
public void addNthChildCondition(String number)

the CSS condition that element has pseudo-class :nth-child(an+b)

addOddChildConditionback to summary
public void addOddChildCondition()

the CSS condition that element has pseudo-class :odd

addUnsupportedConditionback to summary
public void addUnsupportedCondition()

for unsupported or invalid CSS

getAncestorSelectorback to summary
public Selector getAncestorSelector()
getAppropriateSiblingback to summary
pack-priv Object getAppropriateSibling(Object e, TreeResolver treeRes)

Gets the appropriateSibling attribute of the Selector object

Parameters
e:Object

PARAM

Returns:Object

The appropriateSibling value

getAxisback to summary
public int getAxis()

get the axis that this selector should be evaluated on

Returns:int

The axis value

getChainedSelectorback to summary
public Selector getChainedSelector()

get the next selector in the chain, for matching against elements along the appropriate axis

Returns:Selector

The chainedSelector value

getElementStylingOrderback to summary
pack-priv static String getElementStylingOrder()

Gets the elementStylingOrder attribute of the Selector class

Returns:String

The elementStylingOrder value

getOrderback to summary
pack-priv String getOrder()

returns "a number in a large base" with specificity and specification order of selector

Returns:String

The order value

getPseudoElementback to summary
public String getPseudoElement()

Gets the pseudoElement attribute of the Selector object

Returns:String

The pseudoElement value

getRulesetback to summary
public Ruleset getRuleset()

get the Ruleset that this Selector is part of

Returns:Ruleset

The ruleset value

getSelectorIDback to summary
public int getSelectorID()
getSpecificityBback to summary
public int getSpecificityB()

The correct specificity value for this selector and its sibling-axis selectors

getSpecificityCback to summary
public int getSpecificityC()

The correct specificity value for this selector and its sibling-axis selectors

getSpecificityDback to summary
public int getSpecificityD()

The correct specificity value for this selector and its sibling-axis selectors

isPseudoClassback to summary
public boolean isPseudoClass(int pc)

query if a pseudoclass must apply for this selector

Parameters
pc:int

the values from AttributeResolver should be used.

Returns:boolean

The pseudoClass value

matchesback to summary
public boolean matches(Object e, AttributeResolver attRes, TreeResolver treeRes)

Check if the given Element matches this selector.

Note

the parser should give all class

matchesDynamicback to summary
public boolean matchesDynamic(Object e, AttributeResolver attRes, TreeResolver treeRes)

Check if the given Element matches this selector's dynamic properties.

Note

the parser should give all class

setAncestorSelectorback to summary
public void setAncestorSelector(Selector ancestor)
setAxisback to summary
public void setAxis(int axis)
setChainedSelectorback to summary
public void setChainedSelector(Selector selector)
setNameback to summary
public void setName(String name)
setNamespaceURIback to summary
public void setNamespaceURI(String namespaceURI)
setParentback to summary
public void setParent(Ruleset ruleset)
setPosback to summary
public void setPos(int pos)
setPseudoClassback to summary
public void setPseudoClass(int pc)

set which pseudoclasses must apply for this selector

Parameters
pc:int

the values from AttributeResolver should be used. Once set they cannot be unset. Note that the pseudo-classes should be set one at a time, otherwise specificity of declaration becomes wrong.

setPseudoElementback to summary
public void setPseudoElement(String pseudoElement)

check if selector queries for dynamic properties

Parameters
pseudoElement:String

The new pseudoElement value

setSiblingSelectorback to summary
public void setSiblingSelector(Selector selector)
setSpecificityBback to summary
public void setSpecificityB(int b)
setSpecificityCback to summary
public void setSpecificityC(int c)
setSpecificityDback to summary
public void setSpecificityD(int d)
toCSSback to summary
public void toCSS(StringBuilder sb, Set<Selector> stopAt)

Prints the selector chain to a StringBuilder, stopping when it hits a selector in the stopAt set. For example, given the selector 'body svg rect' and the stop set contains 'svg' then this will print 'rect' to the builder. This method is used to recreate CSS selectors to pass to SVG or other plugins. FIXME: Does not handle sibling selector.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

For debugging, prints the entire selector chain. FIXME: Does not handle sibling selectors.

Returns:String

Doc from java.lang.Object.toString.

a string representation of the object

Annotations
@Override