|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.isomorphic.util.DataTools
DataTools
is a utility class with the following facilities:
getProperties()
and setProperties()
: getProperties()
allow the properties of any Java object to be extracted as a Map, and setProperties
allows any Map to be applied to a Java object, calling setter methods named after the keys of the
Map. These methods are very useful for going from Java beans to a JavaScript representation and
back.
prettyPrint(Object)
,
getProperties(Object)
,
setProperties(Map, Object)
Method Summary | |
static java.util.List |
addAll(java.util.List target,
java.util.Iterator source)
Adds all the elements of an Iterator to a List . |
static java.util.List |
addAll(java.util.List target,
java.util.List source)
Adds the contents of one List to another. |
static java.util.List |
addAsList(java.util.List targetList,
java.lang.Object sourceList)
Add either a single object or List to another List. |
static void |
addDisjunctionToSet(java.util.List one,
java.util.List two)
Adds elements of the second List that are missing in the first. |
static void |
addToIntInMap(java.util.Map map,
java.lang.Object key,
int addition)
Add to the value of an Integer instance stored in the map "map" under key "key". |
static java.util.List |
arrayToList(java.lang.Object[] arr)
Creates a List from an array. |
static java.util.List |
arrayToList(java.lang.Object[] arr,
int from,
int length)
Creates a List containing a subset of an array. |
static java.lang.Object[] |
arrayUnion(java.lang.Object[] one,
java.lang.Object[] two)
Creates a new array containing all the elements of two arrays. |
static java.util.List |
buildList(java.lang.Object one)
Creates a List of one elements. |
static java.util.List |
buildList(java.lang.Object one,
java.lang.Object two)
Creates a List of two elements. |
static java.util.List |
buildList(java.lang.Object one,
java.lang.Object two,
java.lang.Object three)
Creates a List of three elements. |
static java.util.List |
buildList(java.lang.Object one,
java.lang.Object two,
java.lang.Object three,
java.lang.Object four)
Creates a List of four elements. |
static java.util.Map |
buildMap(java.lang.Object key,
java.lang.Object value)
Creates a Map of one key/value pair. |
static java.util.Map |
buildMap(java.lang.Object key,
java.lang.Object value,
java.lang.Object key2,
java.lang.Object value2)
Creates a Map of two key/value pairs. |
static java.util.Map |
buildMap(java.lang.Object key,
java.lang.Object value,
java.lang.Object key2,
java.lang.Object value2,
java.lang.Object key3,
java.lang.Object value3)
Creates a Map of three key/value pairs. |
static java.util.Map |
buildMap(java.lang.Object key,
java.lang.Object value,
java.lang.Object key2,
java.lang.Object value2,
java.lang.Object key3,
java.lang.Object value3,
java.lang.Object key4,
java.lang.Object value4)
Creates a Map of four key/value pairs. |
static java.util.Map |
buildMap(java.lang.Object key,
java.lang.Object value,
java.lang.Object key2,
java.lang.Object value2,
java.lang.Object key3,
java.lang.Object value3,
java.lang.Object key4,
java.lang.Object value4,
java.lang.Object key5,
java.lang.Object value5)
Creates a Map of five key/value pairs. |
static java.util.Map |
buildMap(java.lang.Object key,
java.lang.Object value,
java.lang.Object key2,
java.lang.Object value2,
java.lang.Object key3,
java.lang.Object value3,
java.lang.Object key4,
java.lang.Object value4,
java.lang.Object key5,
java.lang.Object value5,
java.lang.Object key6,
java.lang.Object value6)
Creates a Map of six key/value pairs. |
static java.util.Map |
buildMap(java.lang.Object key,
java.lang.Object value,
java.lang.Object key2,
java.lang.Object value2,
java.lang.Object key3,
java.lang.Object value3,
java.lang.Object key4,
java.lang.Object value4,
java.lang.Object key5,
java.lang.Object value5,
java.lang.Object key6,
java.lang.Object value6,
java.lang.Object key7,
java.lang.Object value7)
Creates a Map of six key/value pairs. |
static int |
checkSize(java.lang.Object obj)
Obtains the size of a Map , List or String . |
static java.lang.Object |
combineAsLists(java.lang.Object one,
java.lang.Object two)
Combine two single objects or Lists into one new List, or return a single Object if one argument is single and the other argument is null. |
static boolean |
contains(java.lang.String str,
java.lang.String substr)
Tests if the specified substring is present in the specified string. |
static java.lang.Object |
deepMerge(java.lang.Object source,
java.lang.Object target,
boolean overwrite)
Merges one collections data structure into another. |
static void |
deepRemoveEmptyCollections(java.lang.Object data)
Walks a nested Collection-based datastructure and removes all Collections entities that are zero-sized. |
static void |
deepRemoveKey(java.lang.Object keyToRemove,
java.lang.Object data)
Walks a nested Collection-based datastructure and removes all instances of keyToRemove (and its associated value) from any Map objects found in the data structure. |
static void |
deepRemoveNullValues(java.lang.Object data)
Walks a nested Collection-based datastructure and removes all entities that have a null value. |
static java.util.Map |
divideMap(java.util.Map origMap,
java.util.List retainKeys)
Alters a Map so that it retains only the specified keys, returning a Map
with any keys not retained. |
static java.util.List |
enumToList(java.util.Iterator i)
Converts an Iterator to a List . |
static java.lang.String |
fastDateFormat(java.util.Date date)
Returns a String representation of a Date object. |
static int |
getIntInMap(java.util.Map map,
java.lang.Object key)
Get value of an Integer instance stored in the map "map" under key "key", as the primitive type int . |
static java.util.Map |
getProperties(java.lang.Object bean)
Gets the properties for a JavaBean and returns them as a Map . |
static java.util.List |
getProperty(java.util.List rows,
java.lang.Object column)
Given a result set, as a List of rows, and a column name,
returns the List of values for that column. |
static java.util.Map |
getPropertyDescriptors(java.lang.Class beanClass)
Gets the properties for a JavaBean class through introspection and returns them as a Map . |
static java.util.Map |
getPropertyDescriptors(java.lang.Object bean)
Gets the property descriptors for a JavaBean and returns them as a Map . |
static java.lang.Object |
getSingle(java.lang.Object toFetchFrom)
Retrieves the element of a single element List , or the key
of a single key/value pair Map . |
static java.lang.String |
getStackTrace(java.lang.Throwable t)
Returns the stack trace of a Throwable object as a String . |
static java.util.Map |
identityMap(java.util.List list)
Stores the elements of a List as the keys and values of a Map . |
static void |
incrementIntInMap(java.util.Map map,
java.lang.Object key)
Add to the value of an Integer instance stored in the map "map" under key "key". |
static java.util.List |
keysAsList(java.util.Map map)
Creates a List of the keys from a Map . |
static java.util.List |
keysNotPresent(java.util.Map map,
java.util.List keys)
Given a Map and a List of keys, returns the list of keys
in the List that are not present in the Map . |
static java.lang.Object[] |
listToArray(java.util.List list)
Creates an Object array from a List . |
static java.lang.String[] |
listToStringArray(java.util.Collection list)
Creates a String array from a List . |
static java.util.List |
makeList(java.lang.Object element)
Creates a List containing one element. |
static java.util.List |
makeListIfSingle(java.lang.Object obj)
Creates a List containing one element if the element
is not a List . |
static java.util.Map |
mapDisjunction(java.util.Map one,
java.util.Map two)
Creates a new Map containing the key/value pairs whose keys
are not present in both Maps supplied. |
static java.util.Map |
mapIntersection(java.util.Map primary,
java.util.Map secondary)
Constructs a Map containing the key/value pairs of the primary
Map whose keys are present in the secondary Map . |
static java.util.List |
mapIntersectionKeys(java.util.Map one,
java.util.Map two)
Returns the list of keys that are present in both Maps . |
static java.util.Map |
mapMerge(java.util.Map source,
java.util.Map target)
Copies the key/value pairs of a Map into another Map ,
replacing the key/value pair of the target Map . |
static java.util.Map |
mapMergeNonNull(java.util.Map source,
java.util.Map target)
Copies the key/value pairs of a Map into another Map ,
replacing the key/value pair of the target Map if the source value
is non-null. |
static java.util.Properties |
mapToProperties(java.util.Map map)
Creates a Properties object from a Map . |
static java.util.Map |
mapUnion(java.util.Map one,
java.util.Map two)
Constructs a Map containing all the key/value pairs of the
Maps supplied as arguments. |
static java.lang.Object |
nestedGet(java.lang.Object struct,
java.lang.String fetch)
Retrieves a object from a series of nested Lists or Map . |
static java.util.Map |
orderedMapUnion(java.util.Map primary,
java.util.Map secondary)
Constructs a Map containing all the key/value pairs of the
Maps supplied as arguments, with the first Map taking
precedence. |
static java.lang.String |
prettyPrint(java.lang.Object obj)
Formats information about an Object for viewing or printing as
a String . |
static java.util.Map |
putAllNotPresent(java.util.Map target,
java.util.Map source)
Copies the key/value pairs of a Map into another Map ,
adding only key/value pairs for which the target Map does not
already have a mapping (as determined by the containsKey method). |
static java.util.Map |
putCombinedList(java.util.Map map,
java.lang.Object key,
java.lang.Object value)
Put a value into a Map, combining with any existing value as though combineAsLists() had been called on the existing value and new value. |
static java.util.Map |
putMultiple(java.util.Map map,
java.lang.Object key,
java.lang.Object value)
Puts a key/value pair into a Map , if there is already a value
under that key, create a List to hold the values. |
static java.util.Map |
putMultipleAsList(java.util.Map map,
java.lang.Object key,
java.lang.Object value)
Works like the putMultiple method, but in this case
values are always encapsualted in a List . |
static boolean |
recursiveFileDelete(java.io.File file)
Recursively deletes a directory. |
static java.util.Map |
remapRow(java.util.Map row,
java.util.Map remap)
Change the keys used in a Map to a new set of keys. |
static java.util.Map |
remapRow(java.util.Map row,
java.util.Map remap,
boolean keepNonRemapped)
Change the keys used in a Map to a new set of keys. |
static java.util.List |
remapRows(java.util.List rows,
java.util.Map remap)
Remap the keys in a List of Maps . |
static java.util.List |
remapRows(java.util.List rows,
java.util.Map remap,
boolean keepNonRemapped)
Remap the keys in a List of Maps . |
static java.util.Map |
removeEmptyStringValuedKeys(java.util.Map map)
Removes all keys from the passed-in map where the values are empty strings. |
static java.util.Map |
removeNullValuedKeys(java.util.Map map)
Removes all keys from the passed-in map where the values
are null . |
static java.util.Map |
reverseMap(java.util.Map origMap)
Reverses a Map so that values point at keys. |
static java.util.List |
setDisjunction(java.util.Collection one,
java.util.Collection two)
Creates a new List containing all elements from the first
Collection that are not in the second Collection . |
static java.util.List |
setIntersection(java.util.Collection one,
java.util.Collection two)
Creates a new List containing the common elements of two Collections . |
static java.lang.Object |
setProperties(java.util.Map propertyMap,
java.lang.Object bean)
Sets the properties for a JavaBean provided as key-value pairs in a Map . |
static java.util.List |
setUnion(java.util.List one,
java.util.List two)
Creates a new List containing all the elements of two Lists . |
static java.util.List |
subsetByPrefix(java.util.List list,
java.lang.String prefix)
Returns any strings within list which begin with
prefix . |
static java.util.Map |
subsetMap(java.util.Map origMap,
java.util.List keys)
Given a Map and a List of keys, returns a subset of the Map
containing the key/value pairs as specified by the List of keys. |
static java.util.Map |
substringKeyMap(java.lang.String prefix,
java.util.Map source)
Constructs a Map of key/value pairs from the source
Map whose keys start with a specific prefix. |
static java.util.List |
toLowerCaseList(java.util.List list)
Given a List of strings, returns a new List of lower cased strings. |
Method Detail |
public static java.util.List keysNotPresent(java.util.Map map, java.util.List keys)
Map
and a List
of keys, returns the list of keys
in the List
that are not present in the Map
.
map
- the Map
keys
- the List
of keysList
that are not
present in the Map
public static java.util.Map subsetMap(java.util.Map origMap, java.util.List keys)
Map
and a List
of keys, returns a subset of the Map
containing the key/value pairs as specified by the List
of keys.
origMap
- the original Map
keys
- the keys denoting the key/value pairs that should be
included in the result Map
Map
containing only the
key/value pairs corresponding to the supplied List
of keyspublic static java.util.List subsetByPrefix(java.util.List list, java.lang.String prefix)
list
which begin with
prefix
. Non-string members of list
are ignored.
list
- the list of stringsprefix
- strings in the list with this prefix will be returnedpublic static java.util.Map removeNullValuedKeys(java.util.Map map)
map
where the values
are null
.
map
- the Map
on which to operatepublic static java.util.Map removeEmptyStringValuedKeys(java.util.Map map)
map
where the values are empty strings.
map
- the Map
on which to operatepublic static java.util.Map divideMap(java.util.Map origMap, java.util.List retainKeys)
Map
so that it retains only the specified keys, returning a Map
with any keys not retained.
origMap
- the original Map
retainKeys
- the List
of keys corresponding to the key/value pairs
that should be retainedMap
containing the key/value pairs that were not retainedpublic static java.util.Map mapUnion(java.util.Map one, java.util.Map two)
Map
containing all the key/value pairs of the
Maps
supplied as arguments.
one
- the first Map
two
- the second Map
Maps
public static java.util.Map orderedMapUnion(java.util.Map primary, java.util.Map secondary)
Map
containing all the key/value pairs of the
Maps
supplied as arguments, with the first Map
taking
precedence. If the same key is present in both Maps
, the
returned Map
will contain the key/value pair of the first
Map
.
one
- the first Map
two
- the second Map
Maps
public static java.lang.Object deepMerge(java.lang.Object source, java.lang.Object target, boolean overwrite) throws java.lang.Exception
source
- the Object
to be copied fromtarget
- the Object
to be copied intooverwrite
- controls how non-collection/non-map collisions are resolved. If true,
target values are overwritten with source values. If false, target
values are not overwritten.Object
public static void deepRemoveKey(java.lang.Object keyToRemove, java.lang.Object data) throws java.lang.Exception
keyToRemove
- the key to removedata
- the nested data structure to walkpublic static void deepRemoveNullValues(java.lang.Object data) throws java.lang.Exception
data
- the nested data structure to walkpublic static void deepRemoveEmptyCollections(java.lang.Object data) throws java.lang.Exception
data
- the nested data structure to walkpublic static java.util.Map mapMerge(java.util.Map source, java.util.Map target)
Map
into another Map
,
replacing the key/value pair of the target Map
.
source
- the Map
to be copied fromtarget
- the Map
to be copied intoMap
public static java.util.Map mapMergeNonNull(java.util.Map source, java.util.Map target)
Map
into another Map
,
replacing the key/value pair of the target Map
if the source value
is non-null.
source
- the Map
to be copied fromtarget
- the Map
to be copied intoMap
public static java.util.Map putAllNotPresent(java.util.Map target, java.util.Map source)
Map
into another Map
,
adding only key/value pairs for which the target Map
does not
already have a mapping (as determined by the containsKey
method).
source
- the Map
to be copied fromtarget
- the Map
to be copied intoMap
public static java.util.Map mapIntersection(java.util.Map primary, java.util.Map secondary)
Map
containing the key/value pairs of the primary
Map
whose keys are present in the secondary Map
.
primary
- the primary Map
secondary
- the secondary Map
Map
public static java.util.List mapIntersectionKeys(java.util.Map one, java.util.Map two)
Maps
.
one
- the first Map
two
- the second Map
Maps
public static java.util.Map substringKeyMap(java.lang.String prefix, java.util.Map source)
Map
of key/value pairs from the source
Map
whose keys start with a specific prefix. The new
Map
's keys are the origin keys without the prefix.
prefix
- the prefix to be matched with the keyssource
- the source Map
Map
public static java.util.Map identityMap(java.util.List list)
List
as the keys and values of a Map
.
This can serve as a HashSet
which disallows duplicates and can quickly
determine whether a set has a given member.
list
- the List
to be storedMap
containing the uniques elements of the listpublic static java.util.Map reverseMap(java.util.Map origMap)
Map
so that values point at keys. If more than one
value in the original Map
has the same key (where "same" is
determined by hashcode
), the multiple keys are placed into a
List
in the reversed Map
.
Note: If in the original Map
, Lists
are
mapped to values, and more than one List
maps to the same
value, this method will work incorrectly since it won't be able to tell
Lists
it created for multiple values from Lists
that were keys in the original Map
.
origMap
- the original Map
Map
public static java.util.Map putMultiple(java.util.Map map, java.lang.Object key, java.lang.Object value)
Map
, if there is already a value
under that key, create a List
to hold the values.
map
- the Map
to which the key/value pair should be addedkey
- the key in the key/value pairvalue
- the value in the key/value pairMap
, with the key/value pair added to itpublic static java.util.Map putMultipleAsList(java.util.Map map, java.lang.Object key, java.lang.Object value)
putMultiple
method, but in this case
values are always encapsualted in a List
.
map
- the Map
to which the key/value pair should be addedkey
- the key in the key/value pairvalue
- the value in the key/value pairMap
, with the key/value pair added to itpublic static java.util.List addAll(java.util.List target, java.util.List source)
List
to another.
target
- the List
to which the contents of the
source List
should be addedsource
- the List
to be added to the target
List
List
public static java.util.List addAll(java.util.List target, java.util.Iterator source)
Iterator
to a List
.
target
- the List
to which the contents of the
source List
should be addedsource
- the List
to be added to the target
List
List
public static java.util.List addAsList(java.util.List targetList, java.lang.Object sourceList)
sourceList
is a List,
adds its items, if it's an Object, just adds the Object itself. Returns the modified
targetList
.public static java.lang.Object combineAsLists(java.lang.Object one, java.lang.Object two)
public static java.util.Map putCombinedList(java.util.Map map, java.lang.Object key, java.lang.Object value)
public static java.util.List setUnion(java.util.List one, java.util.List two)
List
containing all the elements of two Lists
.
one
- the first List
two
- the second List
List
public static void addDisjunctionToSet(java.util.List one, java.util.List two)
List
that are missing in the first.
If the first or second List
is null
, the first
will be unchanged.
one
- the first List
two
- the second List
List
public static java.lang.Object[] arrayUnion(java.lang.Object[] one, java.lang.Object[] two)
one
- the first arraytwo
- the second arraypublic static java.util.List setIntersection(java.util.Collection one, java.util.Collection two)
List
containing the common elements of two Collections
.
one
- the first Collection
two
- the second Collection
public static java.util.Map mapDisjunction(java.util.Map one, java.util.Map two)
Map
containing the key/value pairs whose keys
are not present in both Maps
supplied.
one
- the first Map
two
- the second Map
Map
of the disjunctionpublic static java.util.List setDisjunction(java.util.Collection one, java.util.Collection two)
List
containing all elements from the first
Collection
that are not in the second Collection
.
one
- the first Collection
two
- the second Collection
List
of elements present in the first
List
that are not in the second List
public static java.util.List enumToList(java.util.Iterator i)
Iterator
to a List
.
i
- the Iterator
List
of Iterator
elementspublic static java.util.List arrayToList(java.lang.Object[] arr, int from, int length)
List
containing a subset of an array.
arr
- the source arrayfrom
- the array index of the first element of the subsetlength
- the number of elements in the subsetList
of elements from the subset of the source arraypublic static java.util.List arrayToList(java.lang.Object[] arr)
List
from an array.
arr
- the source arrayList
of elements from the source arraypublic static java.lang.Object[] listToArray(java.util.List list)
Object
array from a List
.
list
- the source List
Object
array containing the elements
of the source listpublic static java.lang.String[] listToStringArray(java.util.Collection list)
String
array from a List
.
list
- the source List
Strings
from the source List
public static java.util.Properties mapToProperties(java.util.Map map)
Properties
object from a Map
. The keys and
values in the map must be strings.
map
- the source Map
Properties
object containing the keys/values
of the source Map
as propertiespublic static java.util.List keysAsList(java.util.Map map)
List
of the keys from a Map
.
map
- the source Map
Map
public static java.util.List makeList(java.lang.Object element)
List
containing one element.
element
- the elementList
containing the elementpublic static java.util.List makeListIfSingle(java.lang.Object obj)
List
containing one element if the element
is not a List
.
obj
- the elementList
public static boolean contains(java.lang.String str, java.lang.String substr)
str
- the enclosing stringsubstr
- the substringtrue
if the substring is contained in the string,
false
otherwisepublic static java.lang.Object nestedGet(java.lang.Object struct, java.lang.String fetch)
Lists
or Map
. The
location of the structure is described by a string of Map
keys
or List
indexes, separated by periods.
For example, specifying the string "dog.2"
would retrieve
the object with key "dog"
from the supplied Map
;
this object should be a List
- the second element of this List
would be retrieved and returned.
struct
- the enclosing List
or Map
fetch
- the string describing the location of the desired objectjava.lang.ClassCastException
- if any of the enclosing data structures
is neither a Map
nor a List
public static java.util.List buildList(java.lang.Object one)
List
of one elements. This method is
useful because new ArrayList().add()
does not return
the List
.
one
- the first elementtwo
- the second elementList
containing the two elementspublic static java.util.List buildList(java.lang.Object one, java.lang.Object two)
List
of two elements.
one
- the first elementtwo
- the second elementList
containing the two elementspublic static java.util.List buildList(java.lang.Object one, java.lang.Object two, java.lang.Object three)
List
of three elements.
one
- the first elementtwo
- the second elementthree
- the third elementList
containing the three elementspublic static java.util.List buildList(java.lang.Object one, java.lang.Object two, java.lang.Object three, java.lang.Object four)
List
of four elements.
one
- the first elementtwo
- the second elementthree
- the third elementfour
- the fourth elementList
containing the four elementspublic static java.util.Map buildMap(java.lang.Object key, java.lang.Object value)
Map
of one key/value pair.
key
- the keyvalue
- the valueMap
containing the key/value pairpublic static java.util.Map buildMap(java.lang.Object key, java.lang.Object value, java.lang.Object key2, java.lang.Object value2)
Map
of two key/value pairs.
key
- the first keyvalue
- the first valuekey2
- the second keyvalue2
- the second valueMap
containing the two key/value pairspublic static java.util.Map buildMap(java.lang.Object key, java.lang.Object value, java.lang.Object key2, java.lang.Object value2, java.lang.Object key3, java.lang.Object value3)
Map
of three key/value pairs.
key
- the first keyvalue
- the first valuekey2
- the second keyvalue2
- the second valuekey3
- the third keyvalue3
- the third valueMap
containing the three key/value pairspublic static java.util.Map buildMap(java.lang.Object key, java.lang.Object value, java.lang.Object key2, java.lang.Object value2, java.lang.Object key3, java.lang.Object value3, java.lang.Object key4, java.lang.Object value4)
Map
of four key/value pairs.
key
- the first keyvalue
- the first valuekey2
- the second keyvalue2
- the second valuekey3
- the third keyvalue3
- the third valuekey4
- the fourth keyvalue4
- the fourth valueMap
containing the four key/value pairspublic static java.util.Map buildMap(java.lang.Object key, java.lang.Object value, java.lang.Object key2, java.lang.Object value2, java.lang.Object key3, java.lang.Object value3, java.lang.Object key4, java.lang.Object value4, java.lang.Object key5, java.lang.Object value5)
Map
of five key/value pairs.
key
- the first keyvalue
- the first valuekey2
- the second keyvalue2
- the second valuekey3
- the third keyvalue3
- the third valuekey4
- the fourth keyvalue4
- the fourth valuekey5
- the fifth keyvalue5
- the fifth valueMap
containing the five key/value pairspublic static java.util.Map buildMap(java.lang.Object key, java.lang.Object value, java.lang.Object key2, java.lang.Object value2, java.lang.Object key3, java.lang.Object value3, java.lang.Object key4, java.lang.Object value4, java.lang.Object key5, java.lang.Object value5, java.lang.Object key6, java.lang.Object value6)
Map
of six key/value pairs.
key
- the first keyvalue
- the first valuekey2
- the second keyvalue2
- the second valuekey3
- the third keyvalue3
- the third valuekey4
- the fourth keyvalue4
- the fourth valuekey5
- the fifth keyvalue5
- the fifth valuekey6
- the sixth keyvalue6
- the sixth valueMap
containing the six key/value pairspublic static java.util.Map buildMap(java.lang.Object key, java.lang.Object value, java.lang.Object key2, java.lang.Object value2, java.lang.Object key3, java.lang.Object value3, java.lang.Object key4, java.lang.Object value4, java.lang.Object key5, java.lang.Object value5, java.lang.Object key6, java.lang.Object value6, java.lang.Object key7, java.lang.Object value7)
Map
of six key/value pairs.
key
- the first keyvalue
- the first valuekey2
- the second keyvalue2
- the second valuekey3
- the third keyvalue3
- the third valuekey4
- the fourth keyvalue4
- the fourth valuekey5
- the fifth keyvalue5
- the fifth valuekey6
- the sixth keyvalue6
- the sixth valuekey7
- the seventh keyvalue7
- the seventh valueMap
containing the six key/value pairspublic static java.lang.Object getSingle(java.lang.Object toFetchFrom)
List
, or the key
of a single key/value pair Map
. Returns null
if the
toFetchFrom
argument is not a List
or
Map
, or if toFetchFrom
does not contain a
single element.
toFetchFrom
- the source List
or Map
public static int checkSize(java.lang.Object obj)
Map
, List
or String
.
obj
- the Map
, List
or String
Map
, List
or
String
, as an int
or 0
if the object is of another classpublic static java.lang.String fastDateFormat(java.util.Date date)
String
representation of a Date
object.
This method is faster than using the SimpleDateFormat
methods.
date
- the date to be formattedString
public static java.lang.String getStackTrace(java.lang.Throwable t)
Throwable
object as a String
.
t
- the Throwable
objectt
as a String
public static java.util.Map remapRow(java.util.Map row, java.util.Map remap, boolean keepNonRemapped)
Map
to a new set of keys. Given an existing
Map
and a mapping from old keys to new keys, create a new Map
that uses the new keys.
row
- the row, a Map
remap
- the map of original to new column nameskeepNonRemapped
- boolean
indicating whether to keep data under
keys that are not remappedremap
is null
public static java.util.Map remapRow(java.util.Map row, java.util.Map remap)
Map
to a new set of keys. Given an existing
Map
and a mapping from old keys to new keys, create a new Map
that uses the new keys. Columns from the original row that were not remapped will be
retained.
row
- the row, a Map
remap
- the Map
of original to new column namesremap
is null
public static java.util.List remapRows(java.util.List rows, java.util.Map remap, boolean keepNonRemapped)
List
of Maps
.
rows
- the List
of rowsremap
- the Map
of original to new column nameskeepNonRemapped
- boolean
indicating whether to keep data under
keys that are not remappedList
, if remap
is null
public static java.util.List remapRows(java.util.List rows, java.util.Map remap)
List
of Maps
. Columns from the
original row that were not remapped will be retained.
rows
- the List
of rowsremap
- the Map
of original to new column namesList
, if remap
is null
public static java.util.List getProperty(java.util.List rows, java.lang.Object column)
List
of rows, and a column name,
returns the List
of values for that column.
The result set is represented as a List
of Map
objects,
with each Map
representing a row of data. The keys and values in each
row correspond to the column names and data, respectively.
For rows that do not have a value for the specified column, no value will be present in the return list, in other words, an empty object will not be added for that row.
rows
- the List
of rowscolumn
- the column name or keyList
of values for column
public static java.util.List toLowerCaseList(java.util.List list)
List
of strings, returns a new List
of lower cased strings.
list
- the List
of stringsList
of lower cased stringspublic static java.lang.String prettyPrint(java.lang.Object obj) throws java.lang.Exception
Object
for viewing or printing as
a String
.
obj
- the Object
to be formatted for outputString
to be used for the
Object
in viewing or printingpublic static void addToIntInMap(java.util.Map map, java.lang.Object key, int addition)
If no Integer is currently stored under "key", creates a new Integer with value 0 before adding to it.
This method exists because of the horrific chain of typecasts otherwise necessary to achieve this effect.
public static void incrementIntInMap(java.util.Map map, java.lang.Object key)
If no Integer is currently stored under "key", creates a new Integer with value 0 before adding to it.
This method exists because of the horrific chain of typecasts otherwise necessary to achieve this effect.
public static int getIntInMap(java.util.Map map, java.lang.Object key)
int
.
Returns 0 if no Integer is currently stored in the Map.
public static java.util.Map getProperties(java.lang.Object bean) throws java.lang.Exception
Map
.
bean
- the JavaBean objectMap
public static java.util.Map getPropertyDescriptors(java.lang.Object bean) throws java.lang.Exception
Map
.
bean
- the JavaBean objectMap
public static java.util.Map getPropertyDescriptors(java.lang.Class beanClass) throws java.lang.Exception
Map
.
beanClass
- the JavaBean classMap
public static java.lang.Object setProperties(java.util.Map propertyMap, java.lang.Object bean) throws java.lang.Exception
Map
.
This method performs automatic type detection and conversion where possible. Conversion
is done via standard bean semantics. Additionally, some standard conversions are
performed automatically - for example inbound java.util.Date object will be
auto-converted to java.sql.Date or java.sqlTimestamp.
Also, a Map value is found in the values of the passed in propertyMap, and the recipient field on the bean is not a Map, this method will treat the target field as a bean, attempting to create the bean via newInstance() and populating it via a recursive call to this method. In other words, this method will auto-create and populate inner beans.
Keys for which conversion fails or for which there are no corresponding Bean properties are ignored.
For properties that have primitive value on the target bean (eg properties of
int
type), generally, the static "valueOf(String)" method for the primitive type
(eg Boolean.valueOf(String)) will be invoked on the result of "toString()" for the Object
being assigned to the primitive property.
As special cases the null string ("") and the null
value will become 0 when
assigned to numeric primitive types (which cannot be null).
If the null string is assigned to a non-primitive numeric type (eg Long), the property will
be assigned null
.
Otherwise, if the type accepted by a setter method on the target bean cannot accept the type of the value in the propertyMap, this method will attempt type conversion by looking for a constructor on the setter method type that accepts instances of the value's type.
propertyMap
- a Map
providing the key-value pairsbean
- the JavaBean objectMap
java.lang.IllegalArgumentException
- if a value provided in the Map
cannot be converted to an appropriate typepublic static boolean recursiveFileDelete(java.io.File file)
file
- file or directory to delete
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |