KickJava   Java API By Example, From Geeks To Geeks.

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


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.Set JavaDoc;
14 import javax.xml.namespace.QName JavaDoc;
15
16 import org.apache.axis.Constants;
17 import org.apache.axis.encoding.SerializationContext;
18 import org.apache.axis.wsdl.fromJava.Types;
19 import org.w3c.dom.Element JavaDoc;
20 import org.xml.sax.Attributes JavaDoc;
21
22 /**
23  * @version $Revision: 1.5 $
24  */

25 public class SetSer extends AxisSerializer
26 {
27    static final String JavaDoc TYPE = "Set";
28
29    public void serialize(QName JavaDoc name, Attributes JavaDoc attributes, Object JavaDoc value, SerializationContext context) throws IOException JavaDoc
30    {
31       Set JavaDoc set = (Set JavaDoc)value;
32       context.startElement(name, attributes);
33       for (Iterator JavaDoc i = set.iterator(); i.hasNext();)
34       {
35          Object JavaDoc item = i.next();
36          context.serialize(Constants.QNAME_LITERAL_ITEM, null, item);
37       }
38       context.endElement();
39    }
40
41    public Element JavaDoc writeSchema(Class JavaDoc javaType, Types types) throws Exception JavaDoc
42    {
43       Element JavaDoc complexType = types.createElement(SCHEMA_COMPLEX_TYPE);
44       complexType.setAttribute("name", TYPE);
45       types.writeSchemaElement(Constants.SOAP_VECTOR, complexType);
46       Element JavaDoc allElement = types.createElement(SCHEMA_ALL);
47       complexType.appendChild(allElement);
48       Element JavaDoc element = types.createElement(SCHEMA_ELEMENT);
49       element.setAttribute("name", Constants.QNAME_LITERAL_ITEM.getLocalPart());
50       element.setAttribute("minOccurs", "0");
51       element.setAttribute("maxOccurs", "unbounded");
52       element.setAttribute("type", Constants.XSD_ANYTYPE.getLocalPart());
53       allElement.appendChild(element);
54       return complexType;
55    }
56 }
57
Popular Tags