1 18 package org.apache.batik.css.engine.value; 19 20 import org.w3c.dom.DOMException ; 21 import org.w3c.dom.css.CSSValue; 22 23 29 public class ListValue extends AbstractValue { 30 31 34 protected int length; 35 36 39 protected Value[] items = new Value[5]; 40 41 44 protected char separator = ','; 45 46 49 public ListValue() { 50 } 51 52 55 public ListValue(char s) { 56 separator = s; 57 } 58 59 62 public char getSeparatorChar() { 63 return separator; 64 } 65 66 69 public short getCssValueType() { 70 return CSSValue.CSS_VALUE_LIST; 71 } 72 73 76 public String getCssText() { 77 StringBuffer sb = new StringBuffer (); 78 if (length > 0) { 79 sb.append(items[0].getCssText()); 80 } 81 for (int i = 1; i < length; i++) { 82 sb.append(separator); 83 sb.append(items[i].getCssText()); 84 } 85 return sb.toString(); 86 } 87 88 91 public int getLength() throws DOMException { 92 return length; 93 } 94 95 98 public Value item(int index) throws DOMException { 99 return items[index]; 100 } 101 102 105 public String toString() { 106 return getCssText(); 107 } 108 109 112 public void append(Value v) { 113 if (length == items.length) { 114 Value[] t = new Value[length * 2]; 115 for (int i = 0; i < length; i++) { 116 t[i] = items[i]; 117 } 118 items = t; 119 } 120 items[length++] = v; 121 } 122 } 123 | Popular Tags |