1 18 package org.apache.batik.css.engine.value.svg; 19 20 import org.apache.batik.css.engine.CSSEngine; 21 import org.apache.batik.css.engine.value.LengthManager; 22 import org.apache.batik.css.engine.value.Value; 23 import org.apache.batik.css.engine.value.ValueManager; 24 import org.apache.batik.util.CSSConstants; 25 import org.w3c.css.sac.LexicalUnit; 26 import org.w3c.dom.DOMException ; 27 import org.w3c.dom.css.CSSPrimitiveValue; 28 29 35 public class SpacingManager extends LengthManager { 36 37 40 protected String property; 41 42 45 public SpacingManager(String prop) { 46 property = prop; 47 } 48 49 50 53 public boolean isInheritedProperty() { 54 return true; 55 } 56 57 60 public String getPropertyName() { 61 return property; 62 } 63 64 67 public Value getDefaultValue() { 68 return SVGValueConstants.NORMAL_VALUE; 69 } 70 71 74 public Value createValue(LexicalUnit lu, CSSEngine engine) 75 throws DOMException { 76 switch (lu.getLexicalUnitType()) { 77 case LexicalUnit.SAC_INHERIT: 78 return SVGValueConstants.INHERIT_VALUE; 79 80 case LexicalUnit.SAC_IDENT: 81 if (lu.getStringValue().equalsIgnoreCase 82 (CSSConstants.CSS_NORMAL_VALUE)) { 83 return SVGValueConstants.NORMAL_VALUE; 84 } 85 throw createInvalidIdentifierDOMException(lu.getStringValue()); 86 } 87 return super.createValue(lu, engine); 88 } 89 90 94 public Value createStringValue(short type, String value, CSSEngine engine) 95 throws DOMException { 96 if (type != CSSPrimitiveValue.CSS_IDENT) { 97 throw createInvalidStringTypeDOMException(type); 98 } 99 if (value.equalsIgnoreCase(CSSConstants.CSS_NORMAL_VALUE)) { 100 return SVGValueConstants.NORMAL_VALUE; 101 } 102 throw createInvalidIdentifierDOMException(value); 103 } 104 105 109 protected int getOrientation() { 110 return BOTH_ORIENTATION; 111 } 112 } 113 | Popular Tags |