Class Selector


  • public class Selector
    extends Object
    A Selector is really a chain of CSS selectors that all need to be valid for the selector to match.
    Author:
    Torbjoern Gannholm
    • Constructor Detail

      • Selector

        public Selector()
    • Method Detail

      • matches

        public boolean matches​(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​(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
      • addLastChildCondition

        public void addLastChildCondition()
        the CSS condition that element has pseudo-class :last-child
      • addNthChildCondition

        public void addNthChildCondition​(String number)
        the CSS condition that element has pseudo-class :nth-child(an+b)
      • addEvenChildCondition

        public void addEvenChildCondition()
        the CSS condition that element has pseudo-class :even
      • addOddChildCondition

        public void addOddChildCondition()
        the CSS condition that element has pseudo-class :odd
      • addLangCondition

        public void addLangCondition​(String lang)
        the CSS condition :lang(Xx)
      • addIDCondition

        public void addIDCondition​(String id)
        the CSS condition #ID
      • addClassCondition

        public void addClassCondition​(String className)
        the CSS condition .class
      • addAttributeExistsCondition

        public void addAttributeExistsCondition​(String namespaceURI,
                                                String name)
        the CSS condition [attribute]
      • addAttributeEqualsCondition

        public void addAttributeEqualsCondition​(String namespaceURI,
                                                String name,
                                                String value)
        the CSS condition [attribute=value]
      • addAttributePrefixCondition

        public void addAttributePrefixCondition​(String namespaceURI,
                                                String name,
                                                String value)
        the CSS condition [attribute^=value]
      • addAttributeSuffixCondition

        public void addAttributeSuffixCondition​(String namespaceURI,
                                                String name,
                                                String value)
        the CSS condition [attribute$=value]
      • addAttributeSubstringCondition

        public void addAttributeSubstringCondition​(String namespaceURI,
                                                   String name,
                                                   String value)
        the CSS condition [attribute*=value]
      • addAttributeMatchesListCondition

        public void addAttributeMatchesListCondition​(String namespaceURI,
                                                     String name,
                                                     String value)
        the CSS condition [attribute~=value]
      • addAttributeMatchesFirstPartCondition

        public void addAttributeMatchesFirstPartCondition​(String namespaceURI,
                                                          String name,
                                                          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​(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 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​(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​(String namespaceURI)