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 java.util.Iterator;
13: import java.util.Vector;
14: import javax.management.NotificationFilterSupport;
15: import javax.xml.namespace.QName;
16:
17: import org.apache.axis.Constants;
18: import org.apache.axis.encoding.SerializationContext;
19: import org.apache.axis.wsdl.fromJava.Types;
20: import org.w3c.dom.Element;
21: import org.xml.sax.Attributes;
22:
23: /**
24: * @version $Revision: 1.3 $
25: */
26: public class NotificationFilterSupportSer extends AxisSerializer {
27: static final String TYPE = "NotificationFilterSupport";
28: static final String NOTIFICATION_TYPE = "notificationType";
29: private static final QName NOTIFICATION_TYPE_QNAME = new QName("",
30: NOTIFICATION_TYPE);
31:
32: public void serialize(QName name, Attributes attributes,
33: Object value, SerializationContext context)
34: throws IOException {
35: NotificationFilterSupport filter = (NotificationFilterSupport) value;
36: context.startElement(name, attributes);
37: onSerialize(context, filter);
38: context.endElement();
39: }
40:
41: protected void onSerialize(SerializationContext context,
42: NotificationFilterSupport filter) throws IOException {
43: Vector types = filter.getEnabledTypes();
44: for (Iterator i = types.iterator(); i.hasNext();) {
45: String type = (String) i.next();
46: context.serialize(NOTIFICATION_TYPE_QNAME, null, type);
47: }
48: }
49:
50: public Element writeSchema(Class javaType, Types types)
51: throws Exception {
52: Element complexType = types.createElement(SCHEMA_COMPLEX_TYPE);
53: complexType.setAttribute("name", TYPE);
54: types.writeSchemaElement(Constants.SOAP_VECTOR, complexType);
55: Element allElement = types.createElement(SCHEMA_ALL);
56: complexType.appendChild(allElement);
57: Element element = types.createElement(SCHEMA_ELEMENT);
58: element.setAttribute("name", NOTIFICATION_TYPE);
59: element.setAttribute("minOccurs", "0");
60: element.setAttribute("maxOccurs", "unbounded");
61: element.setAttribute("type", Constants.XSD_STRING
62: .getLocalPart());
63: allElement.appendChild(element);
64: return complexType;
65: }
66: }
|