|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object edu.jhu.tmaj.util.ListConvertUtil
public final class ListConvertUtil
Provides methods for converting and printing information about Collections and arrays.
Method Summary | ||
---|---|---|
static java.util.List<java.util.List> |
arrayTo2dList(java.lang.Object[][] array)
|
|
static java.util.List |
arrayToList(java.lang.Object[] array)
Converts an Array of Objects to a List of Objects. |
|
static java.util.Set |
arrayToSet(java.lang.Object[] objects)
Converts an array into a Set. |
|
static java.lang.String |
arrayToString(java.lang.Object[] objects)
Returns a description of every object in the provided Array. |
|
static java.util.List<java.lang.Boolean> |
booleanArrayPrimitiveAsList(boolean[] bools)
|
|
static java.lang.String[] |
concatStringArrays(java.lang.String[] strings1,
java.lang.String[] strings2)
Merges Two String arrays into one big array. |
|
static
|
convertCollectionToVector(java.util.Collection<T> collection)
|
|
static java.util.List<java.util.Map> |
convertListOfLists_TO_ListOfMaps(java.util.List<java.util.List> listOfLists,
java.util.List fieldNames)
Convert List-of-List (spreadsheet) to a List-of-Maps. |
|
static java.util.List<java.lang.String> |
convertListOfLists_TO_ListOfTabDelimitedStrings(java.util.List<java.util.List> listsList)
|
|
static java.util.List<java.util.List> |
convertListOfMaps_TO_ListOfLists(java.util.List<java.util.Map> listOfMaps,
java.util.List fieldNames)
Convert a List of Maps into a SpreadSheet-like List-Of-Lists. |
|
static java.util.List<java.util.Map<java.lang.String,java.lang.String>> |
convertListOfStringsToListOfMaps(java.util.List<java.lang.String> listOfStrings)
Converts a List of tab-delimited Strings into a List of Maps. |
|
static java.util.List<java.lang.Double> |
doubleArrayToList(double[] doubles)
Converts an doubles array to a List of Doubles. |
|
static java.util.Set |
getAllKeys(java.util.List<java.util.Map> listOfMaps)
Gets a Map containing the union of all keys found in many Maps |
|
static java.lang.String |
getListDescription(java.util.List list)
Returns a description of every object in the provided List. |
|
static java.lang.String |
getObjectDescription(java.lang.Object obj)
Returns a description of an Object including its toString() value and its class name. |
|
static java.util.Map |
getObjectFrequencyHash(java.util.List list)
|
|
static java.lang.String |
intArrayToCommaParenthesisString(int[] values)
Converts an array of ints to a comma-delimited String with parenthesis at the beginning and end. |
|
static java.lang.String |
listToCommaDelimitedString(java.util.List list)
Converts a List to one big comma-delimited String. |
|
static java.lang.String |
listToDelimitedString(java.util.List list,
java.lang.String delimiter)
Converts a list to a String where the elements of the list are delimited by the specified delimiter. |
|
static int[] |
listToIntArray(java.util.List<java.lang.Integer> intList)
Converts an int array to a List of Doubles. |
|
static java.lang.String |
listToString(java.util.List list,
java.lang.String delimiter)
A useful join() function |
|
static java.lang.String |
listToTabDelimitedString(java.util.List list)
Converts a list to a tab-delimited String |
|
static java.util.List<java.lang.String> |
prefixList(java.util.List list,
java.lang.String prefix)
|
|
static java.util.List<java.lang.String> |
purgeEmptyStrings(java.util.List<java.lang.String> listOfStrings)
Returns a list where any strings that were empty have been removed. |
|
static java.lang.String |
setToCommaDelimitedString(java.util.Set set)
|
|
static java.lang.String |
stringArrayToString(java.lang.String[] values,
java.lang.String delimiter)
Converts an array of Strings one big comma-delimited String. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static java.util.List<java.util.Map> convertListOfLists_TO_ListOfMaps(java.util.List<java.util.List> listOfLists, java.util.List fieldNames)
listOfLists
- A List of List of Objects, representing the data in a spread sheet. For example,
listOfLists.get(10).get(20) represents row=11 column=21. The Objects represent a
cell's data. Note the first List does NOT contain the fieldNames.fieldNames
- The field names of the data. Thus, listOfLists.get(x).size()==fieldNames.size() *
public static java.util.List<java.util.List> convertListOfMaps_TO_ListOfLists(java.util.List<java.util.Map> listOfMaps, java.util.List fieldNames)
listOfMaps
- a list of Maps, where each Map represents on row.fieldNames
- the FieldNames found in the Maps. The order will determine the order in the List.
It is not necessary for all the Maps to have each of the FieldNames. If the key
is missing in the Map, a default NOT_FOUND_STRING of " " in used as the value.
public static java.lang.String listToTabDelimitedString(java.util.List list)
public static java.util.List<java.lang.String> convertListOfLists_TO_ListOfTabDelimitedStrings(java.util.List<java.util.List> listsList)
public static java.lang.String listToDelimitedString(java.util.List list, java.lang.String delimiter)
public static java.util.List<java.lang.String> purgeEmptyStrings(java.util.List<java.lang.String> listOfStrings)
public static java.util.List<java.util.Map<java.lang.String,java.lang.String>> convertListOfStringsToListOfMaps(java.util.List<java.lang.String> listOfStrings)
listOfStrings
- a List of tab-delimited Strings; the first row represents the column names
public static java.util.List arrayToList(java.lang.Object[] array)
public static java.util.List<java.util.List> arrayTo2dList(java.lang.Object[][] array)
public static java.lang.String intArrayToCommaParenthesisString(int[] values)
public static java.lang.String stringArrayToString(java.lang.String[] values, java.lang.String delimiter)
public static java.lang.String listToCommaDelimitedString(java.util.List list)
public static java.lang.String setToCommaDelimitedString(java.util.Set set)
public static java.lang.String[] concatStringArrays(java.lang.String[] strings1, java.lang.String[] strings2)
public static java.lang.String getObjectDescription(java.lang.Object obj)
public static java.lang.String getListDescription(java.util.List list)
public static java.lang.String arrayToString(java.lang.Object[] objects)
public static java.util.Set getAllKeys(java.util.List<java.util.Map> listOfMaps)
listOfMaps
- self-explanatory
public static java.util.List<java.lang.String> prefixList(java.util.List list, java.lang.String prefix)
public static java.util.Set arrayToSet(java.lang.Object[] objects)
public static <T> java.util.Vector convertCollectionToVector(java.util.Collection<T> collection)
public static java.util.List<java.lang.Double> doubleArrayToList(double[] doubles)
public static int[] listToIntArray(java.util.List<java.lang.Integer> intList)
public static java.lang.String listToString(java.util.List list, java.lang.String delimiter)
public static java.util.Map getObjectFrequencyHash(java.util.List list)
public static java.util.List<java.lang.Boolean> booleanArrayPrimitiveAsList(boolean[] bools)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |