1 18 package org.apache.batik.css.engine.sac; 19 20 import java.util.Set ; 21 22 import org.w3c.css.sac.Selector; 23 import org.w3c.css.sac.SimpleSelector; 24 import org.w3c.dom.Element ; 25 import org.w3c.dom.Node ; 26 27 34 35 public class CSSDirectAdjacentSelector extends AbstractSiblingSelector { 36 37 40 public CSSDirectAdjacentSelector(short type, 41 Selector parent, 42 SimpleSelector simple) { 43 super(type, parent, simple); 44 } 45 46 50 public short getSelectorType() { 51 return SAC_DIRECT_ADJACENT_SELECTOR; 52 } 53 54 57 public boolean match(Element e, String pseudoE) { 58 Node n = e; 59 while ((n = n.getPreviousSibling()) != null && 60 n.getNodeType() != Node.ELEMENT_NODE); 61 if (n != null) { 62 return ((ExtendedSelector)getSelector()).match((Element )n, 63 null) && 64 ((ExtendedSelector)getSiblingSelector()).match(e, pseudoE); 65 } 66 return false; 67 } 68 69 72 public void fillAttributeSet(Set attrSet) { 73 ((ExtendedSelector)getSelector()).fillAttributeSet(attrSet); 74 ((ExtendedSelector)getSiblingSelector()).fillAttributeSet(attrSet); 75 } 76 77 80 public String toString() { 81 return getSelector() + " + " + getSiblingSelector(); 82 } 83 } 84 | Popular Tags |