Class DataUtil
java.lang.Object
org.brijframework.reflection.data.DataUtil
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionObject[]arrayByAddingObjAtZeroIndex(Object object, Object... paramObjects) castObject(Object object, String type) static HashtableconvertCollectionToMap(Collection<?> vt, String keys) static Vectorstatic VectorConvertStringArrayToVector(String[] lines) convertStringtoArray(String buffer) convertStringtoArray(String buffer, String token1) convertStringtoArray1(String buffer) convertStringToVectorNoWhiteSpace(String buffer, String delim) static HashtableconvertVectorToHash(Vector vt, String keys) static String[]ConvertVectorToStringArray(Vector lines) getArrayFromHash(Map hash, String key, boolean isMandatory, ArrayList defaultValue) static booleangetBoolean(Map<String, Object> map, String key) static booleangetBooleanFromHash(Map hash, String key, boolean isMandatory, boolean defaultValue) static doublegetDoubleFromHash(Map hash, String key, boolean isMandatory, double min, double max, double defaultValue) static List<?>getFilteredList(Collection<?> _beanList, String keyPath, Object filterValue) static HashtablegetHashFromHash(Map hash, String key, boolean isMandatory, Hashtable defaultValue) static intgetIntFromHash(Map hash, String key, boolean isMandatory, int min, int max, int defaultValue) getPropertiesFromMap(Map<?, ?> map, Object[] properties) this method get Map of values of objectsstatic Object[]getPropertyValue(Object[] _objects, String _path) Iterates over all objects in the array, retrieves the value for the given key path and stores it into a new array in the same order.static <T> List<T>getPropertyValue(List<Object> _objects, String _path) Iterates over all objects in the list, retrieves the value for the given key path and stores it into a new list in the same order.static Stringstatic <T> Collection<T>getValuesFormCollection(Collection<?> collection, String property) static VectorgetVectorFromHash(Map hash, String key, boolean isMandatory, Vector defaultValue) groupByKey(Collection<?> _objects, String _key) This method walks over a collection and groups the contained object based on the value of some key.groupByKeyPath(Collection<?> _objects, String _keyPath) This method walks over a collection and groups the contained object based on the value of some keypath.static MapgroupByKeyPathes(Collection _objects, String[] _keyPathes) This method groups a collection based on a set of criterias.static byte[]hashToBytes(Hashtable<?, ?> hash) static booleanstatic booleanisEmpty(Collection<?> _collection) static booleanbooleanstatic Collection<?>mapToCollection(Map<?, ?> map) readHashTable(File file) static voidthis method get Map of values of objectsstatic voidvoidupdateObjectFromMap(Object aObject, Map<String, Object> map) voidupdateObjectFromMap(Object object, Map<String, Object> map, boolean skipNullValues) voidupdateObjectGraphFromMap(Object object, Map<?, ?> _map) static Object[]valuesForKey(Object[] _objects, String _key) Iterates over all objects in the array, retrieves the value for the given key and stores it into a new array in the same order.static voidwriteHashTable(File file, Hashtable<String, Object> hash)
-
Constructor Details
-
DataUtil
public DataUtil()
-
-
Method Details
-
getPropertyValue
Iterates over all objects in the list, retrieves the value for the given key path and stores it into a new list in the same order.Example:
List ownerIds = getPropertyValue(projects, "owner.id");
The returned List should be considered immutable.
- Parameters:
_objects- the objects to retrieve the values from_path- the keypath of the values to be retrieved- Returns:
- a list containing the values for the given key
- See Also:
-
valuesForKey()
-
valuesForKey
Iterates over all objects in the array, retrieves the value for the given key and stores it into a new array in the same order. This method is slightly faster than using getPropertyValue, which of course can also be used for simple keys.Example:
Object[] projectIds = valuesForKeys(projects, "logID");
- Parameters:
_objects- the objects to retrieve the values from_key- the key of the values to be retrieved- Returns:
- an array containing the values for the given key
- See Also:
-
getPropertyValue()
-
getPropertyValue
Iterates over all objects in the array, retrieves the value for the given key path and stores it into a new array in the same order.Example:
Object[] ownerIds = getPropertyValue(projects, "owner.id");
- Parameters:
_objects- the objects to retrieve the values from_path- the keypath of the values to be retrieved- Returns:
- an array containing the values for the given key
- See Also:
-
valuesForKey()
-
groupByKeyPath
This method walks over a collection and groups the contained object based on the value of some keypath. Example:Map groupedByEntity = groupByKeyPath(myObjects, "entity.name")
This will iterate over the given objects and group them by the entity, a result could look like:{ Person = [ xyz, def ]; Team = [ abc, def ]; }- Parameters:
_objects- - objects which should be grouped by the given keypath_keyPath- - the criteria to group on- Returns:
- a Map which contains the group values at the keys
-
groupByKey
This method walks over a collection and groups the contained object based on the value of some key. Example:Map groupedByCity = groupByKey(myObjects, "city")
This will iterate over the given objects and group them by the city, a result could look like:{ Magdeburg = [ { city = Madgeburg; name = "SWM"; }, { city = Magdeburg; name = "Skyrix AG"; } ]; Dortmund = [ ... ]; }This method currently calls groupByKeyPath() with the given key as the keypath.
- Parameters:
_objects- objects which should be grouped by the given key_key- the criteria to group on (eg 'city' or 'lastname')- Returns:
- a Map which contains the group values at the keys
-
groupByKeyPathes
This method groups a collection based on a set of criterias. Eg given those keys: [ city, zip ] a result could look like:{ Magdeburg = { 39104 = [ { name = Skyrix; ...}, { name = TLG; ...} ]; 39122 = [ { name = Telekom; ...} ]; }; Berlin = { 10233 = ... 23882 = ... }; }Note that only the last object in the tree is a List, all the parent groups are Maps.- Parameters:
_objects- the objects to be grouped_keyPathes- the keypathes to group the objects on- Returns:
- a Map of Maps or Lists representing the grouping-tree
-
mapToCollection
-
getPropertiesFromMap
this method get Map of values of objects- Parameters:
Map- , Object[]- Returns:
- Map
-
setPropertiesFromMap
this method get Map of values of objects- Parameters:
origMap- ,map
-
convertCollectionToMap
-
updateObjectFromMap
-
updateObjectFromMap
-
updateObjectGraphFromMap
-
getFieldsMapFromObject
-
arrayByAddingObjAtZeroIndex
-
castObject
-
hashToBytes
-
readHashTable
-
getBoolean
-
convertStringtoArray
-
convertStringtoArray
-
convertStringtoArray1
-
isEquivalent
-
convertStringToVectorNoWhiteSpace
-
convertHashtoVector
-
writeHashTable
-
convertVectorToHash
-
ConvertVectorToStringArray
-
ConvertStringArrayToVector
-
getIntFromHash
-
getDoubleFromHash
-
getBooleanFromHash
-
getUncommentedValue
-
getVectorFromHash
-
getHashFromHash
-
getArrayFromHash
-
getFilteredList
-
sort
-
isEmpty
-
isEmpty
-
isEmpty
-
getValuesFormCollection
-