01: package com.jeta.forms.store.xml.parser;
02:
03: import java.util.HashMap;
04:
05: import org.xml.sax.SAXException;
06:
07: import com.jeta.forms.store.jml.dom.JMLAttributes;
08:
09: public class HashMapHandler extends ObjectHandler {
10:
11: private Object m_current_key;
12: private Object m_current_value;
13:
14: public void setProperty(Object keyName, Object value,
15: JMLAttributes attribs) throws SAXException {
16: if ("key".equalsIgnoreCase(keyName.toString())) {
17: m_current_key = value;
18: } else if ("value".equalsIgnoreCase(keyName.toString())) {
19: m_current_value = value;
20: }
21: }
22:
23: /**
24: * XMLDeserializer implementation <object classname="java.util.HashMap">
25: * <item> <property name="key"><object>,,,</object></property> <property
26: * name="value"><object>,,,</object></property> </item> ... <item>
27: * </item> </object>
28: */
29: public void startElement(XMLNodeContext ctx) throws SAXException {
30: if ("item".equalsIgnoreCase(ctx.getQualifiedName())) {
31: m_current_key = null;
32: m_current_value = null;
33: } else {
34: super .startElement(ctx);
35: }
36: }
37:
38: public void endElement(XMLNodeContext ctx) throws SAXException {
39: if ("item".equalsIgnoreCase(ctx.getQualifiedName())) {
40: ((HashMap) getObject()).put(m_current_key, m_current_value);
41: } else {
42: super.endElement(ctx);
43: }
44: }
45:
46: }
|