1 8 9 package mx4j.tools.remote.soap.axis.ser; 10 11 import java.io.IOException ; 12 import javax.management.remote.NotificationResult ; 13 import javax.xml.namespace.QName ; 14 15 import org.apache.axis.encoding.SerializationContext; 16 import org.apache.axis.encoding.XMLType; 17 import org.apache.axis.wsdl.fromJava.Types; 18 import org.w3c.dom.Element ; 19 import org.xml.sax.Attributes ; 20 21 24 public class NotificationResultSer extends AxisSerializer 25 { 26 static final String TYPE = "NotificationResult"; 27 static final String EARLIEST_NUMBER = "earliestSequenceNumber"; 28 static final String NEXT_NUMBER = "nextSequenceNumber"; 29 static final String NOTIFICATIONS = "targetedNotifications"; 30 private static final QName EARLIEST_NUMBER_QNAME = new QName ("", EARLIEST_NUMBER); 31 private static final QName NEXT_NUMBER_QNAME = new QName ("", NEXT_NUMBER); 32 private static final QName NOTIFICATIONS_QNAME = new QName ("", NOTIFICATIONS); 33 34 public void serialize(QName name, Attributes attributes, Object value, SerializationContext context) throws IOException 35 { 36 NotificationResult notificationResult = (NotificationResult )value; 37 context.startElement(name, attributes); 38 context.serialize(EARLIEST_NUMBER_QNAME, null, new Long (notificationResult.getEarliestSequenceNumber())); 39 context.serialize(NEXT_NUMBER_QNAME, null, new Long (notificationResult.getNextSequenceNumber())); 40 context.serialize(NOTIFICATIONS_QNAME, null, notificationResult.getTargetedNotifications()); 41 context.endElement(); 42 } 43 44 public Element writeSchema(Class aClass, Types types) throws Exception 45 { 46 Element complexType = types.createElement(SCHEMA_COMPLEX_TYPE); 47 complexType.setAttribute("name", TYPE); 48 Element allElement = types.createElement(SCHEMA_ALL); 49 complexType.appendChild(allElement); 50 51 Element typeElement = types.createElement(SCHEMA_ELEMENT); 52 typeElement.setAttribute("name", EARLIEST_NUMBER); 53 typeElement.setAttribute("type", XMLType.XSD_LONG.getLocalPart()); 54 allElement.appendChild(typeElement); 55 56 Element sourceElement = types.createElement(SCHEMA_ELEMENT); 57 sourceElement.setAttribute("name", NEXT_NUMBER); 58 sourceElement.setAttribute("type", XMLType.XSD_LONG.getLocalPart()); 59 allElement.appendChild(sourceElement); 60 61 Element sequenceNumberElement = types.createElement(SCHEMA_ELEMENT); 62 sequenceNumberElement.setAttribute("name", NOTIFICATIONS); 63 sequenceNumberElement.setAttribute("type", XMLType.SOAP_ARRAY.getLocalPart()); 64 allElement.appendChild(sequenceNumberElement); 65 66 return complexType; 67 } 68 } 69 | Popular Tags |