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.static java.util.Map
getPropertyDescriptors(java.lang.Class beanClass)
Map
. Removes properties added by byte-code instrumentation: interceptFieldCallback
property is removed if class implements net.sf.cglib.transform.impl.InterceptFieldEnabled
interface; fieldHandler
property is removed if class implements org.hibernate.bytecode.javassist.FieldHandled
interface; static java.util.Map
getPropertyDescriptors(java.lang.Object bean)
Map
.static java.lang.Class
getPropertyType(java.lang.Class c, java.lang.String propertyName)
static java.lang.Class
getRealClass(java.lang.Object bean)
static java.lang.Object
getSingle(java.lang.Object toFetchFrom)
List
, or the key of a single key/value pair Map
.static java.lang.String
getStackTrace(java.lang.Throwable t)
Throwable
object as a String
.static java.lang.String
getterName(java.lang.reflect.Method method)
static java.lang.String
hashValue(java.lang.String plaintext)
static java.lang.String
hashValue(java.lang.String plaintext, java.lang.String algorithm)
static java.util.Map
identityMap(java.util.List list)
List
as the keys and values of a Map
.static void
incrementIntInMap(java.util.Map map, java.lang.Object key)
static boolean
isNumberType(java.lang.Class clazz)
true
if provided class is either assignable to Number
or represents one of primitive number types byte, short, int, long, float, double
.static boolean
isTextType(java.lang.Class clazz)
true
if provided class is either assignable to Character
or assignable to String
or represents primitive char
type.static java.lang.Object
jxPathContext(java.lang.Object obj)
static java.util.List
keysAsList(java.util.Map map)
List
of the keys from a Map
.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
.static java.lang.Object[]
listToArray(java.util.List list)
Object
array from a List
.static java.lang.String[]
listToStringArray(java.util.Collection list)
String
array from a List
.static java.util.List
makeList(java.lang.Object element)
List
containing one element.static java.util.List
makeListIfSingle(java.lang.Object obj)
List
containing one element if the element is not a List
.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.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
.static java.util.List
mapIntersectionKeys(java.util.Map one, java.util.Map two)
Maps
.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
.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.static java.util.Properties
mapToProperties(java.util.Map map)
Properties
object from a Map
.static java.util.Map
mapUnion(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.static java.lang.String
md5(java.lang.String plaintext)
static java.lang.Object
nestedGet(java.lang.Object struct, java.lang.String fetch)
Lists
or Map
.static java.util.LinkedHashMap
orderedMapUnion(java.util.Map primary, java.util.Map secondary)
mapUnion
, but keeps order of key/value pairs.static java.lang.String
prettyPrint(java.lang.Object obj)
Object
for viewing or printing as a String
.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).static java.util.Map
putCombinedList(java.util.Map map, java.lang.Object key, java.lang.Object value)
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.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
.static boolean
recursiveFileDelete(java.io.File file)
static void
registerTransformer(java.lang.Class targetType, DataTools.Transformer transformer)
static java.util.Map
remapRow(java.util.Map row, java.util.Map remap)
Map
to a new set of keys.static java.util.Map
remapRow(java.util.Map row, java.util.Map remap, boolean keepNonRemapped)
Map
to a new set of keys.static java.util.List
remapRows(java.util.List rows, java.util.Map remap)
List
of Maps
.static java.util.List
remapRows(java.util.List rows, java.util.Map remap, boolean keepNonRemapped)
List
of Maps
.static java.util.Map
removeEmptyStringValuedKeys(java.util.Map map)
map
where the values are empty strings.static java.util.Map
removeNullValuedKeys(java.util.Map map)
map
where the values are null
.static java.util.Map
reverseMap(java.util.Map origMap)
Map
so that values point at keys.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
.static java.util.List
setIntersection(java.util.Collection one, java.util.Collection two)
List
containing the common elements of two Collections
.static java.lang.Object
setProperties(java.util.Map propertyMap, java.lang.Object bean)
static java.lang.Object
setProperties(java.util.Map propertyMap, java.lang.Object bean, DataSource ds)
Map
.static java.lang.Object
setProperties(java.util.Map propertyMap, java.lang.Object bean, DataSource ds, DSRequest dsRequest)
static java.util.List
setUnion(java.util.List one, java.util.List two)
List
containing all the elements of two Lists
.static java.lang.String
sha(java.lang.String plaintext)
static java.util.List
subsetByPrefix(java.util.List list, java.lang.String prefix)
list
which begin with prefix
.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.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.static java.util.List
toLowerCaseList(java.util.List list)
List
of strings, returns a new List
of lower cased strings.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 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.util.LinkedHashMap orderedMapUnion(java.util.Map primary, java.util.Map secondary)
mapUnion
, but keeps order of key/value pairs. Key/value pairs of primary Map
will go first, then key/value pairs from secondary Map
ignoring dublicates. Consider using LinkedHashMap
for primary and secondary maps to get full value of this method. 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
java.lang.Exception
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 walkjava.lang.Exception
public static void deepRemoveNullValues(java.lang.Object data) throws java.lang.Exception
data
- the nested data structure to walkjava.lang.Exception
public static void deepRemoveEmptyCollections(java.lang.Object data) throws java.lang.Exception
data
- the nested data structure to walkjava.lang.Exception
public 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
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 jxPathContext(java.lang.Object obj)
obj
- the context beanpublic 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 findAll(java.util.List rows, java.lang.Object propertyName, java.lang.Object value)
rows
- the List of MapspropertyName
- the propertyName (key in the Map)value
- expected value of the propertyName (may be null)public static java.util.List findAll(java.util.List rows, java.util.Map properties)
rows
- the List of Mapsproperties
- Map of key/value pairs to match. May not have null values.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)
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.lang.String getterName(java.lang.reflect.Method method)
null
if provided method is not getter.method
- Method
Getter to extract property name.String
Getter property name or null
if provided method is not getter.public static java.lang.reflect.Field[] getClassFields(java.lang.Class c)
null
.c
- Class
to be inspected.Field[]
Array of class fields.public static java.lang.reflect.Method[] getClassMethods(java.lang.Class c)
null
.c
- Class
to be inspected.Method[]
Array of class methods.public static java.lang.Class getPropertyType(java.lang.Class c, java.lang.String propertyName) throws java.beans.IntrospectionException
NullPointerException
if either of parameters is null.c
- Class
to be inspected.propertyName
- String
Name of property.Class
Type of property.java.beans.IntrospectionException
- when specified class has no such property.public static java.lang.Class getCachedClass(java.lang.String className)
Class
object for specified name. Cached class is returned if exists otherwise class object is loaded and cached. Returns null
if class can not be loaded (not in class path).className
- String
qualified class name to load.Class
object of null
if class can not be loaded (not in class path).public static java.lang.Class getRealClass(java.lang.Object bean)
realClass = (Class) ((HibernateProxy) bean).getHibernateLazyInitializer().getPersistentClass();
bean
- Object
Class
public static java.util.Map getProperties(java.lang.Object bean) throws java.lang.Exception
Map
.bean
- the JavaBean objectMap
java.lang.Exception
public static java.util.Map getPropertyDescriptors(java.lang.Object bean) throws java.lang.Exception
Map
.bean
- the JavaBean objectMap
java.lang.Exception
public static java.util.Map getPropertyDescriptors(java.lang.Class beanClass) throws java.lang.Exception
Map
. Removes properties added by byte-code instrumentation:interceptFieldCallback
property is removed if class implements net.sf.cglib.transform.impl.InterceptFieldEnabled
interface;fieldHandler
property is removed if class implements org.hibernate.bytecode.javassist.FieldHandled
interface;beanClass
- the JavaBean classMap
java.lang.Exception
public static java.lang.Object setProperties(java.util.Map propertyMap, java.lang.Object bean) throws java.lang.Exception
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 typejava.lang.Exception
public static java.lang.Object setProperties(java.util.Map propertyMap, java.lang.Object bean, DataSource ds) 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.sql.Timestamp. 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
.
If the target bean property is an enum, this method attempts to set an appropriate value by use of the enum translate strategy set by calling setEnumTranslateStrategy() on the dataSource, if one is provided. See DataSource.setEnumTranslateStrategy(String)
. If there is no DataSource, or it cannot set a value by cleanly using the enumTranslateStrategy, it will attempt to infer a value by considering the incoming value first as a String to match against the enumerated type's value names, and failing that as an integer to match against the enumerated type's values as an ordinal value. If that fails, it sets the target bean property to 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.
Also, if 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.
Similarly if a Collection is found in the propertyMap, it will be applied to a target field of Collection type. If the target field is of an abstract Collection type, the default types used are:
A DataSource can be optionally passed as the third argument and can modify some of the above behaviors, including choice of concrete type when populating bean properties that declare only an abstract type or base type - See DataSource.setProperties(Map, Object)
for details.
propertyMap
- a Map
providing the key-value pairsbean
- the JavaBean objectdataSource
- a context DataSource, if applicable. Can be nulljava.lang.IllegalArgumentException
- if a value provided in the Map
cannot be converted to an appropriate typejava.lang.Exception
public static java.lang.Object setProperties(java.util.Map propertyMap, java.lang.Object bean, DataSource ds, DSRequest dsRequest) throws java.lang.Exception
DynamicDSGenerator
.propertyMap
- a Map
providing the key-value pairsbean
- the JavaBean objectdataSource
- a context DataSource, if applicabledsRequest
- a context DSRequest, if applicablejava.lang.IllegalArgumentException
- if a value provided in the Map
cannot be converted to an appropriate typejava.lang.Exception
public static void registerTransformer(java.lang.Class targetType, DataTools.Transformer transformer)
targetType
- the Class that this Transformer is capable of transforming totransformer
- the Transformer object itselfpublic static java.lang.Object castValue(java.lang.Object value, java.lang.Class targetType, DataSource ds)
value
to targetType
. null
if passed value is null
targetType
then same value returnedtargetType
is Long.TYPE
method returns Long
targetType
is Boolean
and passed value is instance of Number
then 0 converted to false
; any other number converted to true
targetType
is Boolean
and passed value is instance of Character
then 'T', 't', 'Y' and 'y' converted to true
; any other character converted to false
targetType
is Boolean
and passed value is instance of String
then "true", "t", "yes" and "y" (ignoring case) converted to true
; any other string converted to false
targetType
is Byte
and passed value is instance of Boolean
then false
converted to 0; true
converted to 1targetType
is Byte
and passed value is instance of Number
then value may be rounded and/or truncatedtargetType
is Byte
and passed value is instance of String
then value is parsed with Byte.valueOf()
targetType
is Short
and passed value is instance of Boolean
then false
converted to 0; true
converted to 1targetType
is Short
and passed value is instance of Number
then value may be rounded and/or truncatedtargetType
is Short
and passed value is instance of String
then value is parsed with Short.valueOf()
targetType
is Integer
and passed value is instance of Boolean
then false
converted to 0; true
converted to 1targetType
is Integer
and passed value is instance of Number
then value may be rounded and/or truncatedtargetType
is Integer
and passed value is instance of Character
then caracter value is returnedtargetType
is Integer
and passed value is instance of String
then value is parsed with Integer.valueOf()
targetType
is Long
and passed value is instance of Boolean
then false
converted to 0; true
converted to 1targetType
is Long
and passed value is instance of Number
then value may be rounded and/or truncatedtargetType
is Long
and passed value is instance of Character
then caracter value is returnedtargetType
is Long
and passed value is instance of String
then value is parsed with Long.valueOf()
targetType
is Long
and passed value is instance of Date
then Date.getTime()
returnedtargetType
is Float
and passed value is instance of Boolean
then false
converted to 0; true
converted to 1targetType
is Float
and passed value is instance of Number
then value may be rounded and/or truncatedtargetType
is Float
and passed value is instance of Character
then caracter value is returnedtargetType
is Float
and passed value is instance of String
then value is parsed with Float.valueOf()
targetType
is Float
and passed value is instance of Date
then Date.getTime()
returnedtargetType
is Double
and passed value is instance of Boolean
then false
converted to 0; true
converted to 1targetType
is Double
and passed value is instance of Number
then value may be roundedtargetType
is Double
and passed value is instance of Character
then caracter value is returnedtargetType
is Double
and passed value is instance of String
then value is parsed with Double.valueOf()
targetType
is Double
and passed value is instance of Date
then Date.getTime()
returnedtargetType
is Character
and passed value is instance of Boolean
then false
converted to 'f'; true
converted to 't'targetType
is Character
and passed value is instance of Number
then character for value code returned (value may be rounded and/or truncated)targetType
is Character
and passed value is instance of String
then returns first string charater; (char) 0
returned for empty stringtargetType
is String
then value.toString()
returnedtargetType
is BigInteger
and passed value is instance of Boolean
then false
converted to BigInteger.ZERO
; true
converted to BigInteger.ONE
targetType
is BigInteger
and passed value is instance of Number
then value may be roundedtargetType
is BigInteger
and passed value is instance of Character
then caracter value is returnedtargetType
is BigInteger
and passed value is instance of String
then value is parsedtargetType
is BigInteger
and passed value is instance of Date
then Date.getTime()
returnedtargetType
is BigDecimal
and passed value is instance of Boolean
then false
converted to BigDecimal.ZERO
; true
converted to BigDecimal.ONE
targetType
is BigDecimal
and passed value is instance of Number
then value converted to BigDecimal
targetType
is BigDecimal
and passed value is instance of Character
then caracter value is returnedtargetType
is BigDecimal
and passed value is instance of String
then value is parsedtargetType
is BigDecimal
and passed value is instance of Date
then Date.getTime()
returnedtargetType
is java.util.Date
and passed value is instance of Number
then java.util.Date
created with value as miliseconds (value may be rounded and/or truncated)targetType
is java.util.Date
and passed value is instance of String
then value is parsed with DateFormat.getDateTimeInstance()
targetType
is java.sql.Date
and passed value is instance of Number
then java.sql.Date
created with value as miliseconds (value may be rounded and/or truncated)targetType
is java.sql.Date
and passed value is instance of String
then value is parsed with DateFormat.getDateInstance()
targetType
is java.sql.Date
and passed value is instance of java.util.Date
then value is convertedtargetType
is java.sql.Date
and passed value is instance of java.sql.Time
then value is convertedtargetType
is java.sql.Date
and passed value is instance of java.sql.Timestamp
then value is convertedtargetType
is java.sql.Time
and passed value is instance of Number
then java.sql.Time
created with value as miliseconds (value may be rounded and/or truncated)targetType
is java.sql.Time
and passed value is instance of String
then value is parsed with DateFormat.getTimeInstance()
targetType
is java.sql.Time
and passed value is instance of java.util.Date
then value is convertedtargetType
is java.sql.Time
and passed value is instance of java.sql.Date
then value is convertedtargetType
is java.sql.Time
and passed value is instance of java.sql.Timestamp
then value is convertedtargetType
is java.sql.Timestamp
and passed value is instance of Number
then java.sql.Timestamp
created with value as miliseconds (value may be rounded and/or truncated)targetType
is java.sql.Timestamp
and passed value is instance of String
then value is parsed with DateFormat.getDateTimeInstance()
targetType
is java.sql.Timestamp
and passed value is instance of java.util.Date
then value is convertedtargetType
is java.sql.Timestamp
and passed value is instance of java.sql.Date
then value is convertedtargetType
is java.sql.Timestamp
and passed value is instance of java.sql.Time
then value is convertedvalue
- Object
value to be converted.targetType
- Class
conversion target type.ds
- DataSource
initiating conversion.Object
converted value.java.lang.ClassCastException
- if value can not be converted or parsing exception occurs.public static boolean isTextType(java.lang.Class clazz)
true
if provided class is either assignable to Character
or assignable to String
or represents primitive char
type.clazz
- Class
for testing.boolean
true
if specified class represents class for text; false
- for all other classes.public static boolean isNumberType(java.lang.Class clazz)
true
if provided class is either assignable to Number
or represents one of primitive number types byte, short, int, long, float, double
.clazz
- Class
for testing.boolean
true
if specified class represents class for numbers; false
- for all other classes.public static boolean recursiveFileDelete(java.io.File file)
file
- file or directory to deletepublic static java.lang.String md5(java.lang.String plaintext) throws java.lang.Exception
plaintext
- the text to encryptjava.lang.Exception
public static java.lang.String sha(java.lang.String plaintext) throws java.lang.Exception
plaintext
- the text to encryptjava.lang.Exception
public static java.lang.String hashValue(java.lang.String plaintext) throws java.lang.Exception
plaintext
- the text to encryptjava.lang.Exception
public static java.lang.String hashValue(java.lang.String plaintext, java.lang.String algorithm) throws java.lang.Exception
plaintext
- the text to encryptalgorithm
- the encryption algorithm to use. Search the client-side documentation for "HashAlgorithm" for details.java.lang.Exception
public static java.lang.String formatDate(java.lang.String format, java.util.Date date)
format
- A valid SimpleDateFormat format stringdate
- The date to formatpublic static org.apache.log4j.spi.LoggerRepository getLoggerRepository()
LoggerRepository
instance that was configured from log4j.isc.config.xml
. Use this method to access log4j loggers for custom categories defined in this file.LoggerRepository
instance