1 18 package org.apache.batik.css.engine.value; 19 20 import org.apache.batik.css.engine.CSSEngine; 21 import org.w3c.css.sac.LexicalUnit; 22 import org.w3c.dom.DOMException ; 23 import org.w3c.dom.css.CSSPrimitiveValue; 24 25 32 public abstract class IdentifierManager extends AbstractValueManager { 33 34 37 public Value createValue(LexicalUnit lu, CSSEngine engine) 38 throws DOMException { 39 switch (lu.getLexicalUnitType()) { 40 case LexicalUnit.SAC_INHERIT: 41 return ValueConstants.INHERIT_VALUE; 42 43 case LexicalUnit.SAC_IDENT: 44 String s = lu.getStringValue().toLowerCase().intern(); 45 Object v = getIdentifiers().get(s); 46 if (v == null) { 47 throw createInvalidIdentifierDOMException(lu.getStringValue()); 48 } 49 return (Value)v; 50 51 default: 52 throw createInvalidLexicalUnitDOMException 53 (lu.getLexicalUnitType()); 54 } 55 } 56 57 61 public Value createStringValue(short type, String value, CSSEngine engine) 62 throws DOMException { 63 if (type != CSSPrimitiveValue.CSS_IDENT) { 64 throw createInvalidStringTypeDOMException(type); 65 } 66 Object v = getIdentifiers().get(value.toLowerCase().intern()); 67 if (v == null) { 68 throw createInvalidIdentifierDOMException(value); 69 } 70 return (Value)v; 71 } 72 73 77 public abstract StringMap getIdentifiers(); 78 } 79 | Popular Tags |