1 18 package org.apache.batik.css.engine.value.css2; 19 20 import org.apache.batik.css.engine.CSSEngine; 21 import org.apache.batik.css.engine.value.AbstractValueManager; 22 import org.apache.batik.css.engine.value.ListValue; 23 import org.apache.batik.css.engine.value.StringMap; 24 import org.apache.batik.css.engine.value.Value; 25 import org.apache.batik.css.engine.value.ValueConstants; 26 import org.apache.batik.css.engine.value.ValueManager; 27 import org.apache.batik.util.CSSConstants; 28 import org.w3c.css.sac.LexicalUnit; 29 import org.w3c.dom.DOMException ; 30 import org.w3c.dom.css.CSSPrimitiveValue; 31 32 38 public class TextDecorationManager extends AbstractValueManager { 39 40 43 protected final static StringMap values = new StringMap(); 44 static { 45 values.put(CSSConstants.CSS_BLINK_VALUE, 46 ValueConstants.BLINK_VALUE); 47 values.put(CSSConstants.CSS_LINE_THROUGH_VALUE, 48 ValueConstants.LINE_THROUGH_VALUE); 49 values.put(CSSConstants.CSS_OVERLINE_VALUE, 50 ValueConstants.OVERLINE_VALUE); 51 values.put(CSSConstants.CSS_UNDERLINE_VALUE, 52 ValueConstants.UNDERLINE_VALUE); 53 } 54 55 58 public boolean isInheritedProperty() { 59 return false; 60 } 61 62 65 public String getPropertyName() { 66 return CSSConstants.CSS_TEXT_DECORATION_PROPERTY; 67 } 68 69 72 public Value getDefaultValue() { 73 return ValueConstants.NONE_VALUE; 74 } 75 76 79 public Value createValue(LexicalUnit lu, CSSEngine engine) 80 throws DOMException { 81 switch (lu.getLexicalUnitType()) { 82 case LexicalUnit.SAC_INHERIT: 83 return ValueConstants.INHERIT_VALUE; 84 85 case LexicalUnit.SAC_IDENT: 86 if (lu.getStringValue().equalsIgnoreCase 87 (CSSConstants.CSS_NONE_VALUE)) { 88 return ValueConstants.NONE_VALUE; 89 } 90 ListValue lv = new ListValue(' '); 91 do { 92 if (lu.getLexicalUnitType() == LexicalUnit.SAC_IDENT) { 93 String s = lu.getStringValue().toLowerCase().intern(); 94 Object obj = values.get(s); 95 if (obj == null) { 96 throw createInvalidIdentifierDOMException 97 (lu.getStringValue()); 98 } 99 lv.append((Value)obj); 100 lu = lu.getNextLexicalUnit(); 101 } else { 102 throw createInvalidLexicalUnitDOMException 103 (lu.getLexicalUnitType()); 104 } 105 106 } while (lu != null); 107 return lv; 108 } 109 throw createInvalidLexicalUnitDOMException 110 (lu.getLexicalUnitType()); 111 } 112 113 117 public Value createStringValue(short type, String value, CSSEngine engine) 118 throws DOMException { 119 if (type != CSSPrimitiveValue.CSS_IDENT) { 120 throw createInvalidStringTypeDOMException(type); 121 } 122 if (!value.equalsIgnoreCase(CSSConstants.CSS_NONE_VALUE)) { 123 throw createInvalidIdentifierDOMException(value); 124 } 125 return ValueConstants.NONE_VALUE; 126 } 127 128 } 129 | Popular Tags |