01: /*
02: * Copyright (C) The MX4J Contributors.
03: * All rights reserved.
04: *
05: * This software is distributed under the terms of the MX4J License version 1.0.
06: * See the terms of the MX4J License in the documentation provided with this software.
07: */
08:
09: 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: /**
22: * @version $Revision: 1.4 $
23: */
24: public class NotificationResultSer extends AxisSerializer {
25: static final String TYPE = "NotificationResult";
26: static final String EARLIEST_NUMBER = "earliestSequenceNumber";
27: static final String NEXT_NUMBER = "nextSequenceNumber";
28: static final String NOTIFICATIONS = "targetedNotifications";
29: private static final QName EARLIEST_NUMBER_QNAME = new QName("",
30: EARLIEST_NUMBER);
31: private static final QName NEXT_NUMBER_QNAME = new QName("",
32: NEXT_NUMBER);
33: private static final QName NOTIFICATIONS_QNAME = new QName("",
34: NOTIFICATIONS);
35:
36: public void serialize(QName name, Attributes attributes,
37: Object value, SerializationContext context)
38: throws IOException {
39: NotificationResult notificationResult = (NotificationResult) value;
40: context.startElement(name, attributes);
41: context.serialize(EARLIEST_NUMBER_QNAME, null, new Long(
42: notificationResult.getEarliestSequenceNumber()));
43: context.serialize(NEXT_NUMBER_QNAME, null, new Long(
44: notificationResult.getNextSequenceNumber()));
45: context.serialize(NOTIFICATIONS_QNAME, null, notificationResult
46: .getTargetedNotifications());
47: context.endElement();
48: }
49:
50: public Element writeSchema(Class aClass, Types types)
51: throws Exception {
52: Element complexType = types.createElement(SCHEMA_COMPLEX_TYPE);
53: complexType.setAttribute("name", TYPE);
54: Element allElement = types.createElement(SCHEMA_ALL);
55: complexType.appendChild(allElement);
56:
57: Element typeElement = types.createElement(SCHEMA_ELEMENT);
58: typeElement.setAttribute("name", EARLIEST_NUMBER);
59: typeElement.setAttribute("type", XMLType.XSD_LONG
60: .getLocalPart());
61: allElement.appendChild(typeElement);
62:
63: Element sourceElement = types.createElement(SCHEMA_ELEMENT);
64: sourceElement.setAttribute("name", NEXT_NUMBER);
65: sourceElement.setAttribute("type", XMLType.XSD_LONG
66: .getLocalPart());
67: allElement.appendChild(sourceElement);
68:
69: Element sequenceNumberElement = types
70: .createElement(SCHEMA_ELEMENT);
71: sequenceNumberElement.setAttribute("name", NOTIFICATIONS);
72: sequenceNumberElement.setAttribute("type", XMLType.SOAP_ARRAY
73: .getLocalPart());
74: allElement.appendChild(sequenceNumberElement);
75:
76: return complexType;
77: }
78: }
|