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 javax.management.relation.RelationTypeSupport;
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.encoding.XMLType;
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 RelationTypeSupportSer extends AxisSerializer {
27: static final String TYPE = "RelationTypeSupport";
28: static final String NAME = "name";
29: static final String ROLE_INFOS = "roleInfos";
30:
31: private static final QName NAME_QNAME = new QName("", NAME);
32: private static final QName ROLE_INFOS_QNAME = new QName("",
33: ROLE_INFOS);
34:
35: public void serialize(QName name, Attributes attributes,
36: Object value, SerializationContext context)
37: throws IOException {
38: RelationTypeSupport relTypeSup = (RelationTypeSupport) value;
39: context.startElement(name, attributes);
40: context.serialize(NAME_QNAME, null, relTypeSup
41: .getRelationTypeName());
42: for (Iterator i = relTypeSup.getRoleInfos().iterator(); i
43: .hasNext();) {
44: context.serialize(Constants.QNAME_LITERAL_ITEM, null, i
45: .next());
46: }
47: context.endElement();
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: Element allElement = types.createElement(SCHEMA_ALL);
55: complexType.appendChild(allElement);
56:
57: Element nameElement = types.createElement(SCHEMA_ELEMENT);
58: nameElement.setAttribute("name", NAME);
59: nameElement.setAttribute("type", XMLType.XSD_STRING
60: .getLocalPart());
61: allElement.appendChild(nameElement);
62:
63: types.writeSchemaElement(Constants.SOAP_VECTOR, complexType);
64: Element sequence = types.createElement(SCHEMA_SEQUENCE);
65: complexType.appendChild(sequence);
66: Element element = types.createElement(SCHEMA_ELEMENT);
67: element.setAttribute("name", Constants.QNAME_LITERAL_ITEM
68: .getLocalPart());
69: element.setAttribute("minOccurs", "0");
70: element.setAttribute("maxOccurs", "unbounded");
71: element.setAttribute("type", RoleInfoSer.TYPE);
72: sequence.appendChild(element);
73:
74: return complexType;
75: }
76:
77: }
|