|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.midao.jdbc.core.handlers.utils.MappingUtils
public class MappingUtils
Collection of utilities used to map values from one type into another (Bean->Map, Map->Bean)
Constructor Summary | |
---|---|
MappingUtils()
|
Method Summary | ||
---|---|---|
static java.lang.Object |
callGetter(java.lang.Object target,
java.beans.PropertyDescriptor prop)
Invokes Property Descriptor Getter and returns value returned by that function. |
|
static void |
callSetter(java.lang.Object target,
java.beans.PropertyDescriptor prop,
java.lang.Object value)
Invokes Property Descriptor Setter and sets value @value into it. |
|
static java.util.List<QueryParameters> |
convertResultSet(java.sql.ResultSet rs)
Converts java.sql.ResultSet into List of QueryParameters. |
|
static boolean |
hasFunction(java.lang.Object object,
java.lang.String functionName,
java.lang.Class[] parameters)
Checks if Instance has specified function |
|
static void |
invokeConnectionSetter(java.sql.Connection conn,
java.lang.String functionName,
java.lang.Object value)
Invocation of Connection setter functions
This function provides flexibility which required to use Connection
with different Java versions: 5/6 etc. |
|
static java.lang.Object |
invokeFunction(java.lang.Object object,
java.lang.String functionName,
java.lang.Class[] parameters,
java.lang.Object[] values)
Invokes class function using Reflection |
|
static java.lang.Object |
invokeStaticFunction(java.lang.Class clazz,
java.lang.String functionName,
java.lang.Class[] parameters,
java.lang.Object[] values)
Invokes class function using Reflection |
|
static java.util.Map<java.lang.String,java.beans.PropertyDescriptor> |
mapPropertyDescriptors(java.lang.Class<?> clazz)
Reads property descriptors of class and puts them into Map. |
|
static
|
newInstance(java.lang.Class<T> clazz)
Creates new Instance of class specified. |
|
static boolean |
objectAssignableTo(java.lang.Object object,
java.lang.String className)
Checks if instance can be cast to specified Class |
|
static boolean |
objectExtends(java.lang.Object object,
java.lang.String superClassName)
Checks if Instance extends specified Class Class.isAssignableFrom(Class) is not used as Class might not be available
and String representation can only be used |
|
static boolean |
objectImplements(java.lang.Object object,
java.lang.String interfaceClass)
Checks if Instance implements specified Interface Class.isAssignableFrom(Class) is not used as Interface might not be available
and String representation can only be used |
|
static boolean |
objectInstanceOf(java.lang.Object object,
java.lang.String className)
Checks if instance is of specified class |
|
static java.beans.PropertyDescriptor[] |
propertyDescriptors(java.lang.Class<?> clazz)
Reads property descriptors of class |
|
static java.lang.Object |
returnStaticField(java.lang.Class clazz,
java.lang.String fieldName)
Returns class static field value Is used to return Constants |
|
static java.util.Map<java.lang.String,java.lang.Object> |
toMap(java.lang.Object inputParameter,
java.beans.PropertyDescriptor[] propertyDescriptors)
Converts Java Object into Map |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public MappingUtils()
Method Detail |
---|
public static java.util.Map<java.lang.String,java.lang.Object> toMap(java.lang.Object inputParameter, java.beans.PropertyDescriptor[] propertyDescriptors)
inputParameter
- Object which would be converted into MappropertyDescriptors
- Array of Class PropertyDescriptors
public static java.beans.PropertyDescriptor[] propertyDescriptors(java.lang.Class<?> clazz)
clazz
- Class for which we are getting property descriptors
public static java.util.Map<java.lang.String,java.beans.PropertyDescriptor> mapPropertyDescriptors(java.lang.Class<?> clazz)
clazz
- Class for which Property Descriptors would be read
public static java.lang.Object callGetter(java.lang.Object target, java.beans.PropertyDescriptor prop)
target
- Object Getter of which would be executedprop
- Property Descriptor which would be used to invoke Getter
public static void callSetter(java.lang.Object target, java.beans.PropertyDescriptor prop, java.lang.Object value)
target
- Object Getter of which would be executedprop
- Property Descriptor which would be used to invoke Gettervalue
- Value which should be set into @targetpublic static java.util.List<QueryParameters> convertResultSet(java.sql.ResultSet rs) throws java.sql.SQLException
rs
- ResultSet values from which would be read
java.sql.SQLException
- propagates SQLException sent from ResultSetpublic static <T> T newInstance(java.lang.Class<T> clazz) throws MidaoException
clazz
- Class which should be instantiated
java.sql.SQLException
- in case of instantiation error
MidaoException
public static void invokeConnectionSetter(java.sql.Connection conn, java.lang.String functionName, java.lang.Object value) throws MidaoException
Connection
setter functions
This function provides flexibility which required to use Connection
with different Java versions: 5/6 etc.
conn
- SQL ConnectionfunctionName
- SQL Connection parameter namevalue
- value which would be set
MidaoException
- if property wasn't foundpublic static java.lang.Object invokeFunction(java.lang.Object object, java.lang.String functionName, java.lang.Class[] parameters, java.lang.Object[] values) throws MidaoException
object
- Instance which function would be invokedfunctionName
- function nameparameters
- function parameters (array of Class)values
- function values (array of Object)
MidaoException
- in case function doesn't existspublic static java.lang.Object invokeStaticFunction(java.lang.Class clazz, java.lang.String functionName, java.lang.Class[] parameters, java.lang.Object[] values) throws MidaoException
clazz
- Class which function would be invokedfunctionName
- function nameparameters
- function parameters (array of Class)values
- function values (array of Object)
MidaoException
- in case function doesn't existspublic static boolean hasFunction(java.lang.Object object, java.lang.String functionName, java.lang.Class[] parameters)
object
- Instance which function would be checkedfunctionName
- function nameparameters
- function parameters (array of Class)
public static boolean objectImplements(java.lang.Object object, java.lang.String interfaceClass)
Class.isAssignableFrom(Class)
is not used as Interface might not be available
and String representation can only be used
object
- Instance which would be checkedinterfaceClass
- Interface with which it would be checked
public static boolean objectExtends(java.lang.Object object, java.lang.String superClassName)
Class.isAssignableFrom(Class)
is not used as Class might not be available
and String representation can only be used
object
- Instance which would be checkedsuperClassName
- Class with which it would be checked
public static boolean objectInstanceOf(java.lang.Object object, java.lang.String className)
object
- Instance which would be checkedclassName
- Class name with which it would be checked
public static boolean objectAssignableTo(java.lang.Object object, java.lang.String className) throws MidaoException
object
- Instance which would be checkedclassName
- Class name with which it would be checked
MidaoException
public static java.lang.Object returnStaticField(java.lang.Class clazz, java.lang.String fieldName) throws MidaoException
clazz
- Class static field of which would be returnedfieldName
- field name
MidaoException
- if field is not present or access is prohibited
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |