01: package tableapp.business.axis;
02:
03: /**
04: * <p>Title: </p>
05: * <p>Description: </p>
06: * <p>Copyright: Copyright (c) 2005</p>
07: * <p>Company: </p>
08: * @author not attributable
09: * @version 1.0
10: */
11:
12: import org.apache.axis.Constants;
13: import org.apache.axis.encoding.DeserializationContext;
14: import org.apache.axis.encoding.Deserializer;
15: import org.apache.axis.encoding.DeserializerImpl;
16: import org.apache.axis.encoding.FieldTarget;
17: import org.apache.axis.message.SOAPHandler;
18: import org.xml.sax.Attributes;
19: import org.xml.sax.SAXException;
20:
21: import javax.xml.namespace.QName;
22: import java.util.Hashtable;
23: import tableapp.spec.Access;
24: import tableapp.business.AccessImpl;
25:
26: import java.util.Date;
27:
28: public class AccessDeser extends DeserializerImpl {
29:
30: public static final String INTMEMBER = "noAccesses";
31: public static final String DATEMEMBER = "sDate";
32:
33: private Hashtable typesByMemberName = new Hashtable();
34:
35: public AccessDeser() {
36: typesByMemberName.put(INTMEMBER, Constants.SOAP_INT);
37: typesByMemberName.put(DATEMEMBER, Constants.XSD_STRING);
38: value = (Access) new AccessImpl();
39: ((Access) value).setNoAccesses(9);
40: //((Access)value).setDate(new Date((long)12345678));
41: }
42:
43: /** DESERIALIZER STUFF - event handlers
44: */
45:
46: /**
47: * This method is invoked when an element start tag is encountered.
48: * @param namespace is the namespace of the element
49: * @param localName is the name of the element
50: * @param prefix is the element's prefix
51: * @param attributes are the attributes on the element...used to get the type
52: * @param context is the DeserializationContext
53: */
54: public SOAPHandler onStartChild(String namespace, String localName,
55: String prefix, Attributes attributes,
56: DeserializationContext context) throws SAXException {
57: QName typeQName = (QName) typesByMemberName.get(localName);
58: if (typeQName == null)
59: throw new SAXException("Invalid element in Data struct - "
60: + localName);
61:
62: // These can come in either order.
63: Deserializer dSer = context.getDeserializerForType(typeQName);
64: try {
65: dSer.registerValueTarget(new FieldTarget(value, localName));
66: } catch (NoSuchFieldException e) {
67: throw new SAXException(e);
68: }
69:
70: if (dSer == null)
71: throw new SAXException("No deserializer for a " + typeQName
72: + "???");
73:
74: return (SOAPHandler) dSer;
75: }
76: }
|