Class DataUtil

java.lang.Object
org.brijframework.reflection.data.DataUtil

public abstract class DataUtil extends Object
  • Constructor Details

    • DataUtil

      public DataUtil()
  • Method Details

    • getPropertyValue

      public 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.

      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

      public 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. 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

      public static 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.

      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

      public static HashMap<Object,List<Object>> groupByKeyPath(Collection<?> _objects, String _keyPath)
      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

      public static HashMap<Object,List<Object>> groupByKey(Collection<?> _objects, String _key)
      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

      public static Map groupByKeyPathes(Collection _objects, String[] _keyPathes)
      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

      public static Collection<?> mapToCollection(Map<?,?> map)
    • getPropertiesFromMap

      public static Map<String,Object> getPropertiesFromMap(Map<?,?> map, Object[] properties)
      this method get Map of values of objects
      Parameters:
      Map - , Object[]
      Returns:
      Map
    • setPropertiesFromMap

      public static void setPropertiesFromMap(Map<String,Object> origMap, Map<String,Object> map)
      this method get Map of values of objects
      Parameters:
      origMap - ,map
    • convertCollectionToMap

      public static Hashtable convertCollectionToMap(Collection<?> vt, String keys)
    • updateObjectFromMap

      public void updateObjectFromMap(Object aObject, Map<String,Object> map)
    • updateObjectFromMap

      public void updateObjectFromMap(Object object, Map<String,Object> map, boolean skipNullValues)
    • updateObjectGraphFromMap

      public void updateObjectGraphFromMap(Object object, Map<?,?> _map)
    • getFieldsMapFromObject

      public Map<String,Object> getFieldsMapFromObject(Object obj)
    • arrayByAddingObjAtZeroIndex

      public Object[] arrayByAddingObjAtZeroIndex(Object object, Object... paramObjects)
    • castObject

      public Object castObject(Object object, String type)
    • hashToBytes

      public static byte[] hashToBytes(Hashtable<?,?> hash)
    • readHashTable

      public static Hashtable<String,Object> readHashTable(File file)
    • getBoolean

      public static boolean getBoolean(Map<String,Object> map, String key)
    • convertStringtoArray

      public static Vector<Object> convertStringtoArray(String buffer, String token1)
    • convertStringtoArray

      public static Vector<Object> convertStringtoArray(String buffer)
    • convertStringtoArray1

      public static Vector<Object> convertStringtoArray1(String buffer)
    • isEquivalent

      public boolean isEquivalent(Object object1, Object object2, Map<String,String> keyMap, boolean isDebug)
    • convertStringToVectorNoWhiteSpace

      public static Vector<Object> convertStringToVectorNoWhiteSpace(String buffer, String delim)
    • convertHashtoVector

      public static Vector convertHashtoVector(Hashtable h)
    • writeHashTable

      public static void writeHashTable(File file, Hashtable<String,Object> hash)
    • convertVectorToHash

      public static Hashtable convertVectorToHash(Vector vt, String keys)
    • ConvertVectorToStringArray

      public static String[] ConvertVectorToStringArray(Vector lines)
    • ConvertStringArrayToVector

      public static Vector ConvertStringArrayToVector(String[] lines)
    • getIntFromHash

      public static int getIntFromHash(Map hash, String key, boolean isMandatory, int min, int max, int defaultValue)
    • getDoubleFromHash

      public static double getDoubleFromHash(Map hash, String key, boolean isMandatory, double min, double max, double defaultValue)
    • getBooleanFromHash

      public static boolean getBooleanFromHash(Map hash, String key, boolean isMandatory, boolean defaultValue)
    • getUncommentedValue

      public static String getUncommentedValue(String str)
    • getVectorFromHash

      public static Vector getVectorFromHash(Map hash, String key, boolean isMandatory, Vector defaultValue)
    • getHashFromHash

      public static Hashtable getHashFromHash(Map hash, String key, boolean isMandatory, Hashtable defaultValue)
    • getArrayFromHash

      public static ArrayList<Object> getArrayFromHash(Map hash, String key, boolean isMandatory, ArrayList defaultValue)
    • getFilteredList

      public static List<?> getFilteredList(Collection<?> _beanList, String keyPath, Object filterValue)
    • sort

      public static void sort(List _beanObjects, String key, boolean isReverse)
    • isEmpty

      public static boolean isEmpty(Object[] _array)
    • isEmpty

      public static boolean isEmpty(Collection<?> _collection)
    • isEmpty

      public static boolean isEmpty(Map<?,?> _map)
    • getValuesFormCollection

      public static <T> Collection<T> getValuesFormCollection(Collection<?> collection, String property)