1 29 30 package com.caucho.jaxb.skeleton; 31 32 import com.caucho.jaxb.JAXBContextImpl; 33 import com.caucho.util.L10N; 34 35 import javax.xml.bind.JAXBException; 36 import javax.xml.bind.annotation.XmlAttribute; 37 import javax.xml.bind.annotation.XmlElement; 38 import javax.xml.bind.annotation.XmlType; 39 import javax.xml.namespace.QName ; 40 import java.beans.PropertyDescriptor ; 41 import java.lang.annotation.Annotation ; 42 import java.lang.reflect.Field ; 43 import java.lang.reflect.GenericArrayType ; 44 import java.lang.reflect.Method ; 45 import java.lang.reflect.ParameterizedType ; 46 import java.lang.reflect.Type ; 47 import java.util.Map ; 48 49 public class CollectionComponentAccessor extends Accessor { 50 private Accessor _accessor; 51 private Class _type; 52 private Type _genericType; 53 54 public CollectionComponentAccessor(Accessor a) 55 { 56 super(a.getContext()); 57 58 _accessor = a; 59 60 Type collectionGenericType = a.getGenericType(); 61 62 if (collectionGenericType instanceof ParameterizedType ) { 63 ParameterizedType pType = (ParameterizedType ) collectionGenericType; 64 65 Type[] parameters = pType.getActualTypeArguments(); 66 67 if (parameters.length < 1) 68 throw new UnsupportedOperationException (L.l("Unsupported type {0}", pType)); 69 70 _genericType = parameters[0]; 71 72 try { 73 if (_genericType instanceof ParameterizedType ) 74 _type = (Class ) ((ParameterizedType ) _genericType).getRawType(); 75 else 76 _type = (Class ) _genericType; 77 } 78 catch (ClassCastException e) { 79 throw new UnsupportedOperationException (L.l("Unsupported type {0}", pType)); 80 } 81 } 82 } 83 84 public Object get(Object o) throws JAXBException 85 { 86 throw new JAXBException("can't invoke CollectionComponentAccessor.get()"); 87 } 88 89 public void set(Object o, Object value) throws JAXBException 90 { 91 throw new JAXBException("can't invoke CollectionComponentAccessor.set()"); 92 } 93 94 public String getName() 95 { 96 return _accessor.getName(); 97 } 98 99 public Class getType() 100 { 101 return _type; 102 } 103 104 public Type getGenericType() 105 { 106 return _genericType; 107 } 108 109 public <A extends Annotation > A getAnnotation(Class <A> c) 110 { 111 return null; 112 } 113 } 114 | Popular Tags |