1 29 30 package com.caucho.jaxb.skeleton; 31 import javax.xml.bind.JAXBException; 32 import javax.xml.bind.Marshaller; 33 import javax.xml.bind.Unmarshaller; 34 import javax.xml.bind.annotation.XmlElementWrapper; 35 import javax.xml.namespace.QName ; 36 import javax.xml.stream.XMLStreamException; 37 import javax.xml.stream.XMLStreamReader; 38 import javax.xml.stream.XMLStreamWriter; 39 import java.io.IOException ; 40 import java.lang.reflect.Array ; 41 import java.util.ArrayList ; 42 import java.util.Iterator ; 43 44 import com.caucho.util.L10N; 45 46 49 public class FloatArrayProperty extends ArrayProperty { 50 private static final L10N L = new L10N(FloatArrayProperty.class); 51 52 public static final FloatArrayProperty PROPERTY = new FloatArrayProperty(); 53 54 public FloatArrayProperty() 55 { 56 super(FloatProperty.PRIMITIVE_PROPERTY); 57 } 58 59 public Object read(Unmarshaller u, XMLStreamReader in, QName qname) 60 throws IOException , XMLStreamException, JAXBException 61 { 62 if (in.getEventType() != in.START_ELEMENT || ! qname.equals(in.getName())) 63 return new float[0]; 65 ArrayList <Float > ret = new ArrayList <Float >(); 66 67 while (in.getEventType() == in.START_ELEMENT && qname.equals(in.getName())) 68 ret.add((Float ) _componentProperty.read(u, in, qname)); 69 70 float[] array = new float[ret.size()]; 71 72 for (int i = 0; i < ret.size(); i++) 73 array[i] = ret.get(i).floatValue(); 74 75 return array; 76 } 77 78 public void write(Marshaller m, XMLStreamWriter out, Object obj, QName qname) 79 throws IOException , XMLStreamException, JAXBException 80 { 81 83 if (obj != null) { 84 float[] array = (float[]) obj; 85 86 for (int i = 0; i < array.length; i++) 87 FloatProperty.PRIMITIVE_PROPERTY.write(m, out, array[i], qname); 88 } 89 } 90 } 91 | Popular Tags |