1
19 package org.apache.batik.css.engine.value.css2;
20
21 import org.apache.batik.css.engine.CSSEngine;
22 import org.apache.batik.css.engine.value.AbstractValueManager;
23 import org.apache.batik.css.engine.value.ListValue;
24 import org.apache.batik.css.engine.value.StringMap;
25 import org.apache.batik.css.engine.value.Value;
26 import org.apache.batik.css.engine.value.ValueConstants;
27 import org.apache.batik.css.engine.value.ValueManager;
28 import org.apache.batik.util.CSSConstants;
29 import org.apache.batik.util.SVGTypes;
30 import org.w3c.css.sac.LexicalUnit;
31 import org.w3c.dom.DOMException;
32 import org.w3c.dom.css.CSSPrimitiveValue;
33
34
40 public class TextDecorationManager extends AbstractValueManager {
41
42
45 protected static final StringMap values = new StringMap();
46 static {
47 values.put(CSSConstants.CSS_BLINK_VALUE,
48 ValueConstants.BLINK_VALUE);
49 values.put(CSSConstants.CSS_LINE_THROUGH_VALUE,
50 ValueConstants.LINE_THROUGH_VALUE);
51 values.put(CSSConstants.CSS_OVERLINE_VALUE,
52 ValueConstants.OVERLINE_VALUE);
53 values.put(CSSConstants.CSS_UNDERLINE_VALUE,
54 ValueConstants.UNDERLINE_VALUE);
55 }
56
57
60 public boolean isInheritedProperty() {
61 return false;
62 }
63
64
67 public boolean isAnimatableProperty() {
68 return true;
69 }
70
71
74 public boolean isAdditiveProperty() {
75 return false;
76 }
77
78
81 public int getPropertyType() {
82 return SVGTypes.TYPE_IDENT_LIST;
83 }
84
85
88 public String getPropertyName() {
89 return CSSConstants.CSS_TEXT_DECORATION_PROPERTY;
90 }
91
92
95 public Value getDefaultValue() {
96 return ValueConstants.NONE_VALUE;
97 }
98
99
102 public Value createValue(LexicalUnit lu, CSSEngine engine)
103 throws DOMException {
104 switch (lu.getLexicalUnitType()) {
105 case LexicalUnit.SAC_INHERIT:
106 return ValueConstants.INHERIT_VALUE;
107
108 case LexicalUnit.SAC_IDENT:
109 if (lu.getStringValue().equalsIgnoreCase
110 (CSSConstants.CSS_NONE_VALUE)) {
111 return ValueConstants.NONE_VALUE;
112 }
113 ListValue lv = new ListValue(' ');
114 do {
115 if (lu.getLexicalUnitType() == LexicalUnit.SAC_IDENT) {
116 String s = lu.getStringValue().toLowerCase().intern();
117 Object obj = values.get(s);
118 if (obj == null) {
119 throw createInvalidIdentifierDOMException
120 (lu.getStringValue());
121 }
122 lv.append((Value)obj);
123 lu = lu.getNextLexicalUnit();
124 } else {
125 throw createInvalidLexicalUnitDOMException
126 (lu.getLexicalUnitType());
127 }
128
129 } while (lu != null);
130 return lv;
131 }
132 throw createInvalidLexicalUnitDOMException
133 (lu.getLexicalUnitType());
134 }
135
136
140 public Value createStringValue(short type, String value, CSSEngine engine)
141 throws DOMException {
142 if (type != CSSPrimitiveValue.CSS_IDENT) {
143 throw createInvalidStringTypeDOMException(type);
144 }
145 if (!value.equalsIgnoreCase(CSSConstants.CSS_NONE_VALUE)) {
146 throw createInvalidIdentifierDOMException(value);
147 }
148 return ValueConstants.NONE_VALUE;
149 }
150
151 }
152