001: /*
002: * Copyright (C) The MX4J Contributors.
003: * All rights reserved.
004: *
005: * This software is distributed under the terms of the MX4J License version 1.0.
006: * See the terms of the MX4J License in the documentation provided with this software.
007: */
008:
009: package mx4j.tools.remote.soap.axis.ser;
010:
011: import java.io.IOException;
012: import javax.management.relation.RoleInfo;
013: import javax.xml.namespace.QName;
014:
015: import org.apache.axis.encoding.SerializationContext;
016: import org.apache.axis.encoding.XMLType;
017: import org.apache.axis.wsdl.fromJava.Types;
018: import org.w3c.dom.Element;
019: import org.xml.sax.Attributes;
020:
021: /**
022: * @version $Revision: 1.3 $
023: */
024: public class RoleInfoSer extends AxisSerializer {
025: static final String TYPE = "RoleInfo";
026: static final String MAX_DEGREE = "maxDegree";
027: static final String MIN_DEGREE = "minDegree";
028: static final String NAME = "name";
029: static final String DESCRIPTION = "description";
030: static final String REF_MBEAN_CLASS_NAME = "refMBeanClassName";
031: static final String READABLE = "readable";
032: static final String WRITEABLE = "writeable";
033:
034: private static final QName MAX_DEGREE_QNAME = new QName("",
035: MAX_DEGREE);
036: private static final QName MIN_DEGREE_QNAME = new QName("",
037: MIN_DEGREE);
038: private static final QName NAME_QNAME = new QName("", NAME);
039: private static final QName DESCRIPTION_QNAME = new QName("",
040: DESCRIPTION);
041: private static final QName REF_MBEAN_CLASS_NAME_QNAME = new QName(
042: "", REF_MBEAN_CLASS_NAME);
043: private static final QName READABLE_QNAME = new QName("", READABLE);
044: private static final QName WRITABLE_QNAME = new QName("", WRITEABLE);
045:
046: public void serialize(QName name, Attributes attributes,
047: Object value, SerializationContext context)
048: throws IOException {
049: RoleInfo roleInfo = (RoleInfo) value;
050: context.startElement(name, attributes);
051: context.serialize(MAX_DEGREE_QNAME, null, new Integer(roleInfo
052: .getMaxDegree()));
053: context.serialize(MIN_DEGREE_QNAME, null, new Integer(roleInfo
054: .getMaxDegree()));
055: context.serialize(NAME_QNAME, null, roleInfo.getName());
056: context.serialize(DESCRIPTION_QNAME, null, roleInfo
057: .getDescription());
058: context.serialize(REF_MBEAN_CLASS_NAME_QNAME, null, roleInfo
059: .getRefMBeanClassName());
060: context.serialize(READABLE_QNAME, null,
061: roleInfo.isReadable() ? Boolean.TRUE : Boolean.FALSE);
062: context.serialize(WRITABLE_QNAME, null,
063: roleInfo.isWritable() ? Boolean.TRUE : Boolean.FALSE);
064: context.endElement();
065: }
066:
067: public Element writeSchema(Class javaType, Types types)
068: throws Exception {
069: Element complexType = types.createElement(SCHEMA_COMPLEX_TYPE);
070: complexType.setAttribute("name", TYPE);
071: Element allElement = types.createElement(SCHEMA_ALL);
072: complexType.appendChild(allElement);
073:
074: Element maxDegreeElement = types.createElement(SCHEMA_ELEMENT);
075: maxDegreeElement.setAttribute("name", MAX_DEGREE);
076: maxDegreeElement.setAttribute("type", XMLType.XSD_INT
077: .getLocalPart());
078: allElement.appendChild(maxDegreeElement);
079:
080: Element minDegreeElement = types.createElement(SCHEMA_ELEMENT);
081: minDegreeElement.setAttribute("name", MIN_DEGREE);
082: minDegreeElement.setAttribute("type", XMLType.XSD_INT
083: .getLocalPart());
084: allElement.appendChild(minDegreeElement);
085:
086: Element nameElement = types.createElement(SCHEMA_ELEMENT);
087: nameElement.setAttribute("name", NAME);
088: nameElement.setAttribute("type", XMLType.XSD_STRING
089: .getLocalPart());
090: allElement.appendChild(nameElement);
091:
092: Element descriptionElement = types
093: .createElement(SCHEMA_ELEMENT);
094: descriptionElement.setAttribute("name", DESCRIPTION);
095: descriptionElement.setAttribute("type", XMLType.XSD_STRING
096: .getLocalPart());
097: allElement.appendChild(descriptionElement);
098:
099: Element refMBeanClassNameElement = types
100: .createElement(SCHEMA_ELEMENT);
101: refMBeanClassNameElement.setAttribute("name",
102: REF_MBEAN_CLASS_NAME);
103: refMBeanClassNameElement.setAttribute("type",
104: XMLType.XSD_STRING.getLocalPart());
105: allElement.appendChild(refMBeanClassNameElement);
106:
107: Element readableElement = types.createElement(SCHEMA_ELEMENT);
108: readableElement.setAttribute("name", READABLE);
109: readableElement.setAttribute("type", XMLType.XSD_BOOLEAN
110: .getLocalPart());
111: allElement.appendChild(readableElement);
112:
113: Element writeableElement = types.createElement(SCHEMA_ELEMENT);
114: writeableElement.setAttribute("name", WRITEABLE);
115: writeableElement.setAttribute("type", XMLType.XSD_BOOLEAN
116: .getLocalPart());
117: allElement.appendChild(writeableElement);
118:
119: return complexType;
120: }
121:
122: }
|