|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.joe_e.reflect.Reflection
public final class Reflection
The reflection interface.
This API provides reflective access to all the public constructors, public fields and public methods of public Joe-E classes and interfaces. The API provides no more permission than is provided by static Joe-E program code. If you can do something with the reflection API, you could also have done it using static Joe-E code. The only difference is expressivity.
| Method Summary | ||
|---|---|---|
static
|
construct(Constructor<T> ctor,
Object... args)
Invokes a reflected constructor. |
|
static
|
constructor(Class<T> type,
Class<?>... args)
Gets a public constructor. |
|
static PowerlessArray<Constructor<?>> |
constructors(Class<?> type)
Gets all declared public constructors. |
|
static Field |
field(Class<?> type,
String name)
Gets a public field. |
|
static PowerlessArray<Field> |
fields(Class<?> type)
Gets all public fields. |
|
static Object |
get(Field field,
Object self)
Gets the value of a field. |
|
static String |
getName(Class<?> c)
Get the name of the entity represented by a Class object,
in the same format as returned by Class.getName(). |
|
static Object |
invoke(Method method,
Object self,
Object... args)
Invokes a reflected method. |
|
static Method |
method(Class<?> type,
String name,
Class<?>... args)
Gets a public method. |
|
static PowerlessArray<Method> |
methods(Class<?> type)
Gets all public methods. |
|
static void |
set(Field field,
Object self,
Object value)
Sets the value of a field. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static Field field(Class<?> type,
String name)
throws NoSuchFieldException
This method wraps Class.getField(java.lang.String).
type - class to searchname - field name
NoSuchFieldException - no matching field foundpublic static PowerlessArray<Field> fields(Class<?> type)
This method wraps Class.getFields().
type - object type
public static <T> Constructor<T> constructor(Class<T> type,
Class<?>... args)
throws NoSuchMethodException
This method wraps Class.getConstructor(java.lang.Class...).
type - class to searchargs - each parameter type
NoSuchMethodException - no matching constructor foundpublic static PowerlessArray<Constructor<?>> constructors(Class<?> type)
This method wraps Class.getConstructors().
type - class to search
public static Method method(Class<?> type,
String name,
Class<?>... args)
throws NoSuchMethodException
This method wraps Class.getMethod(java.lang.String, java.lang.Class...).
type - class to searchname - method nameargs - each parameter type
NoSuchMethodException - no matching method foundpublic static PowerlessArray<Method> methods(Class<?> type)
This method wraps Class.getMethods().
type - object type
public static String getName(Class<?> c)
Class object,
in the same format as returned by Class.getName(). This wrapper
exists to avoid exposing the number of proxy interfaces that have been
generated.
c - the class to get the name of
c
IllegalArgumentException - if c is a proxy classpublic static Object get(Field field,
Object self)
throws IllegalAccessException
field - field to accessself - target object
IllegalAccessException - field is inaccessiblepublic static void set(Field field,
Object self,
Object value)
throws IllegalAccessException
field - field to accessself - target objectvalue - new value
IllegalAccessException - field is inaccessiblepublic static <T> T construct(Constructor<T> ctor,
Object... args)
throws Exception
ctor - constructor to invokeargs - each argument
IllegalAccessException - ctor is inaccessible
ClassCastException - ctor.newInstance() throws an
IllegalArgumentException, usually due to mismatched types
Exception - an exception thrown by the invoked constructorpublic static Object invoke(Method method,
Object self,
Object... args)
throws Exception
method - method to invokeself - target objectargs - each argument
IllegalAccessException - method is inaccessible
ClassCastException - method.invoke() throws an
IllegalArgumentException, usually due to mismatched types
Exception - an exception thrown by the invoked method
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||