jodd.lagarto.csselly
Class CssSelector

java.lang.Object
  extended by jodd.lagarto.csselly.CssSelector
All Implemented Interfaces:
NodeFilter

public class CssSelector
extends java.lang.Object
implements NodeFilter

CSS selector.


Field Summary
protected  Combinator combinator
           
protected  java.lang.String element
           
protected  CssSelector nextCssSelector
           
protected  CssSelector prevCssSelector
           
protected  java.util.List<Selector> selectors
           
 
Constructor Summary
CssSelector()
           
CssSelector(java.lang.String element)
           
 
Method Summary
 boolean accept(java.util.LinkedList<Node> currentResults, Node node, int index)
          Accepts node within current results.
 boolean accept(Node node)
          Accepts single node.
 void addAttributeSelector(java.lang.String attribute)
           
 void addClassSelector(java.lang.String clazz)
           
 void addIdSelector(java.lang.String id)
           
 void addPseudoClassSelector(java.lang.String pseudoClass)
           
 void addPseudoFunctionSelector(java.lang.String pseudoFunction, java.lang.String expression)
           
 Combinator getCombinator()
          Returns combinator, may be null.
 java.lang.String getElement()
          Returns selector element name.
 CssSelector getNextCssSelector()
          Returns next CssSelector.
 CssSelector getPrevCssSelector()
          Returns previous CssSelector.
 Selector getSelector(int index)
          Returns selector for given index.
protected  boolean matchElement(Node node)
          Matches element to css selector.
 int selectorsCount()
          Returns number of selectors.
 void setCombinator(Combinator combinator)
          Sets combinator.
 java.lang.String toString()
          Generates CSS selector for the output.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

prevCssSelector

protected CssSelector prevCssSelector

nextCssSelector

protected CssSelector nextCssSelector

element

protected final java.lang.String element

combinator

protected Combinator combinator

selectors

protected java.util.List<Selector> selectors
Constructor Detail

CssSelector

public CssSelector()

CssSelector

public CssSelector(java.lang.String element)
Method Detail

getPrevCssSelector

public CssSelector getPrevCssSelector()
Returns previous CssSelector.


getNextCssSelector

public CssSelector getNextCssSelector()
Returns next CssSelector.


getElement

public java.lang.String getElement()
Returns selector element name. Returns * for universal selectors.


getSelector

public Selector getSelector(int index)
Returns selector for given index.


selectorsCount

public int selectorsCount()
Returns number of selectors.


setCombinator

public void setCombinator(Combinator combinator)
Sets combinator.


getCombinator

public Combinator getCombinator()
Returns combinator, may be null.


addIdSelector

public void addIdSelector(java.lang.String id)

addClassSelector

public void addClassSelector(java.lang.String clazz)

addAttributeSelector

public void addAttributeSelector(java.lang.String attribute)

addPseudoClassSelector

public void addPseudoClassSelector(java.lang.String pseudoClass)

addPseudoFunctionSelector

public void addPseudoFunctionSelector(java.lang.String pseudoFunction,
                                      java.lang.String expression)

toString

public java.lang.String toString()
Generates CSS selector for the output.

Overrides:
toString in class java.lang.Object

accept

public boolean accept(Node node)
Accepts single node.

Specified by:
accept in interface NodeFilter

matchElement

protected boolean matchElement(Node node)
Matches element to css selector. All non-element types are ignored.


accept

public boolean accept(java.util.LinkedList<Node> currentResults,
                      Node node,
                      int index)
Accepts node within current results.



Copyright © 2003-2012 Jodd Team