Flying Saucer Project Release ${app.version}

org.xhtmlrenderer.css.newmatch
Class Selector

java.lang.Object
  extended by org.xhtmlrenderer.css.newmatch.Selector

public class Selector
extends java.lang.Object

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

Author:
Torbjörn Gannholm

Field Summary
static int ACTIVE_PSEUDOCLASS
           
static int CHILD_AXIS
           
static int DESCENDANT_AXIS
           
static int FOCUS_PSEUDOCLASS
           
static int HOVER_PSEUDOCLASS
           
static int IMMEDIATE_SIBLING_AXIS
           
static int VISITED_PSEUDOCLASS
           
 
Constructor Summary
Selector()
           
 
Method Summary
 void addAttributeEqualsCondition(java.lang.String namespaceURI, java.lang.String name, java.lang.String value)
          the CSS condition [attribute=value]
 void addAttributeExistsCondition(java.lang.String namespaceURI, java.lang.String name)
          the CSS condition [attribute]
 void addAttributeMatchesFirstPartCondition(java.lang.String namespaceURI, java.lang.String name, java.lang.String value)
          the CSS condition [attribute|=value]
 void addAttributeMatchesListCondition(java.lang.String namespaceURI, java.lang.String name, java.lang.String value)
          the CSS condition [attribute~=value]
 void addAttributePrefixCondition(java.lang.String namespaceURI, java.lang.String name, java.lang.String value)
          the CSS condition [attribute^=value]
 void addAttributeSubstringCondition(java.lang.String namespaceURI, java.lang.String name, java.lang.String value)
          the CSS condition [attribute*=value]
 void addAttributeSuffixCondition(java.lang.String namespaceURI, java.lang.String name, java.lang.String value)
          the CSS condition [attribute$=value]
 void addClassCondition(java.lang.String className)
          the CSS condition .class
 void addFirstChildCondition()
          the CSS condition that element has pseudo-class :first-child
 void addIDCondition(java.lang.String id)
          the CSS condition #ID
 void addLangCondition(java.lang.String lang)
          the CSS condition :lang(Xx)
 void addLinkCondition()
          the CSS condition that element has pseudo-class :link
 void addUnsupportedCondition()
          for unsupported or invalid CSS
 int getAxis()
          get the axis that this selector should be evaluated on
 Selector getChainedSelector()
          get the next selector in the chain, for matching against elements along the appropriate axis
 java.lang.String getPseudoElement()
          Gets the pseudoElement attribute of the Selector object
 Ruleset getRuleset()
          get the Ruleset that this Selector is part of
 int getSelectorID()
           
 int getSpecificityB()
          The correct specificity value for this selector and its sibling-axis selectors
 int getSpecificityC()
          The correct specificity value for this selector and its sibling-axis selectors
 int getSpecificityD()
          The correct specificity value for this selector and its sibling-axis selectors
 boolean isPseudoClass(int pc)
          query if a pseudoclass must apply for this selector
 boolean matches(java.lang.Object e, AttributeResolver attRes, TreeResolver treeRes)
          Check if the given Element matches this selector.
 boolean matchesDynamic(java.lang.Object e, AttributeResolver attRes, TreeResolver treeRes)
          Check if the given Element matches this selector's dynamic properties.
 void setAxis(int axis)
           
 void setChainedSelector(Selector selector)
           
 void setName(java.lang.String name)
           
 void setNamespaceURI(java.lang.String namespaceURI)
           
 void setParent(Ruleset ruleset)
           
 void setPos(int pos)
           
 void setPseudoClass(int pc)
          set which pseudoclasses must apply for this selector
 void setPseudoElement(java.lang.String pseudoElement)
          check if selector queries for dynamic properties
 void setSiblingSelector(Selector selector)
           
 void setSpecificityB(int b)
           
 void setSpecificityC(int c)
           
 void setSpecificityD(int d)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DESCENDANT_AXIS

public static final int DESCENDANT_AXIS
See Also:
Constant Field Values

CHILD_AXIS

public static final int CHILD_AXIS
See Also:
Constant Field Values

IMMEDIATE_SIBLING_AXIS

public static final int IMMEDIATE_SIBLING_AXIS
See Also:
Constant Field Values

VISITED_PSEUDOCLASS

public static final int VISITED_PSEUDOCLASS
See Also:
Constant Field Values

HOVER_PSEUDOCLASS

public static final int HOVER_PSEUDOCLASS
See Also:
Constant Field Values

ACTIVE_PSEUDOCLASS

public static final int ACTIVE_PSEUDOCLASS
See Also:
Constant Field Values

