Documentation of 'org.supercsv.util.Util' Java class
Util
org.supercsv.util

Class Util



  • public final class Util
    extends java.lang.Object
    Useful utility methods.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method and Description
      static void executeCellProcessors(java.util.List<java.lang.Object> destination, java.util.List<?> source, CellProcessor[] processors, int lineNo, int rowNo)
      Processes each element in the source List (using the corresponding processor chain in the processors array) and adds it to the destination List.
      static <T> void filterListToMap(java.util.Map<java.lang.String,T> destinationMap, java.lang.String[] nameMapping, java.util.List<? extends T> sourceList)
      Converts a List to a Map using the elements of the nameMapping array as the keys of the Map.
      static java.util.List<java.lang.Object> filterMapToList(java.util.Map<java.lang.String,?> map, java.lang.String[] nameMapping)
      Returns a List of all of the values in the Map whose key matches an entry in the nameMapping array.
      static java.lang.Object[] filterMapToObjectArray(java.util.Map<java.lang.String,?> values, java.lang.String[] nameMapping)
      Converts a Map to an array of objects, adding only those entries whose key is in the nameMapping array.
      static java.lang.String[] objectArrayToStringArray(java.lang.Object[] objectArray)
      Converts an Object array to a String array (null-safe), by calling toString() on each element.
      static java.lang.String[] objectListToStringArray(java.util.List<?> objectList)
      Converts an List
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • executeCellProcessors

        public static void executeCellProcessors(java.util.List<java.lang.Object> destination,
                                                 java.util.List<?> source,
                                                 CellProcessor[] processors,
                                                 int lineNo,
                                                 int rowNo)
        Processes each element in the source List (using the corresponding processor chain in the processors array) and adds it to the destination List. A null CellProcessor in the array indicates that no processing is required and the element should be added as-is.
        Parameters:
        destination - the List to add the processed elements to (which is cleared before it's populated)
        source - the List of source elements to be processed
        processors - the array of CellProcessors used to process each element. The number of elements in this array must match the size of the source List. A null CellProcessor in this array indicates that no processing is required and the element should be added as-is.
        lineNo - the current line number
        rowNo - the current row number
        Throws:
        java.lang.NullPointerException - if destination, source or processors is null
        SuperCsvConstraintViolationException - if a CellProcessor constraint failed
        SuperCsvException - if source.size() != processors.length, or CellProcessor execution failed
      • filterListToMap

        public static <T> void filterListToMap(java.util.Map<java.lang.String,T> destinationMap,
                                               java.lang.String[] nameMapping,
                                               java.util.List<? extends T> sourceList)
        Converts a List to a Map using the elements of the nameMapping array as the keys of the Map.
        Parameters:
        destinationMap - the destination Map (which is cleared before it's populated)
        nameMapping - the keys of the Map (corresponding with the elements in the sourceList). Cannot contain duplicates.
        sourceList - the List to convert
        Throws:
        java.lang.NullPointerException - if destinationMap, nameMapping or sourceList are null
        SuperCsvException - if nameMapping and sourceList are not the same size
      • filterMapToList

        public static java.util.List<java.lang.Object> filterMapToList(java.util.Map<java.lang.String,?> map,
                                                                       java.lang.String[] nameMapping)
        Returns a List of all of the values in the Map whose key matches an entry in the nameMapping array.
        Parameters:
        map - the map
        nameMapping - the keys of the Map values to add to the List
        Returns:
        a List of all of the values in the Map whose key matches an entry in the nameMapping array
        Throws:
        java.lang.NullPointerException - if map or nameMapping is null
      • filterMapToObjectArray

        public static java.lang.Object[] filterMapToObjectArray(java.util.Map<java.lang.String,?> values,
                                                                java.lang.String[] nameMapping)
        Converts a Map to an array of objects, adding only those entries whose key is in the nameMapping array.
        Parameters:
        values - the Map of values to convert
        nameMapping - the keys to extract from the Map (elements in the target array will be added in this order)
        Returns:
        the array of Objects
        Throws:
        java.lang.NullPointerException - if values or nameMapping is null
      • objectArrayToStringArray

        public static java.lang.String[] objectArrayToStringArray(java.lang.Object[] objectArray)
        Converts an Object array to a String array (null-safe), by calling toString() on each element.
        Parameters:
        objectArray - the Object array
        Returns:
        the String array, or null if objectArray is null
      • objectListToStringArray

        public static java.lang.String[] objectListToStringArray(java.util.List<?> objectList)
        Converts an List
        Parameters:
        objectList - the List
        Returns:
        the String array, or null if objectList is null

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.