org.kuali.kfs.sys
Class ObjectUtil

java.lang.Object
  extended by org.kuali.kfs.sys.ObjectUtil

public class ObjectUtil
extends Object

This class provides a set of facilities that can be used to manipulate objects, for example, object population


Constructor Summary
ObjectUtil()
           
 
Method Summary
static void buildObject(Object targetObject, Object sourceObject)
          Populate the target object with the source object
static void buildObject(Object targetObject, Object[] sourceObject, List<String> keyFields)
          Populate the given fields of the target object with the values of an array
static void buildObject(Object targetObject, Object sourceObject, List<String> keyFields)
          Populate the given fields of the target object with the corresponding field values of source object
static void buildObjectWithoutReferenceFields(Object targetObject, Object sourceObject)
          Populate the target object with the source object
static Map<String,Object> buildPropertyMap(Object object, List<String> keyFields)
          build a map of business object with its specified property names and corresponding values
static String concatPropertyAsString(Object object, List<String> keyFields)
          concat the specified properties of the given object as a string
static void convertLineToBusinessObject(Object targetObject, String line, int[] fieldLength, List<String> keyFields)
          Tokenize the input line with the given deliminator and populate the given object with values of the tokens
static void convertLineToBusinessObject(Object targetObject, String line, String delim, List<String> keyFields)
          Tokenize the input line with the given deliminator and populate the given object with values of the tokens
static void convertLineToBusinessObject(Object targetObject, String line, String delim, String fieldNames)
          Tokenize the input line with the given deliminator and populate the given object with values of the tokens
static
<T> T
createObject(Class<T> clazz)
          create an object of the specified type
static boolean equals(Object targetObject, Object sourceObject, List<String> keyFields)
          Determine if they have the same values in the specified fields
static Date formatDate(String value)
          convert the given string into a date
static Timestamp formatTimeStamp(String value)
          convert the given string into a timestamp object if the string is in the valid format of timestamp
static int generateHashCode(Object object, List<String> keyFields)
          compute the hash code for the given object from the given fields
static Map<Class<?>,String> getNestedAttributeTypes(Class<?> clazz, String nestedAttribute)
          get the types of the nested attributes starting at the given class
static String getSimpleTypeName(Object targetObject, String propertyName)
           
static boolean hasNullValueField(Object sourceObject)
          determine if the source object has a field with null as its value
static boolean isDecimal(String value)
          determine if the given string can be converted into a decimal
static boolean isInteger(String value)
          determine if the given string can be converted into an Integer
static void populateBusinessObject(Object businessOjbject, Properties properties, String propertyKey, int[] fieldLength, List<String> keyFields)
          Populate a business object with the given properities and information
static void populateBusinessObject(Object businessOjbject, Properties properties, String propertyKey, String fieldNames, String deliminator)
          Populate a business object with the given properities and information
static void setProperty(Object targetObject, Object sourceObject, org.apache.commons.beanutils.DynaProperty property, boolean skipReferenceFields)
          Populate the property of the target object with the counterpart of the source object
static List<String> split(String line, String delim)
          Tokenize the input line with the given deliminator and store the tokens in a list
static Object valueOf(String type, String propertyValue)
          Get an object of the given type holding the property value of the specified String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ObjectUtil

public ObjectUtil()
Method Detail

createObject

public static <T> T createObject(Class<T> clazz)
create an object of the specified type

Parameters:
clazz - the specified type of the object
Returns:
an object of the specified type

buildObject

public static void buildObject(Object targetObject,
                               Object sourceObject,
                               List<String> keyFields)
Populate the given fields of the target object with the corresponding field values of source object

Parameters:
targetObject - the target object
sourceObject - the source object
keyFields - the given fields of the target object that need to be popluated

buildObject

public static void buildObject(Object targetObject,
                               Object[] sourceObject,
                               List<String> keyFields)
Populate the given fields of the target object with the values of an array

Parameters:
targetObject - the target object
sourceObject - the given array
keyFields - the given fields of the target object that need to be popluated

getSimpleTypeName

public static String getSimpleTypeName(Object targetObject,
                                       String propertyName)

valueOf

public static Object valueOf(String type,
                             String propertyValue)
Get an object of the given type holding the property value of the specified String.

Parameters:
type - the given type of the returning object
propertyValue - the property value of the specified string
Returns:
an object of the given type holding the property value of the specified String

isInteger

public static boolean isInteger(String value)
determine if the given string can be converted into an Integer

Parameters:
value - the value of the specified string
Returns:
true if the string can be converted into an Integer; otherwise, return false

isDecimal

public static boolean isDecimal(String value)
determine if the given string can be converted into a decimal

Parameters:
value - the value of the specified string
Returns:
true if the string can be converted into a decimal; otherwise, return false

formatDate

public static Date formatDate(String value)
convert the given string into a date

Parameters:
value - the given string
Returns:
a date converted from the given string