FOCUS_PSEUDOCLASS

public static final int FOCUS_PSEUDOCLASS
See Also:
Constant Field Values
Constructor Detail

Selector

public Selector()
Method Detail

matches

public boolean matches(java.lang.Object e,
                       AttributeResolver attRes,
                       TreeResolver treeRes)
Check if the given Element matches this selector. Note: the parser should give all class


matchesDynamic

public boolean matchesDynamic(java.lang.Object e,
                              AttributeResolver attRes,
                              TreeResolver treeRes)
Check if the given Element matches this selector's dynamic properties. Note: the parser should give all class


addUnsupportedCondition

public void addUnsupportedCondition()
for unsupported or invalid CSS


addLinkCondition

public void addLinkCondition()
the CSS condition that element has pseudo-class :link


addFirstChildCondition

public void addFirstChildCondition()
the CSS condition that element has pseudo-class :first-child


addLangCondition

public void addLangCondition(java.lang.String lang)
the CSS condition :lang(Xx)


addIDCondition

public void addIDCondition(java.lang.String id)
the CSS condition #ID


addClassCondition

public void addClassCondition(java.lang.String className)
the CSS condition .class


addAttributeExistsCondition

public void addAttributeExistsCondition(java.lang.String namespaceURI,
                                        java.lang.String name)
the CSS condition [attribute]


addAttributeEqualsCondition

public void addAttributeEqualsCondition(java.lang.String namespaceURI,
                                        java.lang.String name,
                                        java.lang.String value)
the CSS condition [attribute=value]


addAttributePrefixCondition

public void addAttributePrefixCondition(java.lang.String namespaceURI,
                                        java.lang.String name,
                                        java.lang.String value)
the CSS condition [attribute^=value]


addAttributeSuffixCondition

public void addAttributeSuffixCondition(java.lang.String namespaceURI,
                                        java.lang.String name,
                                        java.lang.String value)
the CSS condition [attribute$=value]


addAttributeSubstringCondition

public void addAttributeSubstringCondition(java.lang.String namespaceURI,
                                           java.lang.String name,
                                           java.lang.String value)
the CSS condition [attribute*=value]


addAttributeMatchesListCondition

public void addAttributeMatchesListCondition(java.lang.String namespaceURI,
                                             java.lang.String name,
                                             java.lang.String value)
the CSS condition [attribute~=value]


addAttributeMatchesFirstPartCondition

public void addAttributeMatchesFirstPartCondition(java.lang.String namespaceURI,
                                                  java.lang.String name,
                                                  java.lang.String value)
the CSS condition [attribute|=value]


setPseudoClass

public void setPseudoClass(int pc)
set which pseudoclasses must apply for this selector

Parameters:
pc - 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.

setPseudoElement

public void setPseudoElement(java.lang.String pseudoElement)
check if selector queries for dynamic properties

Parameters:
pseudoElement - The new pseudoElement value

isPseudoClass

public boolean isPseudoClass(int pc)
query if a pseudoclass must apply for this selector

Parameters:
pc - the values from AttributeResolver should be used.
Returns:
The pseudoClass value

getPseudoElement

public java.lang.String getPseudoElement()
Gets the pseudoElement attribute of the Selector object

Returns:
The pseudoElement value

getChainedSelector

public Selector getChainedSelector()
get the next selector in the chain, for matching against elements along the appropriate axis

Returns:
The chainedSelector value

getRuleset

public Ruleset getRuleset()
get the Ruleset that this Selector is part of

Returns:
The ruleset value

getAxis

public int getAxis()
get the axis that this selector should be evaluated on

Returns:
The axis value

getSpecificityB

public int getSpecificityB()
The correct specificity value for this selector and its sibling-axis selectors


getSpecificityD

public int getSpecificityD()
The correct specificity value for this selector and its sibling-axis selectors


getSpecificityC

public int getSpecificityC()
The correct specificity value for this selector and its sibling-axis selectors


getSelectorID

public int getSelectorID()

setName

public void setName(java.lang.String name)

setPos

public void setPos(int pos)

setParent

public void setParent(Ruleset ruleset)

setAxis

public void setAxis(int axis)

setSpecificityB

public void setSpecificityB(int b)

setSpecificityC

public void setSpecificityC(int c)

setSpecificityD

public void setSpecificityD(int d)

setChainedSelector

public void setChainedSelector(Selector selector)

setSiblingSelector

public void setSiblingSelector(Selector selector)

setNamespaceURI

public void setNamespaceURI(java.lang.String namespaceURI)

Flying Saucer Project Release ${app.version}

Flying Saucer Project Home