01: package com.jeta.forms.store.xml.parser;
02:
03: import java.util.ArrayList;
04:
05: import org.xml.sax.SAXException;
06:
07: import com.jeta.forms.store.jml.dom.JMLAttributes;
08:
09: public class ObjectArrayHandler extends ObjectHandler {
10:
11: private ArrayList m_items = new ArrayList();
12:
13: protected Object instantiateObject(JMLAttributes attribs)
14: throws InstantiationException, IllegalAccessException,
15: ClassNotFoundException {
16: String ssize = attribs.getValue("size");
17: if (ssize != null) {
18: int size = Integer.parseInt(ssize);
19: for (int index = 0; index < size; index++) {
20: m_items.add(null);
21: }
22: }
23: return m_items;
24: }
25:
26: protected void setProperty(Object key, Object value,
27: JMLAttributes attribs) throws SAXException {
28: if ("item".equalsIgnoreCase(key.toString())) {
29: String index = attribs.getValue("index");
30: if (index != null) {
31: m_items.set(Integer.parseInt(index), value);
32: } else {
33: m_items.add(value);
34: }
35: }
36: }
37:
38: public Object getObject() {
39: return m_items.toArray();
40: }
41:
42: }
|