|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.threerings.util.ReflectionUtil
public class ReflectionUtil
Some general reflection utility methods.
| Field Summary | |
|---|---|
protected static HashMap<Class<?>,Constructor> |
_ctors
Maps classes to their default constructors. |
protected static HashMap<Class<?>,Class<?>> |
_oclasses
Maps classes to their outer classes, or to Void if they are not inner classes. |
protected static HashMap<Class<?>,Field> |
_outers
Maps inner classes to their outer class reference fields. |
| Constructor Summary | |
|---|---|
ReflectionUtil()
|
|
| Method Summary | |
|---|---|
static Object |
getOuter(Object object)
Returns a reference to an inner object's outer class reference, or null if
the object represents an instance of a static class. |
static Class<?> |
getOuterClass(Class<?> clazz)
Returns the outer class for the given inner class (or null if not an inner
class). |
protected static Field |
getOuterField(Class<?> clazz)
Returns a reference to the outer class reference field. |
static boolean |
isInner(Class<?> clazz)
Determines whether the specified class is a non-static inner class. |
static Object |
newInstance(Class<?> clazz)
Creates a new instance of the specified class. |
static Object |
newInstance(Class<?> clazz,
Object outer)
Creates a new instance of the specified (possibly inner) class. |
static Object |
newInstance(String classname)
Creates a new instance of the named class. |
static Object |
newInstance(String classname,
Object outer)
Creates a new instance of the named inner class. |
static void |
setOuter(Object object,
Object outer)
Sets an inner object's outer class reference if it has one. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static HashMap<Class<?>,Field> _outers
protected static HashMap<Class<?>,Class<?>> _oclasses
Void if they are not inner classes.
protected static HashMap<Class<?>,Constructor> _ctors
| Constructor Detail |
|---|
public ReflectionUtil()
| Method Detail |
|---|
public static Object newInstance(String classname)
classname - the name of the class to instantiate.
public static Object newInstance(String classname,
Object outer)
classname - the name of the class to instantiate.outer - an instance of the enclosing class.public static Object newInstance(Class<?> clazz)
clazz - the class to instantiate.
public static Object newInstance(Class<?> clazz,
Object outer)
clazz - the class to instantiate.outer - for inner classes, a reference to the enclosing instance (otherwise
null).
null if there was some error
(in which case a message will be logged).
public static void setOuter(Object object,
Object outer)
public static Object getOuter(Object object)
null if
the object represents an instance of a static class.
public static boolean isInner(Class<?> clazz)
public static Class<?> getOuterClass(Class<?> clazz)
null if not an inner
class).
protected static Field getOuterField(Class<?> clazz)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||