KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > caucho > jaxb > skeleton > ArrayComponentAccessor


1 /*
2  * Copyright (c) 1998-2006 Caucho Technology -- all rights reserved
3  *
4  * This file is part of Resin(R) Open Source
5  *
6  * Each copy or derived work must preserve the copyright notice and this
7  * notice unmodified.
8  *
9  * Resin Open Source is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * Resin Open Source is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
17  * of NON-INFRINGEMENT. See the GNU General Public License for more
18  * details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with Resin Open Source; if not, write to the
22  *
23  * Free Software Foundation, Inc.
24  * 59 Temple Place, Suite 330
25  * Boston, MA 02111-1307 USA
26  *
27  * @author Emil Ong
28  */

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 JavaDoc;
40 import java.beans.PropertyDescriptor JavaDoc;
41 import java.lang.annotation.Annotation JavaDoc;
42 import java.lang.reflect.Field JavaDoc;
43 import java.lang.reflect.GenericArrayType JavaDoc;
44 import java.lang.reflect.Method JavaDoc;
45 import java.lang.reflect.ParameterizedType JavaDoc;
46 import java.lang.reflect.Type JavaDoc;
47 import java.util.Map JavaDoc;
48
49 public class ArrayComponentAccessor extends Accessor {
50   private Accessor _accessor;
51   private Class JavaDoc _type;
52   private Type _genericType;
53
54   public ArrayComponentAccessor(Accessor a)
55   {
56     super(a.getContext());
57
58     _accessor = a;
59
60     _type = _accessor.getType().getComponentType();
61
62     if (a.getGenericType() instanceof GenericArrayType JavaDoc) {
63       GenericArrayType JavaDoc arrayType = (GenericArrayType JavaDoc) a.getGenericType();
64       _genericType = arrayType.getGenericComponentType();
65     }
66     else {
67       _genericType = _type;
68     }
69   }
70
71   public Object JavaDoc get(Object JavaDoc o) throws JAXBException
72   {
73     throw new JAXBException("cannot invoke ArrayComponentAccessor.get()");
74   }
75
76   public void set(Object JavaDoc o, Object JavaDoc value) throws JAXBException
77   {
78     throw new JAXBException("cannot invoke ArrayComponentAccessor.set()");
79   }
80
81   public String JavaDoc getName()
82   {
83     return _accessor.getName();
84   }
85
86   public Class JavaDoc getType()
87   {
88     return _type;
89   }
90
91   public Type getGenericType()
92   {
93     return _genericType;
94   }
95
96   public <A extends Annotation JavaDoc> A getAnnotation(Class JavaDoc<A> c)
97   {
98     return null;
99   }
100 }
101
Popular Tags