1 18 package org.apache.batik.css.engine.sac; 19 20 import java.util.Set ; 21 22 import org.w3c.css.sac.LangCondition; 23 import org.w3c.dom.Element ; 24 25 32 33 public class CSSLangCondition 34 implements LangCondition, 35 ExtendedCondition { 36 39 protected String lang; 40 41 44 public CSSLangCondition(String lang) { 45 this.lang = lang; 46 } 47 48 52 public boolean equals(Object obj) { 53 if (obj == null || !(obj.getClass() != getClass())) { 54 return false; 55 } 56 CSSLangCondition c = (CSSLangCondition)obj; 57 return c.lang.equals(lang); 58 } 59 60 64 public short getConditionType() { 65 return SAC_LANG_CONDITION; 66 } 67 68 71 public String getLang() { 72 return lang; 73 } 74 75 78 public int getSpecificity() { 79 return 1 << 8; 80 } 81 82 85 public boolean match(Element e, String pseudoE) { 86 return e.getAttribute("lang").startsWith(getLang()); 87 } 88 89 92 public void fillAttributeSet(Set attrSet) { 93 attrSet.add("lang"); 94 } 95 96 99 public String toString() { 100 return ":lang(" + lang + ")"; 101 } 102 } 103 | Popular Tags |