|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectsimple.util.Introspector
public class Introspector
The Introspector
provides a means to invoke methods
of arbitrary objects by matching a parameter list and name. The
method matching done by this is similar, but more primitave, to
the dynamic binding done by the Java runtime. This will basically
attempt to find a method, in no specific order, that has the
name specified and that takes parameters that are compatiable
to those given to the invoke
methods.
Constructor Summary | |
---|---|
Introspector(java.lang.Class type)
Constructor for the Introspector class. |
Method Summary | |
---|---|
java.lang.Object |
invoke(java.lang.String name,
java.lang.Object target,
java.lang.Object data)
Performs a reflective invocation on a target object by means of discovering a method compatible with the arguments. |
java.lang.Object |
invoke(java.lang.String name,
java.lang.Object target,
java.lang.Object[] list)
Performs a reflective invocation on a target object by means of discovering a method compatible with the arguments. |
java.lang.reflect.Method |
match(java.lang.String name,
java.lang.Class type)
This method performs the "discovery" of methods within the instance class. |
java.lang.reflect.Method |
match(java.lang.String name,
java.lang.Class[] types)
This method performs the "discovery" of methods within the instance class. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Introspector(java.lang.Class type)
Introspector
class. This
will enable methods of the specified Class
to be
invoked using only the name of the method and the arguments
to that method. The target of the invocation must be either
the same type or a subclass of the class specified to this.
type
- the object type the introspection is done withMethod Detail |
---|
public java.lang.reflect.Method match(java.lang.String name, java.lang.Class type) throws java.lang.Exception
Class
.
The discovery of the method is done in no specific order. This will simply match aand retrieve the first method that is compatable with the signature described. If no match is found then this method will return null.
name
- this is the name of the method to be invokedtype
- this is the type of the single parameter
Method
that is discovered
java.lang.Exception
- thrown if there is a problem matchingpublic java.lang.reflect.Method match(java.lang.String name, java.lang.Class[] types)
Class
array.
The discovery of the method is done in no specific order. This will simply match and retrieve the first method that is compatable with the signature described. If no match is found then this method will return null.
name
- this is the name of the method to be invokedtypes
- these are the types of the method parameters
Method
that is discoveredpublic java.lang.Object invoke(java.lang.String name, java.lang.Object target, java.lang.Object data) throws java.lang.Exception
Introspector
instance was created to search.
If the target object is not of the same type as the type this
instance was specified to use, then this method will throw an
IllegalArgumentException
. The target object
therefore must be of the same type or a subclass of the type.
name
- this is the name of the method to search fortarget
- this is the target object to be invokeddata
- a single argument to be passed to the method
java.lang.IllegalAccessException
- this is thrown if the method
discovered is not public
java.lang.reflect.InvocationTargetException
- this is thrown if the
discovered method throws an exception
java.lang.IllegalArgumentException
- thrown if the target object
is not compatable with the issued type
java.lang.NoSuchMethodException
- thrown if a matching method
cannot be found for the class
java.lang.Exception
public java.lang.Object invoke(java.lang.String name, java.lang.Object target, java.lang.Object[] list) throws java.lang.Exception
Introspector
instance was created to search.
If the target object is not of the same type as the type this
instance was specified to use, then this method will throw an
IllegalArgumentException
. The target object
therefore must be of the same type or a subclass of the type.
name
- this is the name of the method to search fortarget
- this is the target object to be invokedlist
- the list of arguments to be passed to the method
java.lang.IllegalAccessException
- this is thrown if the method
discovered is not public
java.lang.reflect.InvocationTargetException
- this is thrown if the
discovered method throws an exception
java.lang.IllegalArgumentException
- thrown if the target object
is not compatable with the issued type
java.lang.NoSuchMethodException
- thrown if a matching method
cannot be found for the class
java.lang.Exception
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |