1 18 package org.apache.batik.css.engine.sac; 19 20 import java.util.Set ; 21 22 import org.w3c.dom.Element ; 23 24 31 public class CSSAttributeCondition extends AbstractAttributeCondition { 32 35 protected String localName; 36 37 40 protected String namespaceURI; 41 42 45 protected boolean specified; 46 47 50 public CSSAttributeCondition(String localName, 51 String namespaceURI, 52 boolean specified, 53 String value) { 54 super(value); 55 this.localName = localName; 56 this.namespaceURI = namespaceURI; 57 this.specified = specified; 58 } 59 60 64 public boolean equals(Object obj) { 65 if (!super.equals(obj)) { 66 return false; 67 } 68 CSSAttributeCondition c = (CSSAttributeCondition)obj; 69 return c.namespaceURI.equals(namespaceURI) && 70 c.localName.equals(localName) && 71 c.specified == specified; 72 } 73 74 78 public short getConditionType() { 79 return SAC_ATTRIBUTE_CONDITION; 80 } 81 82 86 public String getNamespaceURI() { 87 return namespaceURI; 88 } 89 90 94 public String getLocalName() { 95 return localName; 96 } 97 98 102 public boolean getSpecified() { 103 return specified; 104 } 105 106 109 public boolean match(Element e, String pseudoE) { 110 String val = getValue(); 111 if (val == null) { 112 return !e.getAttribute(getLocalName()).equals(""); 113 } 114 return e.getAttribute(getLocalName()).equals(val); 115 } 116 117 120 public void fillAttributeSet(Set attrSet) { 121 attrSet.add(localName); 122 } 123 124 127 public String toString() { 128 if (value == null) { 129 return "[" + localName + "]"; 130 } 131 return "[" + localName + "=\"" + value + "\"]"; 132 } 133 } 134 | Popular Tags |