com.threerings.util
Class ReflectionUtil

java.lang.Object
  extended by com.threerings.util.ReflectionUtil

public class ReflectionUtil
extends Object

Some general reflection utility methods.


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).
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
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReflectionUtil

public ReflectionUtil()
Method Detail

newInstance

public static Object newInstance(String classname)
Creates a new instance of the named class.

Parameters:
classname - the name of the class to instantiate.

newInstance

public static Object newInstance(String classname,
                                 Object outer)
Creates a new instance of the named inner class.

Parameters:
classname - the name of the class to instantiate.
outer - an instance of the enclosing class.

newInstance

public static Object newInstance(Class<?> clazz)
Creates a new instance of the specified class.

Parameters:
clazz - the class to instantiate.

newInstance

public static Object newInstance(Class<?> clazz,
                                 Object outer)
Creates a new instance of the specified (possibly inner) class.

Parameters:
clazz - the class to instantiate.
outer - for inner classes, a reference to the enclosing instance (otherwise null).
Returns:
the newly created object, or null if there was some error (in which case a message will be logged).

setOuter

public static void setOuter(Object object,
                            Object outer)
Sets an inner object's outer class reference if it has one.


getOuter

public 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.


isInner

public static boolean isInner(Class<?> clazz)
Determines whether the specified class is a non-static inner class.


getOuterClass

public static Class<?> getOuterClass(Class<?> clazz)
Returns the outer class for the given inner class (or null if not an inner class).



Copyright © 2011. All Rights Reserved.