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