| java.lang.Object org.gjt.sp.jedit.bsh.Reflect
Reflect | class Reflect (Code) | | All of the reflection API code lies here. It is in the form of static
utilities. Maybe this belongs in LHS.java or a generic object
wrapper class.
|
Method Summary | |
static Object | constructObject(Class clas, Object[] args) Primary object constructor
This method is simpler than those that must resolve general method
invocation because constructors are not inherited. | static Constructor | findMostSpecificConstructor(Class[] idealMatch, Constructor[] constructors) | static int | findMostSpecificConstructorIndex(Class[] idealMatch, Constructor[] constructors) | static Method | findMostSpecificMethod(Class[] idealMatch, Method[] methods) Find the best match for signature idealMatch.
It is assumed that the methods array holds only valid candidates
(e.g. | static int | findMostSpecificSignature(Class[] idealMatch, Class[][] candidates) Implement JLS 15.11.2
Return the index of the most specific arguments match or -1 if no
match is found. | public static Class | getArrayBaseType(Class arrayClass) Returns the base type of an array Class. | public static int | getArrayDimensions(Class arrayClass) | static Method[] | getCandidateMethods(Class baseClass, String methodName, int numArgs, boolean publicOnly) Climb the class and interface inheritence graph of the type and collect
all methods matching the specified name and criterion. | public static Object | getIndex(Object array, int index) | static LHS | getLHSObjectField(Object object, String fieldName) Get an LHS reference to an object field. | static LHS | getLHSStaticField(Class clas, String fieldName) | public static Object | getObjectFieldValue(Object object, String fieldName) | public static Object | getObjectProperty(Object obj, String propName) | public static Object | getStaticFieldValue(Class clas, String fieldName) | public static boolean | hasObjectPropertyGetter(Class clas, String propName) | public static boolean | hasObjectPropertySetter(Class clas, String propName) | public static Object | invokeCompiledCommand(Class commandClass, Object[] args, Interpreter interpreter, CallStack callstack) A command may be implemented as a compiled Java class containing one or
more static invoke() methods of the correct signature. | static Object | invokeMethod(Method method, Object object, Object[] args) Invoke the Java method on the specified object, performing needed
type mappings on arguments and return values. | public static Object | invokeObjectMethod(Object object, String methodName, Object[] args, Interpreter interpreter, CallStack callstack, SimpleNode callerInfo) Invoke method on arbitrary object instance. | public static Object | invokeStaticMethod(BshClassManager bcm, Class clas, String methodName, Object[] args) Invoke a method known to be static. | public static String | normalizeClassName(Class type) Return a more human readable version of the type name.
Specifically, array types are returned with postfix "[]" dimensions.
e.g. | protected static Field | resolveExpectedJavaField(Class clas, String fieldName, boolean staticOnly) | protected static Method | resolveExpectedJavaMethod(BshClassManager bcm, Class clas, Object object, String name, Object[] args, boolean staticOnly) This method wraps resolveJavaMethod() and expects a non-null method
result. | protected static Field | resolveJavaField(Class clas, String fieldName, boolean staticOnly) | protected static Method | resolveJavaMethod(BshClassManager bcm, Class clas, String name, Class[] types, boolean staticOnly) The full blown resolver method. | public static void | setIndex(Object array, int index, Object val) | public static void | setObjectProperty(Object obj, String propName, Object value) |
constructObject | static Object constructObject(Class clas, Object[] args) throws ReflectError, InvocationTargetException(Code) | | Primary object constructor
This method is simpler than those that must resolve general method
invocation because constructors are not inherited.
This method determines whether to attempt to use non-public constructors
based on Capabilities.haveAccessibility() and will set the accessibilty
flag on the method as necessary.
|
findMostSpecificConstructorIndex | static int findMostSpecificConstructorIndex(Class[] idealMatch, Constructor[] constructors)(Code) | | |
findMostSpecificMethod | static Method findMostSpecificMethod(Class[] idealMatch, Method[] methods)(Code) | | Find the best match for signature idealMatch.
It is assumed that the methods array holds only valid candidates
(e.g. method name and number of args already matched).
This method currently does not take into account Java 5 covariant
return types... which I think will require that we find the most
derived return type of otherwise identical best matches.
See Also: Reflect.findMostSpecificSignature(Class[],Class[][]) Parameters: methods - the set of candidate method which differ only in thetypes of their arguments. |
findMostSpecificSignature | static int findMostSpecificSignature(Class[] idealMatch, Class[][] candidates)(Code) | | Implement JLS 15.11.2
Return the index of the most specific arguments match or -1 if no
match is found.
This method is used by both methods and constructors (which
unfortunately don't share a common interface for signature info).
the index of the most specific candidate |
getArrayBaseType | public static Class getArrayBaseType(Class arrayClass) throws ReflectError(Code) | | Returns the base type of an array Class.
throws ReflectError if the Class is not an array class.
|
getArrayDimensions | public static int getArrayDimensions(Class arrayClass)(Code) | | returns the dimensionality of the Class
returns 0 if the Class is not an array class
|
getCandidateMethods | static Method[] getCandidateMethods(Class baseClass, String methodName, int numArgs, boolean publicOnly)(Code) | | Climb the class and interface inheritence graph of the type and collect
all methods matching the specified name and criterion. If publicOnly
is true then only public methods in *public* classes or interfaces will
be returned. In the normal (non-accessible) case this addresses the
problem that arises when a package private class or private inner class
implements a public interface or derives from a public type.
This method primarily just delegates to gatherMethodsRecursive()
See Also: Reflect.gatherMethodsRecursive(Class,String,int,boolean,java.util.Vector) |
getLHSObjectField | static LHS getLHSObjectField(Object object, String fieldName) throws UtilEvalError, ReflectError(Code) | | Get an LHS reference to an object field.
This method also deals with the field style property access.
In the field does not exist we check for a property setter.
|
hasObjectPropertyGetter | public static boolean hasObjectPropertyGetter(Class clas, String propName)(Code) | | |
hasObjectPropertySetter | public static boolean hasObjectPropertySetter(Class clas, String propName)(Code) | | |
invokeCompiledCommand | public static Object invokeCompiledCommand(Class commandClass, Object[] args, Interpreter interpreter, CallStack callstack) throws UtilEvalError(Code) | | A command may be implemented as a compiled Java class containing one or
more static invoke() methods of the correct signature. The invoke()
methods must accept two additional leading arguments of the interpreter
and callstack, respectively. e.g. invoke(interpreter, callstack, ... )
This method adds the arguments and invokes the static method, returning
the result.
|
normalizeClassName | public static String normalizeClassName(Class type)(Code) | | Return a more human readable version of the type name.
Specifically, array types are returned with postfix "[]" dimensions.
e.g. return "int []" for integer array instead of "class [I" as
would be returned by Class getName() in that case.
|
resolveJavaMethod | protected static Method resolveJavaMethod(BshClassManager bcm, Class clas, String name, Class[] types, boolean staticOnly) throws UtilEvalError(Code) | | The full blown resolver method. All other method invocation methods
delegate to this. The method may be static or dynamic unless
staticOnly is set (in which case object may be null).
If staticOnly is set then only static methods will be located.
This method performs caching (caches discovered methods through the
class manager and utilizes cached methods.)
This method determines whether to attempt to use non-public methods
based on Capabilities.haveAccessibility() and will set the accessibilty
flag on the method as necessary.
If, when directed to find a static method, this method locates a more
specific matching instance method it will throw a descriptive exception
analogous to the error that the Java compiler would produce.
Note: as of 2.0.x this is a problem because there is no way to work
around this with a cast.
Parameters: staticOnly - The method located must be static, the object param may be null. the method or null if no matching method was found. |
|
|