| java.lang.Object org.araneaframework.backend.util.BeanUtil
Field Summary | |
final public static char | NESTED_DELIM The delimiter that separates the components of a nested reference. |
Method Summary | |
public static Object | clone(Object bean) Clones bean by copying its fields values (references) to a
new instance of the same type.
Parameters: bean - bean Object, which value to set. | public static Object | copy(Object from, Object to) Sets all the fields with same names to same values.
NB! the values are references (there'is no deep copy made)!
from Bean fields that are not supported by to
are ignored. | public static Object | copy(Object from, Class toType) Creates a new instance of Class toType and sets its field values to be
the same as given from Object. | public static void | fillFieldValue(Object bean, String field, Object value) Sets the value of Bean field identified by name field for
object bean . | public static Class | getFieldType(Class beanClass, String field) Returns type of Bean field identified by name field .
Null is returned if no such method found.
Parameters: beanClass - the class implementing the Bean pattern. Parameters: field - The name of Bean field. | public static Object | getFieldValue(Object bean, String field) Returns the value of Bean field identified with name field
for object bean .
Returns null if no bean specified or such method found.
Parameters: bean - Object, which value to return. Parameters: field - The name of VO field. | public static List | getFields(Class beanClass) Returns List<String> - the List of Bean
field names.
Only simple fields (not nested) are returned.
Parameters: beanClass - the class implementing the Bean pattern. | public static Method | getReadMethod(Class beanClass, String field) Returns read method (getter) for the field.
Null is returned if no such method found.
Parameters: beanClass - the class implementing the Bean pattern. Parameters: field - Bean field name. | public static Method | getWriteMethod(Class beanClass, String field) Returns write method (setter) for the field.
Null is returned if no such method found.
Parameters: beanClass - the class implementing the Bean pattern. Parameters: field - Bean field name. | public static boolean | isBean(Class clazz) Returns whether the given object type is a Bean type.
Parameters: clazz - the class. | public static boolean | isReadable(Class beanClass, String field) Checks that the field identified by field is a valid
Bean field (can be read-only).
To enable reading the field, the spcfified beanClass must
have getter (field's name starts with get or
is ) for this field.
Parameters: beanClass - the class implementing the Bean pattern. Parameters: field - Bean field name. | public static boolean | isWritable(Class beanClass, String field) Checks that the field identified by field is a writable
Bean field.
To enable writing the field, the spcfified beanClass must
have setter (field's name starts with set ) for this field.
Parameters: beanClass - the class implementing the Bean pattern. Parameters: field - Bean field name. | public static Object | newInstance(Class beanClass) Creates new instance of the specified beanClass .
In order to be Bean type, it must have a constructor without arguments. | public static void | setFieldValue(Object bean, String field, Object value) Sets the value of Bean field identified by name field for
object bean .
Nothing happens if no bean specified, one of its sub-field is null or
no such method found.
If one of the sub-fields (not the last one) is null, they are not
automatically propagated. |
NESTED_DELIM | final public static char NESTED_DELIM(Code) | | The delimiter that separates the components of a nested reference.
|
copy | public static Object copy(Object from, Object to)(Code) | | Sets all the fields with same names to same values.
NB! the values are references (there'is no deep copy made)!
from Bean fields that are not supported by to
are ignored.
Parameters: from - Bean from which to convert. Parameters: to - Bean to which to convert. to with values See Also: BeanUtil.copy(Object,Class) |
copy | public static Object copy(Object from, Class toType)(Code) | | Creates a new instance of Class toType and sets its field values to be
the same as given from Object. Only fields with same names that exist in
both from object and toType class are affected.
Parameters: from - Bean from which to read field values. Parameters: toType - Class which object instance to create. new instance of toType with from values See Also: BeanUtil.copy(Object,Object) See Also: BeanUtil.clone() See Also: |
fillFieldValue | public static void fillFieldValue(Object bean, String field, Object value)(Code) | | Sets the value of Bean field identified by name field for
object bean .
Nothing happens if no bean specified or such method found.
This method is identical to
BeanUtil.setFieldValue(Object,String,Object) except that mssing beans
in sub-fields (not the last one) of bean Object are created
automatically.
Parameters: bean - bean Object, which value to set. Parameters: field - The name of Bean field. Parameters: value - The new value of the field. See Also: BeanUtil.setFieldValue(Object,String,Object) |
getFieldType | public static Class getFieldType(Class beanClass, String field)(Code) | | Returns type of Bean field identified by name field .
Null is returned if no such method found.
Parameters: beanClass - the class implementing the Bean pattern. Parameters: field - The name of Bean field. The type of the field. |
getFieldValue | public static Object getFieldValue(Object bean, String field)(Code) | | Returns the value of Bean field identified with name field
for object bean .
Returns null if no bean specified or such method found.
Parameters: bean - Object, which value to return. Parameters: field - The name of VO field. The value of the field. |
getFields | public static List getFields(Class beanClass)(Code) | | Returns List<String> - the List of Bean
field names.
Only simple fields (not nested) are returned.
Parameters: beanClass - the class implementing the Bean pattern. List<String> - the List of Beanfield names. |
getReadMethod | public static Method getReadMethod(Class beanClass, String field)(Code) | | Returns read method (getter) for the field.
Null is returned if no such method found.
Parameters: beanClass - the class implementing the Bean pattern. Parameters: field - Bean field name. read method (getter) for the field. |
getWriteMethod | public static Method getWriteMethod(Class beanClass, String field)(Code) | | Returns write method (setter) for the field.
Null is returned if no such method found.
Parameters: beanClass - the class implementing the Bean pattern. Parameters: field - Bean field name. write method (setter) for the field. |
isBean | public static boolean isBean(Class clazz)(Code) | | Returns whether the given object type is a Bean type.
Parameters: clazz - the class. whether the given object type is a Bean type. |
isReadable | public static boolean isReadable(Class beanClass, String field)(Code) | | Checks that the field identified by field is a valid
Bean field (can be read-only).
To enable reading the field, the spcfified beanClass must
have getter (field's name starts with get or
is ) for this field.
Parameters: beanClass - the class implementing the Bean pattern. Parameters: field - Bean field name. if this field is in Bean. |
isWritable | public static boolean isWritable(Class beanClass, String field)(Code) | | Checks that the field identified by field is a writable
Bean field.
To enable writing the field, the spcfified beanClass must
have setter (field's name starts with set ) for this field.
Parameters: beanClass - the class implementing the Bean pattern. Parameters: field - Bean field name. if this field is in Bean. |
newInstance | public static Object newInstance(Class beanClass)(Code) | | Creates new instance of the specified beanClass .
In order to be Bean type, it must have a constructor without arguments.
If creating the new instance fails, a RuntimeException is thrown.
Parameters: beanClass - the class implementing the Bean pattern. new instance of the Bean type. |
setFieldValue | public static void setFieldValue(Object bean, String field, Object value)(Code) | | Sets the value of Bean field identified by name field for
object bean .
Nothing happens if no bean specified, one of its sub-field is null or
no such method found.
If one of the sub-fields (not the last one) is null, they are not
automatically propagated. In order for this, use
BeanUtil.fillFieldValue(Object,String,Object) method.
Parameters: bean - bean Object, which value to set. Parameters: field - The name of Bean field. Parameters: value - The new value of the field. See Also: BeanUtil.fillFieldValue(Object,String,Object) |
|
|