org.xith3d.utility.classes.beans
Class BeanUtil

java.lang.Object
  extended by org.xith3d.utility.classes.beans.BeanUtil

public class BeanUtil
extends java.lang.Object

Bean util class for runtime use of get/set methods based on member name via Reflection, or field setting if available


Nested Class Summary
static class BeanUtil.NoGetterException
          This Exception is thrown when no getter has been found
static class BeanUtil.NoSetterException
          This Exception is thrown when no setter has been found
 
Constructor Summary
BeanUtil()
           
 
Method Summary
static java.lang.Object get(java.lang.Object object, java.lang.String member)
          Get a member using a getter method, or if there isn't any, try to retry it via member access if it's public.
static java.lang.reflect.Method getGetter(java.lang.Object object, java.lang.String member)
          Finds the appropriate the getter for an Object.
static java.lang.reflect.Method getSetter(java.lang.Object object, java.lang.String member)
          Finds the appropriate setter for the member of an object.
static void set(java.lang.Object object, java.lang.String member, java.lang.Object value)
          Sets a member to a value using a setter method, or if none found, using member access if the member is public
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BeanUtil

public BeanUtil()
Method Detail

get

public static java.lang.Object get(java.lang.Object object,
                                   java.lang.String member)
Get a member using a getter method, or if there isn't any, try to retry it via member access if it's public.

Parameters:
object - The object from which to get the member
member - The member to get
Returns:
The value of the member asked for, or null if there's no getter

getGetter

public static java.lang.reflect.Method getGetter(java.lang.Object object,
                                                 java.lang.String member)
                                          throws BeanUtil.NoGetterException
Finds the appropriate the getter for an Object.

Parameters:
object - The object
member - The member
Returns:
The getter for the specified member of this Object
Throws:
BeanUtil.NoGetterException - if no getter can be found

set

public static void set(java.lang.Object object,
                       java.lang.String member,
                       java.lang.Object value)
Sets a member to a value using a setter method, or if none found, using member access if the member is public

Parameters:
object - The object of which to set the member
member - The member to change
value - The value to set the member to

getSetter

public static java.lang.reflect.Method getSetter(java.lang.Object object,
                                                 java.lang.String member)
                                          throws BeanUtil.NoSetterException
Finds the appropriate setter for the member of an object.

Parameters:
object - The object
member - Its member
Returns:
The setter
Throws:
BeanUtil.NoSetterException - if no setter can be found