public class ObjectGetSetter extends Object
| Modifier and Type | Method and Description |
|---|---|
static Object |
get(Object object,
String fieldName)
Gets the value of a field of an object as an object.
|
static HashMap |
getAll(Object object,
boolean primitivesonly)
Returns a HashMap of name/value pairs for all fields declared by the class or super classes Note: fields with 'private'
modifiers are not picked up.
|
static Field |
getField(Object object,
String fieldName)
Get a field from the class or the super classes of the object
|
static void |
set(Object object,
String fieldName,
String fieldValue)
Sets the field to the specified value in the suppled object Either the field name shoudl exist, or a generic HashMap named
'atributes' should exist Else, teh suppled value is not set.
|
static void |
setAll(Object object,
Attributes values)
Sets values from an Attribute containing bname/value pairs to a corresponding fields of the supplied object.
|
static void |
setAll(Object object,
HashMap values)
Sets values from a HashMap containing bname/value pairs to a corresponding fields of the supplied object.
|
public static Object get(Object object, String fieldName)
object - : object whose field value is to be returnedfieldName - : Name of the fieldpublic static HashMap getAll(Object object, boolean primitivesonly)
object - : object from which the fields are to be extractedprimitivesonly - : Data types, int, Integer, float, Float, ..... and String are considered to be primitive If this
field is set to true, fields of only these type are picked up. Else all fields are picked up.public static Field getField(Object object, String fieldName) throws NoSuchFieldException
object - fieldName - name of teh field to returnNoSuchFieldExceptionpublic static void set(Object object, String fieldName, String fieldValue)
object - fieldName - fieldValue - public static void setAll(Object object, HashMap values)
object - values - public static void setAll(Object object, Attributes values)
object - values - Copyright © 2015–2017 eGovernments Foundation. All rights reserved.