1 package test.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 18 20 28 public void serialize(QName name, Attributes attributes, 29 Object value, SerializationContext context) 30 throws IOException 31 { 32 if (!(value instanceof Data)) 33 throw new IOException ("Can't serialize a " + value.getClass().getName() + " with a DataSerializer."); 34 Data data = (Data)value; 35 36 context.startElement(name, attributes); 37 context.serialize(new QName ("", STRINGMEMBER), null, data.stringMember); 38 context.serialize(new QName ("", FLOATMEMBER), null, data.floatMember); 39 context.endElement(); 40 } 41 public String getMechanismType() { return Constants.AXIS_SAX; } 42 43 public Element writeSchema(Class javaType, Types types) throws Exception { 44 return null; 45 } 46 } 47 | Popular Tags |