Debian Codegraph @

samples/encoding/DataSer.java

raw
1 package samples.encoding;
2
3 import org.apache.axis.Constants;
4 import org.apache.axis.encoding.SerializationContext;
5 import org.apache.axis.encoding.Serializer;
6 import org.apache.axis.wsdl.fromJava.Types;
7 import org.w3c.dom.Element;
8 import org.xml.sax.Attributes;
9
10 import javax.xml.namespace.QName;
11 import java.io.IOException;
12
13 public class DataSer implements Serializer
14 {
15 public static final String STRINGMEMBER = "stringMember";
16 public static final String FLOATMEMBER = "floatMember";
17 public static final String DATAMEMBER = "dataMember";
18 public static final QName myTypeQName = new QName("typeNS", "Data");
19
20 /** SERIALIZER STUFF
21 */
22 /**
23 * Serialize an element named name, with the indicated attributes
24 * and value.
25 * @param name is the element name
26 * @param attributes are the attributes...serialize is free to add more.
27 * @param value is the value
28 * @param context is the SerializationContext
29 */
30 public void serialize(QName name, Attributes attributes,
31 Object value, SerializationContext context)
32 throws IOException
33 {
34 if (!(value instanceof Data))
35 throw new IOException("Can't serialize a " + value.getClass().getName() + " with a DataSerializer.");
36 Data data = (Data)value;
37
38 context.startElement(name, attributes);
39 context.serialize(new QName("", STRINGMEMBER), null, data.stringMember);
40 context.serialize(new QName("", FLOATMEMBER), null, data.floatMember);
41 context.serialize(new QName("", DATAMEMBER), null, data.dataMember);
42 context.endElement();
43 }
44 public String getMechanismType() { return Constants.AXIS_SAX; }
45
46 public Element writeSchema(Class javaType, Types types) throws Exception {
47 return null;
48 }
49 }