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.Set;
14: import javax.xml.namespace.QName;
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;
20: import org.xml.sax.Attributes;
21:
22: /**
23: * @version $Revision: 1.5 $
24: */
25: public class SetSer extends AxisSerializer {
26: static final String TYPE = "Set";
27:
28: public void serialize(QName name, Attributes attributes,
29: Object value, SerializationContext context)
30: throws IOException {
31: Set set = (Set) value;
32: context.startElement(name, attributes);
33: for (Iterator i = set.iterator(); i.hasNext();) {
34: Object item = i.next();
35: context.serialize(Constants.QNAME_LITERAL_ITEM, null, item);
36: }
37: context.endElement();
38: }
39:
40: public Element writeSchema(Class javaType, Types types)
41: throws Exception {
42: Element complexType = types.createElement(SCHEMA_COMPLEX_TYPE);
43: complexType.setAttribute("name", TYPE);
44: types.writeSchemaElement(Constants.SOAP_VECTOR, complexType);
45: Element allElement = types.createElement(SCHEMA_ALL);
46: complexType.appendChild(allElement);
47: Element element = types.createElement(SCHEMA_ELEMENT);
48: element.setAttribute("name", Constants.QNAME_LITERAL_ITEM
49: .getLocalPart());
50: element.setAttribute("minOccurs", "0");
51: element.setAttribute("maxOccurs", "unbounded");
52: element.setAttribute("type", Constants.XSD_ANYTYPE
53: .getLocalPart());
54: allElement.appendChild(element);
55: return complexType;
56: }
57: }
|