KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > caucho > bytecode > JConstructorWrapper


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 Scott Ferguson
28  */

29
30 package com.caucho.bytecode;
31
32 import java.lang.reflect.Constructor JavaDoc;
33 import java.lang.reflect.Modifier JavaDoc;
34
35 /**
36  * Wrapper around the Java Constructor for a JMethod.
37  */

38 public class JConstructorWrapper extends JMethod {
39   private JClassLoader _loader;
40
41   private Constructor JavaDoc _method;
42
43   public JConstructorWrapper(Constructor JavaDoc method, JClassLoader loader)
44   {
45     if (loader == null)
46       throw new NullPointerException JavaDoc();
47
48     _method = method;
49     _loader = loader;
50   }
51
52   /**
53    * Returns the method name.
54    */

55   public String JavaDoc getName()
56   {
57     return _method.getName();
58   }
59
60   /**
61    * Returns true for a static method.
62    */

63   public boolean isStatic()
64   {
65     return Modifier.isStatic(_method.getModifiers());
66   }
67
68   /**
69    * Returns true for a private method
70    */

71   public boolean isPrivate()
72   {
73     return Modifier.isPrivate(_method.getModifiers());
74   }
75
76   /**
77    * Returns true for a public method.
78    */

79   public boolean isPublic()
80   {
81     return Modifier.isPublic(_method.getModifiers());
82   }
83
84   /**
85    * Returns true for a final method.
86    */

87   public boolean isFinal()
88   {
89     return Modifier.isFinal(_method.getModifiers());
90   }
91
92   /**
93    * Returns true for an abstract method.
94    */

95   public boolean isAbstract()
96   {
97     return Modifier.isAbstract(_method.getModifiers());
98   }
99
100   /**
101    * Returns the declaring type.
102    */

103   public JClass getDeclaringClass()
104   {
105     return _loader.forName(_method.getDeclaringClass().getName());
106   }
107
108   /**
109    * Returns the return type.
110    */

111   public JClass getReturnType()
112   {
113     throw new UnsupportedOperationException JavaDoc();
114   }
115
116   /**
117    * Returns the return type.
118    */

119   public JType getGenericReturnType()
120   {
121     throw new UnsupportedOperationException JavaDoc();
122   }
123
124   /**
125    * Returns the parameter types.
126    */

127   public JClass []getParameterTypes()
128   {
129     Class JavaDoc []types = _method.getParameterTypes();
130
131     JClass []jTypes = new JClass[types.length];
132
133     for (int i = 0; i < types.length; i++) {
134       jTypes[i] = _loader.forName(types[i].getName());
135     }
136
137     return jTypes;
138   }
139
140   /**
141    * Returns the exception types.
142    */

143   public JClass []getExceptionTypes()
144   {
145     Class JavaDoc []types = _method.getExceptionTypes();
146
147     JClass []jTypes = new JClass[types.length];
148
149     for (int i = 0; i < types.length; i++) {
150       jTypes[i] = _loader.forName(types[i].getName());
151     }
152
153     return jTypes;
154   }
155
156   /**
157    * Returns the annotations.
158    */

159   public JAnnotation []getDeclaredAnnotations()
160   {
161     return new JAnnotation[0];
162   }
163 }
164
Popular Tags