1 18 package org.apache.batik.css.engine.sac; 19 20 import org.apache.batik.css.engine.CSSStylableElement; 21 import org.w3c.dom.Element ; 22 23 30 public class CSSClassCondition extends CSSAttributeCondition { 31 32 35 public CSSClassCondition(String localName, 36 String namespaceURI, 37 String value) { 38 super(localName, namespaceURI, true, value); 39 } 40 41 45 public short getConditionType() { 46 return SAC_CLASS_CONDITION; 47 } 48 49 52 public boolean match(Element e, String pseudoE) { 53 if (!(e instanceof CSSStylableElement)) 54 return false; String attr = ((CSSStylableElement)e).getCSSClass(); 56 String val = getValue(); 57 int i = attr.indexOf(val); 58 if (i == -1) { 59 return false; 60 } 61 if (i != 0 && !Character.isSpaceChar(attr.charAt(i - 1))) { 62 return false; 63 } 64 int j = i + val.length(); 65 return (j == attr.length() || 66 (j < attr.length() && Character.isSpaceChar(attr.charAt(j)))); 67 } 68 69 72 public String toString() { 73 return "." + getValue(); 74 } 75 } 76 | Popular Tags |