1 55 56 package org.jboss.axis.encoding.ser; 57 58 import org.jboss.axis.Constants; 59 import org.jboss.axis.NotImplementedException; 60 import org.jboss.axis.encoding.SerializationContext; 61 import org.jboss.axis.encoding.Serializer; 62 import org.jboss.axis.utils.JavaUtils; 63 import org.jboss.axis.wsdl.fromJava.Types; 64 import org.jboss.logging.Logger; 65 import org.w3c.dom.Element ; 66 import org.xml.sax.Attributes ; 67 68 import javax.xml.namespace.QName ; 69 import java.io.IOException ; 70 71 76 77 public class ListSerializer implements Serializer 78 { 79 80 private static Logger log = Logger.getLogger(ListSerializer.class.getName()); 81 82 private Class javaType; 83 private QName xmlType; 84 85 public ListSerializer(Class javaType, QName xmlType) 86 { 87 this.javaType = javaType; 88 this.xmlType = xmlType; 89 } 90 91 100 public void serialize(QName name, Attributes attributes, 101 Object value, SerializationContext context) 102 throws IOException 103 { 104 105 if (value == null || JavaUtils.isArrayClass(value.getClass()) == false) 106 throw new IllegalStateException ("Cannot use this serializer with: " + value); 107 108 Object [] itemArr = (Object [])value; 109 110 context.startElement(name, attributes); 111 for (int i = 0; i < itemArr.length; i++) 112 { 113 String strValue = getValueAsString(itemArr[i]); 114 if (i > 0) strValue = " " + strValue; 115 context.serialize(null, null, strValue); 116 } 117 118 context.endElement(); 119 } 120 121 124 private String getValueAsString(Object item) 125 { 126 return item.toString(); 128 } 129 130 public String getMechanismType() 131 { 132 return Constants.AXIS_SAX; 133 } 134 135 146 public Element writeSchema(Class javaType, Types types) throws Exception 147 { 148 throw new NotImplementedException(); 149 } 150 } 151 | Popular Tags |