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 javax.management.Attribute;
13: import javax.xml.namespace.QName;
14:
15: import org.apache.axis.encoding.SerializationContext;
16: import org.apache.axis.encoding.XMLType;
17: import org.apache.axis.wsdl.fromJava.Types;
18: import org.w3c.dom.Element;
19: import org.xml.sax.Attributes;
20:
21: /**
22: * @version $Revision: 1.8 $
23: */
24: public class AttributeSer extends AxisSerializer {
25: static final String TYPE = "Attribute";
26: static final String NAME = "name";
27: static final String VALUE = "value";
28: private static final QName NAME_QNAME = new QName("", NAME);
29: private static final QName VALUE_QNAME = new QName("", VALUE);
30:
31: public void serialize(QName name, Attributes attributes,
32: Object value, SerializationContext context)
33: throws IOException {
34: Attribute attribute = (Attribute) value;
35: context.startElement(name, attributes);
36: context.serialize(NAME_QNAME, null, attribute.getName());
37: context.serialize(VALUE_QNAME, null, attribute.getValue());
38: context.endElement();
39: }
40:
41: public Element writeSchema(Class aClass, Types types)
42: throws Exception {
43: Element complexType = types.createElement(SCHEMA_COMPLEX_TYPE);
44: complexType.setAttribute("name", TYPE);
45: Element allElement = types.createElement(SCHEMA_ALL);
46: complexType.appendChild(allElement);
47:
48: Element nameElement = types.createElement(SCHEMA_ELEMENT);
49: nameElement.setAttribute("name", NAME);
50: nameElement.setAttribute("type", XMLType.XSD_STRING
51: .getLocalPart());
52: allElement.appendChild(nameElement);
53:
54: Element valueElement = types.createElement(SCHEMA_ELEMENT);
55: valueElement.setAttribute("name", VALUE);
56: valueElement.setAttribute("type", XMLType.XSD_ANYTYPE
57: .getLocalPart());
58: allElement.appendChild(valueElement);
59:
60: return complexType;
61: }
62: }
|