com.ibatis.common.beans
Class GenericProbe

java.lang.Object
  extended bycom.ibatis.common.beans.BaseProbe
      extended bycom.ibatis.common.beans.GenericProbe
All Implemented Interfaces:
Probe

public class GenericProbe
extends BaseProbe

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);


Constructor Summary
protected GenericProbe()
           
 
Method Summary
 java.lang.Object getObject(java.lang.Object object, java.lang.String name)
          Gets an object from a Map or bean
protected  java.lang.Object getProperty(java.lang.Object object, java.lang.String property)
           
 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.
 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.
 java.lang.String[] getReadablePropertyNames(java.lang.Object object)
          Gets an array of the readable properties in a Map or JavaBean
 java.lang.String[] getWriteablePropertyNames(java.lang.Object object)
          Gets an array of the writeable properties in a Map or JavaBean
 boolean hasReadableProperty(java.lang.Object object, java.lang.String propertyName)
          Checks to see if a bean has a readable property by a given name
 boolean hasWritableProperty(java.lang.Object object, java.lang.String propertyName)
          Checks to see if an object has a writable property by a given name
 void setObject(java.lang.Object object, java.lang.String name, java.lang.Object value)
          Sets an object in a Map or bean
protected  void setProperty(java.lang.Object object, java.lang.String property, java.lang.Object value)
           
 
Methods inherited from class com.ibatis.common.beans.BaseProbe
getIndexedProperty, getIndexedType, setIndexedProperty
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GenericProbe

protected GenericProbe()
Method Detail

getObject

public java.lang.Object getObject(java.lang.Object object,
                                  java.lang.String name)
Gets an object from a Map or bean

Parameters:
object - - the object to probe
name - - the name of the property (or map entry)
Returns:
The value of the property (or map entry)
See Also:
Probe.getObject(java.lang.Object, java.lang.String)

setObject

public void setObject(java.lang.Object object,
                      java.lang.String name,
                      java.lang.Object value)
Sets an object in a Map or bean

Parameters:
object - - the object to probe
name - - the name of the property (or map entry)
value - - the new value of the property (or map entry)
See Also:
Probe.setObject(java.lang.Object, java.lang.String, java.lang.Object)

getReadablePropertyNames

public java.lang.String[] getReadablePropertyNames(java.lang.Object object)
Gets an array of the readable properties in a Map or JavaBean

Specified by:
getReadablePropertyNames in class BaseProbe
Parameters:
object - - the object to get properties for
Returns:
The array of properties (or map entries)
See Also:
BaseProbe.getReadablePropertyNames(java.lang.Object)

getWriteablePropertyNames

public java.lang.String[] getWriteablePropertyNames(java.lang.Object object)
Gets an array of the writeable properties in a Map or JavaBean

Specified by:
getWriteablePropertyNames in class BaseProbe
Parameters:
object - - the object to get properties for
Returns:
The array of properties (or map entries)
See Also:
BaseProbe.getWriteablePropertyNames(java.lang.Object)

getPropertyTypeForSetter

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

Parameters:
object - - The class to check
name - - the name of the property
Returns:
The type of the property
See Also:
Probe.getPropertyTypeForSetter(java.lang.Object, java.lang.String)

getPropertyTypeForGetter

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

Parameters:
object - The bean to check
name - The name of the property
Returns:
The type of the property
See Also:
Probe.getPropertyTypeForGetter(java.lang.Object, java.lang.String)

hasWritableProperty

public boolean hasWritableProperty(java.lang.Object object,
                                   java.lang.String propertyName)
Checks to see if an object has a writable property by a given name

Parameters:
object - The bean to check
propertyName - The property to check for
Returns:
True if the property exists and is writable
See Also:
Probe.hasWritableProperty(java.lang.Object, java.lang.String)

hasReadableProperty

public boolean hasReadableProperty(java.lang.Object object,
                                   java.lang.String propertyName)
Checks to see if a bean has a readable property by a given name

Parameters:
object - The bean to check
propertyName - The property to check for
Returns:
True if the property exists and is readable
See Also:
Probe.hasReadableProperty(java.lang.Object, java.lang.String)

setProperty

protected void setProperty(java.lang.Object object,
                           java.lang.String property,
                           java.lang.Object value)
Specified by:
setProperty in class BaseProbe

getProperty

protected java.lang.Object getProperty(java.lang.Object object,
                                       java.lang.String property)
Specified by:
getProperty in class BaseProbe