KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jibx > binding > model > IClass


1 /*
2 Copyright (c) 2004-2005, Dennis M. Sosnoski
3 All rights reserved.
4
5 Redistribution and use in source and binary forms, with or without modification,
6 are permitted provided that the following conditions are met:
7
8  * Redistributions of source code must retain the above copyright notice, this
9    list of conditions and the following disclaimer.
10  * Redistributions in binary form must reproduce the above copyright notice,
11    this list of conditions and the following disclaimer in the documentation
12    and/or other materials provided with the distribution.
13  * Neither the name of JiBX nor the names of its contributors may be used
14    to endorse or promote products derived from this software without specific
15    prior written permission.
16
17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
21 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
24 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */

28
29 package org.jibx.binding.model;
30
31 import org.jibx.binding.classes.ClassFile;
32
33 /**
34  * Interface for class file information. Provides access to class field and
35  * method information.
36  *
37  * @author Dennis M. Sosnoski
38  * @version 1.0
39  */

40
41 public interface IClass
42 {
43     /**
44      * Get class file information.
45      * TODO: eliminate this sucker
46      *
47      * @return class file information
48      */

49     public ClassFile getClassFile();
50
51     /**
52      * Get fully qualified class name.
53      *
54      * @return fully qualified name for class
55      */

56     public String JavaDoc getName();
57
58     /**
59      * Get signature for class as type.
60      *
61      * @return signature for class used as type
62      */

63     public String JavaDoc getSignature();
64
65     /**
66      * Get package name.
67      *
68      * @return package name for class
69      */

70     public String JavaDoc getPackage();
71
72     /**
73      * Get superclass.
74      *
75      * @return superclass information
76      */

77     public IClass getSuperClass();
78
79     /**
80      * Get names of all interfaces implemented by class.
81      *
82      * @return names of all interfaces implemented directly by class
83      */

84     public String JavaDoc[] getInterfaces();
85
86     /**
87      * Get signatures for all types of which instances of this type are
88      * instances.
89      *
90      * @return all signatures suppored by instances
91      */

92     public String JavaDoc[] getInstanceSigs();
93
94     /**
95      * Check if class implements an interface.
96      *
97      * @param signature of interface to be checked
98      * @return <code>true</code> if interface is implemented by class,
99      * <code>false</code> if not
100      */

101     public boolean isImplements(String JavaDoc sig);
102
103     /**
104      * Check if another class is a superclass of this one.
105      *
106      * @param name potential superclass to be checked
107      * @return <code>true</code> if named class is a superclass of this one,
108      * <code>false</code> if not
109      */

110     public boolean isSuperclass(String JavaDoc name);
111
112     /**
113      * Get information for field. This only checks for fields that are actually
114      * members of the class (not superclasses).
115      * TODO: make this work with both static and member fields
116      *
117      * @param name field name
118      * @return field information, or <code>null</code> if field not found
119      */

120     public IClassItem getDirectField(String JavaDoc name);
121
122     /**
123      * Get information for field. If the field is not found directly,
124      * superclasses are checked for inherited fields matching the supplied name.
125      * TODO: make this work with both static and member fields
126      *
127      * @param name field name
128      * @return field information, or <code>null</code> if field not found
129      */

130     public IClassItem getField(String JavaDoc name);
131
132     /**
133      * Get information for best matching method. This tries to find a method
134      * which matches the specified name, return type, and argument types. If an
135      * exact match is not found it looks for a method with a return type that
136      * is extended or implemented by the specified type and arguments that are
137      * extended or implemented by the specified types. If no match is found for
138      * this class superclasses are checked.
139      * TODO: make this work with both static and member methods
140      *
141      * @param name method name
142      * @param type return value type name (<code>null</code> if indeterminant)
143      * @param args argument value type names
144      * @return method information, or <code>null</code> if method not found
145      */

146     public IClassItem getBestMethod(String JavaDoc name, String JavaDoc type, String JavaDoc[] args);
147
148     /**
149      * Get information for method without respect to potential trailing
150      * arguments or return value. If the method is not found directly,
151      * superclasses are checked for inherited methods matching the supplied
152      * name. This compares the supplied partial signature against the actual
153      * method signature, and considers it a match if the actual sigature starts
154      * with the supplied signature.
155      * TODO: make this work with both static and member methods
156      *
157      * @param name method name
158      * @param sig partial method signature to be matched
159      * @return method information, or <code>null</code> if method not found
160      */

161     public IClassItem getMethod(String JavaDoc name, String JavaDoc sig);
162
163     /**
164      * Get information for method matching one of several possible signatures.
165      * If a match is not found directly, superclasses are checked for inherited
166      * methods matching the supplied name and signatures. The signature
167      * variations are checked in the order supplied.
168      * TODO: make this work with both static and member methods
169      *
170      * @param name method name
171      * @param sigs possible signatures for method (including return type)
172      * @return method information, or <code>null</code> if method not found
173      */

174     public IClassItem getMethod(String JavaDoc name, String JavaDoc[] sigs);
175
176     /**
177      * Get information for initializer. Only the class itself is checked for an
178      * initializer matching the argument list signature.
179      *
180      * @param sig encoded argument list signature
181      * @return method information, or <code>null</code> if method not found
182      */

183     public IClassItem getInitializerMethod(String JavaDoc sig);
184
185     /**
186      * Get information for static method without respect to return value. Only
187      * the class itself is checked for a method matching the supplied name and
188      * argument list signature.
189      *
190      * @param name method name
191      * @param sig encoded argument list signature
192      * @return method information, or <code>null</code> if method not found
193      */

194     public IClassItem getStaticMethod(String JavaDoc name, String JavaDoc sig);
195
196     /**
197      * Check accessible method. Check if a field or method in another class is
198      * accessible from within this class.
199      *
200      * @param item field or method information
201      * @return <code>true</code> if accessible, <code>false</code> if not
202      */

203     public boolean isAccessible(IClassItem item);
204
205     /**
206      * Check if a value of this type can be directly assigned to another type.
207      * This is basically the equivalent of the instanceof operator.
208      *
209      * @param other type to be assigned to
210      * @return <code>true</code> if assignable, <code>false</code> if not
211      */

212     public boolean isAssignable(IClass other);
213 }
Popular Tags