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 IntegerArrayProperty extends ArrayProperty { 50 private static final L10N L = new L10N(IntegerArrayProperty.class); 51 52 public static final IntegerArrayProperty PROPERTY 53 = new IntegerArrayProperty(); 54 55 private IntegerArrayProperty() 56 { 57 super(IntProperty.PRIMITIVE_PROPERTY); 58 } 59 60 public Object read(Unmarshaller u, XMLStreamReader in, QName qname) 61 throws IOException , XMLStreamException, JAXBException 62 { 63 if (in.getEventType() != in.START_ELEMENT || ! qname.equals(in.getName())) 64 return new int[0]; 66 ArrayList <Integer > ret = new ArrayList <Integer >(); 67 68 while (in.getEventType() == in.START_ELEMENT && qname.equals(in.getName())) 69 ret.add((Integer ) _componentProperty.read(u, in, qname)); 70 71 int[] array = new int[ret.size()]; 72 73 for (int i = 0; i < ret.size(); i++) 74 array[i] = ret.get(i).intValue(); 75 76 return array; 77 } 78 79 public void write(Marshaller m, XMLStreamWriter out, Object obj, QName qname) 80 throws IOException , XMLStreamException, JAXBException 81 { 82 84 if (obj != null) { 85 int[] array = (int[]) obj; 86 87 for (int i = 0; i < array.length; i++) 88 IntProperty.PRIMITIVE_PROPERTY.write(m, out, array[i], qname); 89 } 90 } 91 } 92 | Popular Tags |