org.objectweb.telosys.util
Class BeanUtil

java.lang.Object
  extended byorg.objectweb.telosys.util.BeanUtil

public class BeanUtil
extends java.lang.Object


Field Summary
static int ALL_METHODS
           
static int CLASS_DECLARED_METHODS
           
 
Constructor Summary
BeanUtil()
           
 
Method Summary
static java.lang.String getAttributeName(java.lang.String sName)
           
static java.lang.String getBeanName(java.lang.String sName)
          Returns the "bean name" from the variable name ( in standard "dot notation" )
static java.lang.Object getFieldValue(java.lang.Object oBean, java.lang.String sFieldName)
          Returns the value of the given bean field using reflection
static void shallowCopy(java.lang.Object orig, java.lang.Object dest)
          Shallow copy of a bean to another, attribute by attribute :
call "setXxxx" with corresponding "getXxxx" or "isXxxx"
NB: the 2 beans must be instances of the same class
static void shallowCopy(java.lang.Object orig, java.lang.Object dest, int iFlag)
          Shallow copy of a bean to another, attribute by attribute :
call "setXxxx" with corresponding "getXxxx" or "isXxxx"
NB: the 2 beans must be instances of the same class
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ALL_METHODS

public static final int ALL_METHODS
See Also:
Constant Field Values

CLASS_DECLARED_METHODS

public static final int CLASS_DECLARED_METHODS
See Also:
Constant Field Values
Constructor Detail

BeanUtil

public BeanUtil()
Method Detail

shallowCopy

public static final void shallowCopy(java.lang.Object orig,
                                     java.lang.Object dest)
Shallow copy of a bean to another, attribute by attribute :
call "setXxxx" with corresponding "getXxxx" or "isXxxx"
NB: the 2 beans must be instances of the same class

Parameters:
orig - : the original bean to copy
dest - : the destination bean

shallowCopy

public static final void shallowCopy(java.lang.Object orig,
                                     java.lang.Object dest,
                                     int iFlag)
Shallow copy of a bean to another, attribute by attribute :
call "setXxxx" with corresponding "getXxxx" or "isXxxx"
NB: the 2 beans must be instances of the same class

Parameters:
orig - : the original bean to copy
dest - : the destination bean
iFlag - : indicates the introspection level :
ALL_METHODS : all the public methods including those inherited
CLASS_DECLARED_METHODS : only the methods declared by the class (without inherited methods)

getFieldValue

public static java.lang.Object getFieldValue(java.lang.Object oBean,
                                             java.lang.String sFieldName)
                                      throws TelosysException
Returns the value of the given bean field using reflection

Parameters:
oBean - : the bean instance
sFieldName - : the field name
Returns:
: the value found
Throws:
TelosysException - if the field name is unknown or if arguments are invalid

getBeanName

public static java.lang.String getBeanName(java.lang.String sName)
Returns the "bean name" from the variable name ( in standard "dot notation" )

Parameters:
sName - : the variable name to parse ( 'bean.attribute' )
Returns:
: the "bean name" part : 'aaa' for 'aaa.bbb', 'aaa' for 'aaa' or null for '.aaa'

getAttributeName

public static java.lang.String getAttributeName(java.lang.String sName)
Parameters:
sName - : the variable name to parse ( 'bean.attribute', 'bean', '.attribute' )
Returns:
: the "attribute name" part ( 'attr' for 'bean.attr' or '.attr' )
or null for 'bean', 'aa.bb.cc', ''