1 18 package org.apache.batik.css.engine.sac; 19 20 import org.w3c.dom.Element ; 21 22 29 public class CSSOneOfAttributeCondition extends CSSAttributeCondition { 30 33 public CSSOneOfAttributeCondition(String localName, 34 String namespaceURI, 35 boolean specified, 36 String value) { 37 super(localName, namespaceURI, specified, value); 38 } 39 40 44 public short getConditionType() { 45 return SAC_ONE_OF_ATTRIBUTE_CONDITION; 46 } 47 48 51 public boolean match(Element e, String pseudoE) { 52 String attr = e.getAttribute(getLocalName()); 53 String val = getValue(); 54 int i = attr.indexOf(val); 55 if (i == -1) { 56 return false; 57 } 58 if (i != 0 && !Character.isSpaceChar(attr.charAt(i - 1))) { 59 return false; 60 } 61 int j = i + val.length(); 62 return (j == attr.length() || 63 (j < attr.length() && Character.isSpaceChar(attr.charAt(j)))); 64 } 65 66 69 public String toString() { 70 return "[" + getLocalName() + "~=\"" + getValue() + "\"]"; 71 } 72 } 73 | Popular Tags |