KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > reflect > plugins > javassist > JavassistParameterInfo


1 /*
2 * JBoss, Home of Professional Open Source
3 * Copyright 2006, JBoss Inc., and individual contributors as indicated
4 * by the @authors tag. See the copyright.txt in the distribution for a
5 * full listing of individual contributors.
6 *
7 * This is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as
9 * published by the Free Software Foundation; either version 2.1 of
10 * the License, or (at your option) any later version.
11 *
12 * This software is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this software; if not, write to the Free
19 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21 */

22 package org.jboss.reflect.plugins.javassist;
23
24 import org.jboss.reflect.plugins.AnnotationHelper;
25 import org.jboss.reflect.spi.AnnotationValue;
26 import org.jboss.reflect.spi.ParameterInfo;
27 import org.jboss.reflect.spi.TypeInfo;
28 import org.jboss.util.JBossStringBuilder;
29
30 /**
31  * JavassistParameterInfo.
32  *
33  * @author <a HREF="adrian@jboss.com">Adrian Brock</a>
34  * @version $Revision: 57133 $
35  */

36 public class JavassistParameterInfo extends JavassistAnnotatedInfo implements ParameterInfo
37 {
38    /** The annotated info */
39    private JavassistAnnotatedParameterInfo annotated;
40    
41    /** The name */
42    private String JavaDoc name;
43    
44    /** The paramter type */
45    private TypeInfo parameterType;
46    
47    /**
48     * Create a new JavassistParameterInfo.
49     *
50     * @param annotationHelper the annotation helper
51     * @param annotated the annotated object
52     * @param index the index
53     * @param parameterType the type
54     */

55    public JavassistParameterInfo(AnnotationHelper annotationHelper, JavassistAnnotatedParameterInfo annotated, int index, TypeInfo parameterType)
56    {
57       super(annotationHelper);
58       this.annotated = annotated;
59       this.name = "arg" + index;
60       this.parameterType = parameterType;
61    }
62
63    /**
64     * Get the annotated info
65     *
66     * @return the annotated
67     */

68    protected JavassistAnnotatedInfo getAnnotated()
69    {
70       return annotated;
71    }
72    
73    public String JavaDoc getName()
74    {
75       return name;
76    }
77
78    public TypeInfo getParameterType()
79    {
80       return parameterType;
81    }
82
83    public boolean equals(Object JavaDoc obj)
84    {
85       if (this == obj)
86          return true;
87       if (obj == null || obj instanceof ParameterInfo == false)
88          return false;
89       
90       ParameterInfo other = (ParameterInfo) obj;
91       return parameterType.equals(other.getParameterType());
92    }
93
94    protected int getHashCode()
95    {
96       return getName().hashCode();
97    }
98
99    public void toShortString(JBossStringBuilder buffer)
100    {
101       buffer.append(getParameterType());
102    }
103
104    protected void toString(JBossStringBuilder buffer)
105    {
106       buffer.append("type=").append(getParameterType());
107       super.toString(buffer);
108    }
109    
110    public AnnotationValue[] getAnnotations()
111    {
112       if (annotationsArray == NOT_CONFIGURED)
113       {
114          annotated.createParameterAnnotations(); //Calls setAnnotations() so annotationsArray is created
115
}
116       return annotationsArray;
117    }
118    
119    public void setAnnotations(AnnotationValue[] annotations)
120    {
121       annotationsArray = annotations;
122       setupAnnotations(annotations);
123    }
124
125 }
126
Popular Tags