Throws NullPointerException
if either of parameters is null.
c
- Class
to be inspected.propertyName
- String
Name of property.Class
Type of property.IntrospectionException
- when specified class has no such property.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).realClass = (Class) ((HibernateProxy) bean).getHibernateLazyInitializer().getPersistentClass();
bean
- Object
Class
Map
.bean
- the JavaBean objectMap
Exception
Map
.bean
- the JavaBean objectMap
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
Exception
propertyMap
- a Map
providing the key-value pairsbean
- the JavaBean objectMap
IllegalArgumentException
- if a value provided in the Map
cannot be converted to an appropriate typeException
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.
If the target bean property is of Joda-Time type (org.joda.time.DateTime, DateMidnight, LocalDateTime, LocalDate, LocalTime
), then value is passed to the target type constructor taking Object
parameter. See Joda documentation for supported inputs.
If the target bean property is of Java 8 Date/Time API type (java.time.LocalDate, LocalDateTime, LocalTime
), it is created with ZoneId.systemDefault()
for Date
input or attempting <target-type>.parse(input.toString())
for everything else.
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 nullIllegalArgumentException
- if a value provided in the Map
cannot be converted to an appropriate typeException
DynamicDSGenerator
.propertyMap
- a Map
providing the key-value pairsbean
- the JavaBean objectdataSource
- a context DataSource, if applicabledsRequest
- a context DSRequest, if applicableIllegalArgumentException
- if a value provided in the Map
cannot be converted to an appropriate typeException
targetType
- the Class that this Transformer is capable of transforming totransformer
- the Transformer object itselfvalue
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.ClassCastException
- if value can not be converted or parsing exception occurs.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.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.file
- file or directory to deleteplaintext
- the text to encryptException
sha256(java.lang.String)
or sha512(java.lang.String)
instead to generate a secure hash, as SHA-1 is vulnerable to attackers creating collisions with current technology.plaintext
- the text to encryptException
plaintext
- the text to encryptException
plaintext
- the text to encryptException
plaintext
- the text to encryptException
plaintext
- the text to encryptException
plaintext
- the text to encryptalgorithm
- the encryption algorithm to use. Search the client-side documentation for "HashAlgorithm" for details.Exception
format
- A valid SimpleDateFormat format stringdate
- The date to formatLoggerContext
by calling the new getLoggerContext()
API.LoggerContext
instance that was configured from log4j2.isc.config.xml
. Use this method to access log4j2 loggers for custom categories defined in this file. Note: use this method only if log4j2 logging is used.
LoggerContext
instance if configured, otherwise null
. Note: Object
return type is used to avoid unnecessary log4j2 dependency if alternative logging system is used.
sha256(java.lang.String)
orsha512(java.lang.String)
instead to generate a secure hash, as MD5 is vulnerable to attackers creating collisions with current technology.