|
|||||||||
| Home >> All >> org >> progeeks >> [ util overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.progeeks.util
Class Inspector

java.lang.Objectorg.progeeks.util.Inspector
- public class Inspector
- extends java.lang.Object
A utility for doing simple Bean-like reflection.
- Since:
- 1.0
- Version:
- $Revision: 1.3 $
| Field Summary | |
(package private) static org.progeeks.util.log.Log |
log
|
protected java.lang.Object |
object
The object upon which inspection is done. |
protected java.lang.Class |
type
The class of the object upon which inspection is done. |
| Constructor Summary | |
Inspector()
Creates a new Inspector object with no internal object. |
|
Inspector(java.lang.Object object)
Creates a new Inspector object with the specified internal object. |
|
| Method Summary | |
java.lang.Object |
callMethod(java.lang.String name)
|
java.lang.Object |
callMethod(java.lang.String name,
java.lang.String param)
|
java.lang.Object |
get(java.lang.String name)
Returns the value of the specified property. |
private java.lang.reflect.Method |
getAccessor(java.lang.String name)
Returns the "get" method of the specified property. |
private java.lang.reflect.Method |
getDynamicAccessor()
Returns the "get" method for dynamic properties, ie: get( String ). |
private java.lang.reflect.Method |
getDynamicMutator(java.lang.String name)
Returns the "set" method for dynamic properties. |
private java.lang.reflect.Method |
getDynamicMutator(java.lang.String name,
java.lang.Class type)
Returns the "set" method of the specified property and type. |
java.lang.Class |
getDynamicType()
Returns the type for dynamic properties. |
private java.lang.reflect.Method |
getMethod(java.lang.String name,
java.lang.Class[] parms)
|
private java.lang.reflect.Method |
getMutator(java.lang.String name)
Returns the "set" method of the specified property. |
private java.lang.reflect.Method |
getMutator(java.lang.String name,
java.lang.Class type)
Returns the "set" method of the specified property and type. |
java.lang.Object |
getObject()
Returns the object upon which inspection is done. |
java.lang.Class |
getType(java.lang.String name)
Returns the type of the specified property. |
static boolean |
hasConstructor(java.lang.Class type,
java.lang.Class[] argTypes)
|
boolean |
hasMutator(java.lang.String name,
java.lang.Class type)
Returns true if the contained object has a set method for the specified field and type. |
static java.lang.Object |
newInstance(java.lang.Class type)
Creates a new object of the specified class using the no-argument constructor. |
static java.lang.Object |
newInstance(java.lang.Class type,
java.lang.Object[] args)
Creates a new object of the specified class using the constructor that takes the specified parameters. |
static java.lang.Object |
newInstance(java.lang.Class type,
java.lang.Object[] args,
java.lang.Class[] argTypes)
Creates a new object of the specified class using the constructor that takes the specified parameters of the specified types. |
static java.lang.Object |
newInstance(java.lang.String type)
Creates a new object of the specified class name using the no-argument constructor. |
static java.lang.Object |
newInstance(java.lang.String className,
java.lang.Object[] args,
java.lang.Class[] argTypes)
Creates a new object of the specified class by converting the class name to a class object and using the constructor that takes the specified parameters of the specified types. |
private java.lang.String |
propertyName(java.lang.String name)
|
void |
set(java.lang.String name,
java.lang.Object value)
Sets the value of the specified property. |
void |
set(java.lang.String name,
java.lang.Object value,
java.lang.Class type)
Sets the value of the specified property using a specifically overloaded mutator method. |
void |
setObject(java.lang.Object object)
Sets the object upon which inspection will be performed. |
static java.lang.Class |
translateFromPrimitive(java.lang.Class primitive)
If this specified class represents a primitive type (int, float, etc.) then it is translated into its wrapper type (Integer, Float, etc.). |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
log
static org.progeeks.util.log.Log log
object
protected java.lang.Object object
- The object upon which inspection is done.
type
protected java.lang.Class type
- The class of the object upon which inspection is done.
| Constructor Detail |
Inspector
public Inspector()
- Creates a new Inspector object with no internal object.
Inspector
public Inspector(java.lang.Object object)
- Creates a new Inspector object with the specified internal object.
| Method Detail |
translateFromPrimitive
public static java.lang.Class translateFromPrimitive(java.lang.Class primitive)
- If this specified class represents a primitive type (int, float, etc.) then
it is translated into its wrapper type (Integer, Float, etc.). If the
passed class is not a primitive then it is just returned.
newInstance
public static java.lang.Object newInstance(java.lang.Class type)
- Creates a new object of the specified class using the no-argument
constructor.
newInstance
public static java.lang.Object newInstance(java.lang.String type)
- Creates a new object of the specified class name using the no-argument
constructor.
newInstance
public static java.lang.Object newInstance(java.lang.Class type, java.lang.Object[] args)
- Creates a new object of the specified class using the constructor that
takes the specified parameters.
hasConstructor
public static boolean hasConstructor(java.lang.Class type, java.lang.Class[] argTypes)
newInstance
public static java.lang.Object newInstance(java.lang.Class type, java.lang.Object[] args, java.lang.Class[] argTypes)
- Creates a new object of the specified class using the constructor that
takes the specified parameters of the specified types.
newInstance
public static java.lang.Object newInstance(java.lang.String className, java.lang.Object[] args, java.lang.Class[] argTypes)
- Creates a new object of the specified class by converting the class name
to a class object and using the constructor that takes the specified
parameters of the specified types.
setObject
public void setObject(java.lang.Object object)
- Sets the object upon which inspection will be performed.
getObject
public java.lang.Object getObject()
- Returns the object upon which inspection is done.
set
public void set(java.lang.String name, java.lang.Object value) throws InspectionException
- Sets the value of the specified property.
set
public void set(java.lang.String name, java.lang.Object value, java.lang.Class type) throws InspectionException
- Sets the value of the specified property using a specifically overloaded
mutator method.
hasMutator
public boolean hasMutator(java.lang.String name, java.lang.Class type)
- Returns true if the contained object has a set method for the
specified field and type.
get
public java.lang.Object get(java.lang.String name)
- Returns the value of the specified property.
getType
public java.lang.Class getType(java.lang.String name)
- Returns the type of the specified property.
getAccessor
private java.lang.reflect.Method getAccessor(java.lang.String name)
- Returns the "get" method of the specified property.
getDynamicAccessor
private java.lang.reflect.Method getDynamicAccessor()
- Returns the "get" method for dynamic properties, ie: get( String ).
getDynamicType
public java.lang.Class getDynamicType()
- Returns the type for dynamic properties.
getMutator
private java.lang.reflect.Method getMutator(java.lang.String name)
- Returns the "set" method of the specified property.
getMutator
private java.lang.reflect.Method getMutator(java.lang.String name, java.lang.Class type)
- Returns the "set" method of the specified property and type.
getDynamicMutator
private java.lang.reflect.Method getDynamicMutator(java.lang.String name)
- Returns the "set" method for dynamic properties. A dynamic property
mutator is a set() method that takes a name and value pair.
getDynamicMutator
private java.lang.reflect.Method getDynamicMutator(java.lang.String name, java.lang.Class type)
- Returns the "set" method of the specified property and type.
propertyName
private java.lang.String propertyName(java.lang.String name)
callMethod
public java.lang.Object callMethod(java.lang.String name, java.lang.String param)
callMethod
public java.lang.Object callMethod(java.lang.String name)
getMethod
private java.lang.reflect.Method getMethod(java.lang.String name, java.lang.Class[] parms)
|
|||||||||
| Home >> All >> org >> progeeks >> [ util overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
org.progeeks.util.Inspector