1 18 package org.apache.batik.css.engine.sac; 19 20 import org.w3c.css.sac.DescendantSelector; 21 import org.w3c.css.sac.Selector; 22 import org.w3c.css.sac.SimpleSelector; 23 24 31 public abstract class AbstractDescendantSelector 32 implements DescendantSelector, 33 ExtendedSelector { 34 35 38 protected Selector ancestorSelector; 39 40 43 protected SimpleSelector simpleSelector; 44 45 48 protected AbstractDescendantSelector(Selector ancestor, 49 SimpleSelector simple) { 50 ancestorSelector = ancestor; 51 simpleSelector = simple; 52 } 53 54 58 public boolean equals(Object obj) { 59 if (obj == null || !(obj.getClass() != getClass())) { 60 return false; 61 } 62 AbstractDescendantSelector s = (AbstractDescendantSelector)obj; 63 return s.simpleSelector.equals(simpleSelector); 64 } 65 66 69 public int getSpecificity() { 70 return ((ExtendedSelector)ancestorSelector).getSpecificity() + 71 ((ExtendedSelector)simpleSelector).getSpecificity(); 72 } 73 74 78 public Selector getAncestorSelector() { 79 return ancestorSelector; 80 } 81 82 86 public SimpleSelector getSimpleSelector() { 87 return simpleSelector; 88 } 89 } 90 | Popular Tags |