formatTimeStamp

public static Timestamp formatTimeStamp(String value)
convert the given string into a timestamp object if the string is in the valid format of timestamp

Parameters:
value - the given string
Returns:
a timestamp converted from the given string

buildObject

public static void buildObject(Object targetObject,
                               Object sourceObject)
Populate the target object with the source object

Parameters:
targetObject - the target object
sourceObject - the source object

buildObjectWithoutReferenceFields

public static void buildObjectWithoutReferenceFields(Object targetObject,
                                                     Object sourceObject)
Populate the target object with the source object

Parameters:
targetObject - the target object
sourceObject - the source object

setProperty

public static void setProperty(Object targetObject,
                               Object sourceObject,
                               org.apache.commons.beanutils.DynaProperty property,
                               boolean skipReferenceFields)
Populate the property of the target object with the counterpart of the source object

Parameters:
targetObject - the target object
sourceObject - the source object
property - the specified propety of the target object
skipReferenceFields - determine whether the referencing fields need to be populated

equals

public static boolean equals(Object targetObject,
                             Object sourceObject,
                             List<String> keyFields)
Determine if they have the same values in the specified fields

Parameters:
targetObject - the target object
sourceObject - the source object
keyFields - the specified fields
Returns:
true if the two objects have the same values in the specified fields; otherwise, false

generateHashCode

public static int generateHashCode(Object object,
                                   List<String> keyFields)
compute the hash code for the given object from the given fields

Parameters:
object - the given object
keyFields - the specified fields
Returns:
the hash code for the given object from the given fields

buildPropertyMap

public static Map<String,Object> buildPropertyMap(Object object,
                                                  List<String> keyFields)
build a map of business object with its specified property names and corresponding values

Parameters:
businessObject - the given business object
the - specified fields that need to be included in the return map
Returns:
the map of business object with its property names and values

concatPropertyAsString

public static String concatPropertyAsString(Object object,
                                            List<String> keyFields)
concat the specified properties of the given object as a string

Parameters:
object - the given object
the - specified fields that need to be included in the return string
Returns:
the specified properties of the given object as a string

convertLineToBusinessObject

public static void convertLineToBusinessObject(Object targetObject,
                                               String line,
                                               String delim,
                                               List<String> keyFields)
Tokenize the input line with the given deliminator and populate the given object with values of the tokens

Parameters:
targetObject - the target object
line - the input line
delim - the deminator that separates the fields in the given line
keyFields - the specified fields

convertLineToBusinessObject

public static void convertLineToBusinessObject(Object targetObject,
                                               String line,
                                               String delim,
                                               String fieldNames)
Tokenize the input line with the given deliminator and populate the given object with values of the tokens

Parameters:
targetObject - the target object
line - the input line
delim - the deminator that separates the fields in the given line
keyFields - the specified fields

split

public static List<String> split(String line,
                                 String delim)
Tokenize the input line with the given deliminator and store the tokens in a list

Parameters:
line - the input line
delim - the deminator that separates the fields in the given line
Returns:
a list of tokens

convertLineToBusinessObject

public static void convertLineToBusinessObject(Object targetObject,
                                               String line,
                                               int[] fieldLength,
                                               List<String> keyFields)
Tokenize the input line with the given deliminator and populate the given object with values of the tokens

Parameters:
targetObject - the target object
line - the input line
delim - the deminator that separates the fields in the given line
keyFields - the specified fields

populateBusinessObject

public static void populateBusinessObject(Object businessOjbject,
                                          Properties properties,
                                          String propertyKey,
                                          String fieldNames,
                                          String deliminator)
Populate a business object with the given properities and information

Parameters:
businessOjbject - the business object to be populated
properties - the given properties
propertyKey - the property keys in the properties
fieldNames - the names of the fields to be populated
deliminator - the deliminator that separates the values to be used in a string

populateBusinessObject

public static void populateBusinessObject(Object businessOjbject,
                                          Properties properties,
                                          String propertyKey,
                                          int[] fieldLength,
                                          List<String> keyFields)
Populate a business object with the given properities and information

Parameters:
businessOjbject - the business object to be populated
properties - the given properties
propertyKey - the property keys in the properties
fieldNames - the names of the fields to be populated
deliminator - the deliminator that separates the values to be used in a string

hasNullValueField

public static boolean hasNullValueField(Object sourceObject)
determine if the source object has a field with null as its value

Parameters:
sourceObject - the source object

getNestedAttributeTypes

public static Map<Class<?>,String> getNestedAttributeTypes(Class<?> clazz,
                                                           String nestedAttribute)
get the types of the nested attributes starting at the given class

Parameters:
clazz - the given class
nestedAttribute - the nested attributes of the given class
Returns:
a map that contains the types of the nested attributes and the attribute names


Copyright © 2005-2012 The Kuali Foundation. All Rights Reserved.