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 DoubleArrayProperty extends ArrayProperty { 50 private static final L10N L = new L10N(DoubleArrayProperty.class); 51 52 public static final DoubleArrayProperty PROPERTY = new DoubleArrayProperty(); 53 54 public DoubleArrayProperty() 55 { 56 super(DoubleProperty.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 double[0]; 65 ArrayList <Double > ret = new ArrayList <Double >(); 66 67 while (in.getEventType() == in.START_ELEMENT && qname.equals(in.getName())) 68 ret.add((Double ) _componentProperty.read(u, in, qname)); 69 70 double[] array = new double[ret.size()]; 71 72 for (int i = 0; i < ret.size(); i++) 73 array[i] = ret.get(i).doubleValue(); 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 double[] array = (double[]) obj; 85 86 for (int i = 0; i < array.length; i++) 87 DoubleProperty.PRIMITIVE_PROPERTY.write(m, out, array[i], qname); 88 } 89 } 90 } 91 | Popular Tags |