KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > mx4j > tools > remote > soap > axis > ser > NotificationFilterSupportSer


1 /*
2  * Copyright (C) The MX4J Contributors.
3  * All rights reserved.
4  *
5  * This software is distributed under the terms of the MX4J License version 1.0.
6  * See the terms of the MX4J License in the documentation provided with this software.
7  */

8
9 package mx4j.tools.remote.soap.axis.ser;
10
11 import java.io.IOException JavaDoc;
12 import java.util.Iterator JavaDoc;
13 import java.util.Vector JavaDoc;
14 import javax.management.NotificationFilterSupport JavaDoc;
15 import javax.xml.namespace.QName JavaDoc;
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 JavaDoc;
21 import org.xml.sax.Attributes JavaDoc;
22
23 /**
24  * @version $Revision: 1.3 $
25  */

26 public class NotificationFilterSupportSer extends AxisSerializer
27 {
28    static final String JavaDoc TYPE = "NotificationFilterSupport";
29    static final String JavaDoc NOTIFICATION_TYPE = "notificationType";
30    private static final QName JavaDoc NOTIFICATION_TYPE_QNAME = new QName JavaDoc("", NOTIFICATION_TYPE);
31
32    public void serialize(QName JavaDoc name, Attributes JavaDoc attributes, Object JavaDoc value, SerializationContext context) throws IOException JavaDoc
33    {
34       NotificationFilterSupport JavaDoc filter = (NotificationFilterSupport JavaDoc)value;
35       context.startElement(name, attributes);
36       onSerialize(context, filter);
37       context.endElement();
38    }
39
40    protected void onSerialize(SerializationContext context, NotificationFilterSupport JavaDoc filter) throws IOException JavaDoc
41    {
42       Vector JavaDoc types = filter.getEnabledTypes();
43       for (Iterator JavaDoc i = types.iterator(); i.hasNext();)
44       {
45          String JavaDoc type = (String JavaDoc)i.next();
46          context.serialize(NOTIFICATION_TYPE_QNAME, null, type);
47       }
48    }
49
50    public Element JavaDoc writeSchema(Class JavaDoc javaType, Types types) throws Exception JavaDoc
51    {
52       Element JavaDoc complexType = types.createElement(SCHEMA_COMPLEX_TYPE);
53       complexType.setAttribute("name", TYPE);
54       types.writeSchemaElement(Constants.SOAP_VECTOR, complexType);
55       Element JavaDoc allElement = types.createElement(SCHEMA_ALL);
56       complexType.appendChild(allElement);
57       Element JavaDoc 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.getLocalPart());
62       allElement.appendChild(element);
63       return complexType;
64    }
65 }
66
Popular Tags