View Javadoc

1   package org.vectomatic.dom.svg;
2   
3   /**
4    * Class for a CSS value list
5    * @author laaglu
6    */
7   public class OMCSSValueList extends OMCSSValue {
8   	protected OMCSSValue[] items;
9   	/**
10  	 * Constructor
11  	 * @param items The items in the value list
12  	 */
13  	public OMCSSValueList(OMCSSValue[] items, String cssText) {
14  		super(CSS_VALUE_LIST);
15  		this.items = items;
16  		this.cssText = cssText;
17  	}
18  	
19  	/**
20  	 * Returns the number of CSSValues in the list. The range of valid 
21  	 * values of the indices is 0 to length-1 inclusive.
22  	 * @return
23  	 * The number of CSSValues in the list.
24  	 */
25  	public int getLength() {
26  		return items != null ? items.length : 0;
27  	}
28  	/**
29  	 * Used to retrieve an {@link OMCSSValue} by ordinal index. 
30  	 * The order in this collection represents the order of the values 
31  	 * in the CSS style property. If index is greater than or equal to 
32  	 * the number of values in the list, this returns null.
33  	 * @param index Index into the collection.
34  	 * @return an OMCSSValue
35  	 */
36  	public OMCSSValue getItem(int index) {
37  		return (items != null && index >= 0 && index < items.length) ? items[index] : null;
38  	}
39  
40  	@Override
41  	public String getDescription() {
42  		StringBuilder builder = new StringBuilder("OMCSSValueList(cssValueType=");
43  		builder.append(cssValueType);
44  		builder.append(", cssText=");
45  		builder.append(cssText);
46  		builder.append("{");
47  		if (items != null) {
48  			for (int i = 0; i < items.length; i ++) {
49  				if (i > 0) {
50  					builder.append(",");
51  				}
52  				builder.append(items[i].getDescription());
53  			}
54  		}
55  		builder.append("})");
56  		return builder.toString();
57  	}
58  }