1 18 package org.apache.batik.css.engine.value; 19 20 import org.w3c.dom.DOMException ; 21 import org.w3c.dom.css.CSSPrimitiveValue; 22 23 29 public class StringValue extends AbstractValue { 30 31 34 public static String getCssText(short type, String value) { 35 switch (type) { 36 case CSSPrimitiveValue.CSS_URI: 37 return "url(" + value + ")"; 38 39 case CSSPrimitiveValue.CSS_STRING: 40 char q = (value.indexOf('"') != -1) ? '\'' : '"'; 41 return q + value + q; 42 } 43 return value; 44 } 45 46 49 protected String value; 50 51 54 protected short unitType; 55 56 59 public StringValue(short type, String s) { 60 unitType = type; 61 value = s; 62 } 63 64 67 public short getPrimitiveType() { 68 return unitType; 69 } 70 71 75 public boolean equals(Object obj) { 76 if (obj == null || !(obj instanceof StringValue)) { 77 return false; 78 } 79 StringValue v = (StringValue)obj; 80 if (unitType != v.unitType) { 81 return false; 82 } 83 return value.equals(v.value); 84 } 85 86 89 public String getCssText() { 90 return getCssText(unitType, value); 91 } 92 93 99 public String getStringValue() throws DOMException { 100 return value; 101 } 102 103 106 public String toString() { 107 return getCssText(); 108 } 109 } 110 | Popular Tags |