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