001: /*
002: Copyright (c) 2004-2005, Dennis M. Sosnoski
003: All rights reserved.
004:
005: Redistribution and use in source and binary forms, with or without modification,
006: are permitted provided that the following conditions are met:
007:
008: * Redistributions of source code must retain the above copyright notice, this
009: list of conditions and the following disclaimer.
010: * Redistributions in binary form must reproduce the above copyright notice,
011: this list of conditions and the following disclaimer in the documentation
012: and/or other materials provided with the distribution.
013: * Neither the name of JiBX nor the names of its contributors may be used
014: to endorse or promote products derived from this software without specific
015: prior written permission.
016:
017: THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
018: ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
019: WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
020: DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
021: ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
022: (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
023: LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
024: ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
025: (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
026: SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
027: */
028:
029: package org.jibx.binding.model;
030:
031: import org.jibx.binding.classes.ClassFile;
032:
033: /**
034: * Interface for class file information. Provides access to class field and
035: * method information.
036: *
037: * @author Dennis M. Sosnoski
038: * @version 1.0
039: */
040:
041: public interface IClass {
042: /**
043: * Get class file information.
044: * TODO: eliminate this sucker
045: *
046: * @return class file information
047: */
048: public ClassFile getClassFile();
049:
050: /**
051: * Get fully qualified class name.
052: *
053: * @return fully qualified name for class
054: */
055: public String getName();
056:
057: /**
058: * Get signature for class as type.
059: *
060: * @return signature for class used as type
061: */
062: public String getSignature();
063:
064: /**
065: * Get package name.
066: *
067: * @return package name for class
068: */
069: public String getPackage();
070:
071: /**
072: * Get superclass.
073: *
074: * @return superclass information
075: */
076: public IClass getSuperClass();
077:
078: /**
079: * Get names of all interfaces implemented by class.
080: *
081: * @return names of all interfaces implemented directly by class
082: */
083: public String[] getInterfaces();
084:
085: /**
086: * Get signatures for all types of which instances of this type are
087: * instances.
088: *
089: * @return all signatures suppored by instances
090: */
091: public String[] getInstanceSigs();
092:
093: /**
094: * Check if class implements an interface.
095: *
096: * @param signature of interface to be checked
097: * @return <code>true</code> if interface is implemented by class,
098: * <code>false</code> if not
099: */
100: public boolean isImplements(String sig);
101:
102: /**
103: * Check if class is abstract.
104: *
105: * @return <code>true</code> if class is abstract, <code>false</code> if not
106: */
107: public boolean isAbstract();
108:
109: /**
110: * Check if class is an interface.
111: *
112: * @return <code>true</code> if class is an interface, <code>false</code> if
113: * not
114: */
115: public boolean isInterface();
116:
117: /**
118: * Check if class is modifiable.
119: *
120: * @return <code>true</code> if class is modifiable, <code>false</code> if
121: * not
122: */
123: public boolean isModifiable();
124:
125: /**
126: * Check if another class is a superclass of this one.
127: *
128: * @param name potential superclass to be checked
129: * @return <code>true</code> if named class is a superclass of this one,
130: * <code>false</code> if not
131: */
132: public boolean isSuperclass(String name);
133:
134: /**
135: * Get information for field. This only checks for fields that are actually
136: * members of the class (not superclasses).
137: * TODO: make this work with both static and member fields
138: *
139: * @param name field name
140: * @return field information, or <code>null</code> if field not found
141: */
142: public IClassItem getDirectField(String name);
143:
144: /**
145: * Get information for field. If the field is not found directly,
146: * superclasses are checked for inherited fields matching the supplied name.
147: * TODO: make this work with both static and member fields
148: *
149: * @param name field name
150: * @return field information, or <code>null</code> if field not found
151: */
152: public IClassItem getField(String name);
153:
154: /**
155: * Get information for best matching method. This tries to find a method
156: * which matches the specified name, return type, and argument types. If an
157: * exact match is not found it looks for a method with a return type that
158: * is extended or implemented by the specified type and arguments that are
159: * extended or implemented by the specified types. If no match is found for
160: * this class superclasses are checked.
161: * TODO: make this work with both static and member methods
162: *
163: * @param name method name
164: * @param type return value type name (<code>null</code> if indeterminant)
165: * @param args argument value type names
166: * @return method information, or <code>null</code> if method not found
167: */
168: public IClassItem getBestMethod(String name, String type,
169: String[] args);
170:
171: /**
172: * Get information for method without respect to potential trailing
173: * arguments or return value. If the method is not found directly,
174: * superclasses are checked for inherited methods matching the supplied
175: * name. This compares the supplied partial signature against the actual
176: * method signature, and considers it a match if the actual sigature starts
177: * with the supplied signature.
178: * TODO: make this work with both static and member methods
179: *
180: * @param name method name
181: * @param sig partial method signature to be matched
182: * @return method information, or <code>null</code> if method not found
183: */
184: public IClassItem getMethod(String name, String sig);
185:
186: /**
187: * Get information for method matching one of several possible signatures.
188: * If a match is not found directly, superclasses are checked for inherited
189: * methods matching the supplied name and signatures. The signature
190: * variations are checked in the order supplied.
191: * TODO: make this work with both static and member methods
192: *
193: * @param name method name
194: * @param sigs possible signatures for method (including return type)
195: * @return method information, or <code>null</code> if method not found
196: */
197: public IClassItem getMethod(String name, String[] sigs);
198:
199: /**
200: * Get information for initializer. Only the class itself is checked for an
201: * initializer matching the argument list signature.
202: *
203: * @param sig encoded argument list signature
204: * @return method information, or <code>null</code> if method not found
205: */
206: public IClassItem getInitializerMethod(String sig);
207:
208: /**
209: * Get information for static method without respect to return value. Only
210: * the class itself is checked for a method matching the supplied name and
211: * argument list signature.
212: *
213: * @param name method name
214: * @param sig encoded argument list signature
215: * @return method information, or <code>null</code> if method not found
216: */
217: public IClassItem getStaticMethod(String name, String sig);
218:
219: /**
220: * Check accessible method. Check if a field or method in another class is
221: * accessible from within this class.
222: *
223: * @param item field or method information
224: * @return <code>true</code> if accessible, <code>false</code> if not
225: */
226: public boolean isAccessible(IClassItem item);
227:
228: /**
229: * Check if a value of this type can be directly assigned to another type.
230: * This is basically the equivalent of the instanceof operator.
231: *
232: * @param other type to be assigned to
233: * @return <code>true</code> if assignable, <code>false</code> if not
234: */
235: public boolean isAssignable(IClass other);
236:
237: /**
238: * Load class in executable form.
239: *
240: * @return loaded class, or <code>null</code> if unable to load
241: */
242: public Class loadClass();
243:
244: /**
245: * Get all methods of class.
246: *
247: * @return methods
248: */
249: public IClassItem[] getMethods();
250:
251: /**
252: * Get all fields of class.
253: *
254: * @return fields
255: */
256: public IClassItem[] getFields();
257:
258: /**
259: * Get the JavaDoc comment for this class.
260: *
261: * @return comment text, or <code>null</code> if none or no source available
262: */
263: public String getJavaDoc();
264:
265: /**
266: * Get the locator which provided this class.
267: *
268: * @return locator
269: */
270: public IClassLocator getLocator();
271: }
|