1 18 package org.apache.batik.css.engine.sac; 19 20 import java.util.Set ; 21 22 import org.w3c.css.sac.Condition; 23 import org.w3c.css.sac.ConditionalSelector; 24 import org.w3c.css.sac.SimpleSelector; 25 import org.w3c.dom.Element ; 26 27 34 public class CSSConditionalSelector 35 implements ConditionalSelector, 36 ExtendedSelector { 37 38 41 protected SimpleSelector simpleSelector; 42 43 46 protected Condition condition; 47 48 51 public CSSConditionalSelector(SimpleSelector s, Condition c) { 52 simpleSelector = s; 53 condition = c; 54 } 55 56 60 public boolean equals(Object obj) { 61 if (obj == null || !(obj.getClass() != getClass())) { 62 return false; 63 } 64 CSSConditionalSelector s = (CSSConditionalSelector)obj; 65 return s.simpleSelector.equals(simpleSelector) && 66 s.condition.equals(condition); 67 } 68 69 73 public short getSelectorType() { 74 return SAC_CONDITIONAL_SELECTOR; 75 } 76 77 80 public boolean match(Element e, String pseudoE) { 81 return ((ExtendedSelector)getSimpleSelector()).match(e, pseudoE) && 82 ((ExtendedCondition)getCondition()).match(e, pseudoE); 83 } 84 85 88 public void fillAttributeSet(Set attrSet) { 89 ((ExtendedSelector)getSimpleSelector()).fillAttributeSet(attrSet); 90 ((ExtendedCondition)getCondition()).fillAttributeSet(attrSet); 91 } 92 93 96 public int getSpecificity() { 97 return ((ExtendedSelector)getSimpleSelector()).getSpecificity() + 98 ((ExtendedCondition)getCondition()).getSpecificity(); 99 } 100 101 105 public SimpleSelector getSimpleSelector() { 106 return simpleSelector; 107 } 108 109 113 public Condition getCondition() { 114 return condition; 115 } 116 117 120 public String toString() { 121 return "" + simpleSelector + condition; 122 } 123 } 124 | Popular Tags |