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