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