KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > tableapp > business > axis > AccessDeser


1 package tableapp.business.axis;
2
3 /**
4  * <p>Title: </p>
5  * <p>Description: </p>
6  * <p>Copyright: Copyright (c) 2005</p>
7  * <p>Company: </p>
8  * @author not attributable
9  * @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 JavaDoc;
19 import org.xml.sax.SAXException JavaDoc;
20
21 import javax.xml.namespace.QName JavaDoc;
22 import java.util.Hashtable JavaDoc;
23 import tableapp.spec.Access;
24 import tableapp.business.AccessImpl;
25
26 import java.util.Date JavaDoc;
27
28 public class AccessDeser
29     extends DeserializerImpl {
30
31   public static final String JavaDoc INTMEMBER = "noAccesses";
32   public static final String JavaDoc DATEMEMBER = "sDate";
33
34   private Hashtable JavaDoc typesByMemberName = new Hashtable JavaDoc();
35
36   public AccessDeser() {
37     typesByMemberName.put(INTMEMBER, Constants.SOAP_INT);
38     typesByMemberName.put(DATEMEMBER, Constants.XSD_STRING);
39     value = (Access)new AccessImpl();
40     ( (Access) value).setNoAccesses(9);
41     //((Access)value).setDate(new Date((long)12345678));
42
}
43
44   /** DESERIALIZER STUFF - event handlers
45    */

46
47   /**
48    * This method is invoked when an element start tag is encountered.
49    * @param namespace is the namespace of the element
50    * @param localName is the name of the element
51    * @param prefix is the element's prefix
52    * @param attributes are the attributes on the element...used to get the type
53    * @param context is the DeserializationContext
54    */

55   public SOAPHandler onStartChild(String JavaDoc namespace,
56                                   String JavaDoc localName,
57                                   String JavaDoc prefix,
58                                   Attributes JavaDoc attributes,
59                                   DeserializationContext context) throws
60       SAXException JavaDoc {
61     QName JavaDoc typeQName = (QName JavaDoc) typesByMemberName.get(localName);
62     if (typeQName == null)
63       throw new SAXException JavaDoc("Invalid element in Data struct - " + localName);
64
65     // These can come in either order.
66
Deserializer dSer = context.getDeserializerForType(typeQName);
67     try {
68       dSer.registerValueTarget(new FieldTarget(value, localName));
69     }
70     catch (NoSuchFieldException JavaDoc e) {
71       throw new SAXException JavaDoc(e);
72     }
73
74     if (dSer == null)
75       throw new SAXException JavaDoc("No deserializer for a " + typeQName + "???");
76
77     return (SOAPHandler) dSer;
78   }
79 }
Popular Tags