|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.ibatis.common.beans.StaticBeanProbe
StaticBeanProbe provides methods that allow simple, reflective access to JavaBeans style properties. Methods are provided for all simple types as well as object types.
Examples:
StaticBeanProbe.setObject(object, propertyName, value);
Object value = StaticBeanProbe.getObject(object, propertyName);
Field Summary | |
private static java.lang.Object[] |
NO_ARGUMENTS
|
private static boolean |
useMetaClasses
|
Constructor Summary | |
StaticBeanProbe()
|
Method Summary | |
static boolean |
beanEquals(java.lang.Object object1,
java.lang.Object object2)
Compares two beans to see if all properties/values are the same |
static boolean |
beanEquals(java.lang.Object object1,
java.lang.Object object2,
java.lang.String[] properties)
Compares two beans to see if a subset of their properties/values are the same |
private static boolean |
beanEquals(java.lang.Object object1,
java.lang.Object object2,
java.lang.String[] properties,
java.util.Set alreadyChecked)
|
static int |
beanHashCode(java.lang.Object object)
Calculates a hash code for all readable properties of a bean |
static int |
beanHashCode(java.lang.Object object,
java.lang.String[] properties)
Calculates a hash code for a subset of the readable properties of a bean |
private static int |
beanHashCode(java.lang.Object object,
java.lang.String[] properties,
java.util.Set alreadyDigested)
|
private static java.lang.Object |
getArrayProperty(java.lang.Object object,
java.lang.String indexedName)
|
static boolean |
getBoolean(java.lang.Object object,
java.lang.String name)
Gets a boolean value from a bean |
static byte |
getByte(java.lang.Object object,
java.lang.String name)
Gets a byte value from a bean |
char |
getCharacter(java.lang.Object object,
java.lang.String name)
Gets a char value from a bean |
static java.util.Date |
getDate(java.lang.Object object,
java.lang.String name)
Gets a Date value from a bean |
static double |
getDouble(java.lang.Object object,
java.lang.String name)
Gets a double value from a bean |
static java.lang.Object |
getField(java.lang.Object object,
java.lang.String name)
Provides direct access (get value) to class fields through reflection. |
static float |
getFloat(java.lang.Object object,
java.lang.String name)
Gets a float value from a bean |
static int |
getInteger(java.lang.Object object,
java.lang.String name)
Gets a Integer value from a bean |
static long |
getLong(java.lang.Object object,
java.lang.String name)
Gets a long value from a bean |
static java.lang.Object |
getObject(java.lang.Object object,
java.lang.String name)
Gets an Object property from a bean |
private static java.lang.Object |
getProperty(java.lang.Object object,
java.lang.String name)
|
static java.lang.Class |
getPropertyTypeForGetter(java.lang.Object object,
java.lang.String name)
Returns the class that the getter will return when reading a property value. |
static java.lang.Class |
getPropertyTypeForSetter(java.lang.Object object,
java.lang.String name)
Returns the class that the setter expects to receive as a parameter when setting a property value. |
static java.lang.String[] |
getReadablePropertyNames(java.lang.Object object)
Returns an array of the readable properties exposed by a bean |
static short |
getShort(java.lang.Object object,
java.lang.String name)
Gets a short value from a bean |
static java.lang.String |
getString(java.lang.Object object,
java.lang.String name)
Gets a String value from a bean |
static java.lang.String[] |
getWriteablePropertyNames(java.lang.Object object)
Returns an array of the writeable properties exposed by a bean |
static boolean |
hasReadableProperty(java.lang.Object object,
java.lang.String propertyName)
Checks to see if a bean has a readable property be a given name |
static boolean |
hasWritableProperty(java.lang.Object object,
java.lang.String propertyName)
Checks to see if a bean has a writable property be a given name |
private static boolean |
isSimpleType(java.lang.Object value)
|
static boolean |
isUseMetaClasses()
|
private static void |
setArrayProperty(java.lang.Object object,
java.lang.String indexedName,
java.lang.Object value)
|
static void |
setBoolean(java.lang.Object object,
java.lang.String name,
boolean value)
Sets the value of a bean property to a boolean |
static void |
setByte(java.lang.Object object,
java.lang.String name,
byte value)
Sets the value of a bean property to a byte |
static void |
setCharacter(java.lang.Object object,
java.lang.String name,
char value)
Sets the value of a bean property to a char |
static void |
setDate(java.lang.Object object,
java.lang.String name,
java.util.Date value)
Sets the value of a bean property to a Date |
static void |
setDouble(java.lang.Object object,
java.lang.String name,
double value)
Sets the value of a bean property to a double |
static void |
setField(java.lang.Object object,
java.lang.String name,
java.lang.Object value)
Provides direct access (set value) to class fields through reflection. |
static void |
setFloat(java.lang.Object object,
java.lang.String name,
float value)
Sets the value of a bean property to a float |
static void |
setInteger(java.lang.Object object,
java.lang.String name,
int value)
Sets the value of a bean property to a int |
static void |
setLong(java.lang.Object object,
java.lang.String name,
long value)
Sets the value of a bean property to a long |
static void |
setObject(java.lang.Object object,
java.lang.String name,
java.lang.Object value)
Sets the value of a bean property to an Object |
private static void |
setProperty(java.lang.Object object,
java.lang.String name,
java.lang.Object value)
|
static void |
setShort(java.lang.Object object,
java.lang.String name,
short value)
Sets the value of a bean property to a short |
static void |
setString(java.lang.Object object,
java.lang.String name,
java.lang.String value)
Sets the value of a bean property to a String |
static void |
setUseMetaClasses(boolean useMetaClasses)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private static final java.lang.Object[] NO_ARGUMENTS
private static boolean useMetaClasses
Constructor Detail |
public StaticBeanProbe()
Method Detail |
public static boolean isUseMetaClasses()
public static void setUseMetaClasses(boolean useMetaClasses)
public static void setField(java.lang.Object object, java.lang.String name, java.lang.Object value)
Warning: This is a dangerous method that should never be used in production. However, it may be quite valueable for testing purposes.
object
- The object to modifyname
- The name of the property to modifyvalue
- The new value to setpublic static java.lang.Object getField(java.lang.Object object, java.lang.String name)
Warning: This is a dangerous method that should never be used in production. However, it may be quite valueable for testing purposes.
object
- The bean to get the value fromname
- The name of the property to read
public static java.lang.String[] getReadablePropertyNames(java.lang.Object object)
object
- The bean
public static java.lang.String[] getWriteablePropertyNames(java.lang.Object object)
object
- The bean
public static boolean beanEquals(java.lang.Object object1, java.lang.Object object2)
object1
- Bean oneobject2
- Bean two
public static boolean beanEquals(java.lang.Object object1, java.lang.Object object2, java.lang.String[] properties)
object1
- Bean oneobject2
- Bean twoproperties
- The subset of properties to check
private static boolean beanEquals(java.lang.Object object1, java.lang.Object object2, java.lang.String[] properties, java.util.Set alreadyChecked)
public static int beanHashCode(java.lang.Object object)
object
- The bean to calculate the hash code for
public static int beanHashCode(java.lang.Object object, java.lang.String[] properties)
object
- The bean to calculate the hash code forproperties
- A list of the properties to hash
private static int beanHashCode(java.lang.Object object, java.lang.String[] properties, java.util.Set alreadyDigested)
private static boolean isSimpleType(java.lang.Object value)
public static java.lang.Class getPropertyTypeForSetter(java.lang.Object object, java.lang.String name)
object
- The bean to checkname
- The name of the property
public static java.lang.Class getPropertyTypeForGetter(java.lang.Object object, java.lang.String name)
object
- The bean to checkname
- The name of the property
private static java.lang.Object getArrayProperty(java.lang.Object object, java.lang.String indexedName)
private static java.lang.Object getProperty(java.lang.Object object, java.lang.String name)
private static void setArrayProperty(java.lang.Object object, java.lang.String indexedName, java.lang.Object value)
private static void setProperty(java.lang.Object object, java.lang.String name, java.lang.Object value)
public static java.lang.Object getObject(java.lang.Object object, java.lang.String name)
object
- The beanname
- The property name
public static void setObject(java.lang.Object object, java.lang.String name, java.lang.Object value)
object
- The bean to changename
- The name of the property to setvalue
- The new value to setpublic static java.lang.String getString(java.lang.Object object, java.lang.String name)
object
- The bean to get the value fromname
- The name of the property to get
public static void setString(java.lang.Object object, java.lang.String name, java.lang.String value)
object
- The bean to changename
- The name of the property to setvalue
- The new value to setpublic static int getInteger(java.lang.Object object, java.lang.String name)
object
- The bean to get the value fromname
- The name of the property to get
public static void setInteger(java.lang.Object object, java.lang.String name, int value)
object
- The bean to changename
- The name of the property to setvalue
- The new value to setpublic static long getLong(java.lang.Object object, java.lang.String name)
object
- The bean to get the value fromname
- The name of the property to get
public static void setLong(java.lang.Object object, java.lang.String name, long value)
object
- The bean to changename
- The name of the property to setvalue
- The new value to setpublic static short getShort(java.lang.Object object, java.lang.String name)
object
- The bean to get the value fromname
- The name of the property to get
public static void setShort(java.lang.Object object, java.lang.String name, short value)
object
- The bean to changename
- The name of the property to setvalue
- The new value to setpublic static byte getByte(java.lang.Object object, java.lang.String name)
object
- The bean to get the value fromname
- The name of the property to get
public static void setByte(java.lang.Object object, java.lang.String name, byte value)
object
- The bean to changename
- The name of the property to setvalue
- The new value to setpublic char getCharacter(java.lang.Object object, java.lang.String name)
object
- The bean to get the value fromname
- The name of the property to get
public static void setCharacter(java.lang.Object object, java.lang.String name, char value)
object
- The bean to changename
- The name of the property to setvalue
- The new value to setpublic static double getDouble(java.lang.Object object, java.lang.String name)
object
- The bean to get the value fromname
- The name of the property to get
public static void setDouble(java.lang.Object object, java.lang.String name, double value)
object
- The bean to changename
- The name of the property to setvalue
- The new value to setpublic static float getFloat(java.lang.Object object, java.lang.String name)
object
- The bean to get the value fromname
- The name of the property to get
public static void setFloat(java.lang.Object object, java.lang.String name, float value)
object
- The bean to changename
- The name of the property to setvalue
- The new value to setpublic static boolean getBoolean(java.lang.Object object, java.lang.String name)
object
- The bean to get the value fromname
- The name of the property to get
public static void setBoolean(java.lang.Object object, java.lang.String name, boolean value)
object
- The bean to changename
- The name of the property to setvalue
- The new value to setpublic static java.util.Date getDate(java.lang.Object object, java.lang.String name)
object
- The bean to get the value fromname
- The name of the property to get
public static void setDate(java.lang.Object object, java.lang.String name, java.util.Date value)
object
- The bean to changename
- The name of the property to setvalue
- The new value to setpublic static boolean hasWritableProperty(java.lang.Object object, java.lang.String propertyName)
object
- The bean to checkpropertyName
- The property to check for
public static boolean hasReadableProperty(java.lang.Object object, java.lang.String propertyName)
object
- The bean to checkpropertyName
- The property to check for
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |