com.epam.xml.utils
Class ReflectUtil

java.lang.Object
  extended by com.epam.xml.utils.ReflectUtil

public final class ReflectUtil
extends Object

Provides ability to work with generic type.


Constructor Summary
ReflectUtil()
           
 
Method Summary
static void clearAttributes(Object source, Class<? extends Annotation> attributeMarker)
           
static String concateStrings(Object instance, String value)
          Concatenates the strings.
static Object createGenericInstance(Class clazz)
          Creates the generic instance if clazz.
static Class<?> getClassInPath(String path, String className)
           
static void invokeAddListValue(Object instance, Object value, Method method)
          Invokes add to list method
static void invokeAddToList(Object instance, Method method, String value, Class<?> type)
          Invokes the method
static void invokeSetValue(Object instance, Object value, Method method)
          Invokes the method.
static void invokeSetValue(Object instance, String value, Class<?> type, Method method)
          Invokes the method
static boolean isArray(Class<?> _class)
          Returns true, if array.
static boolean isArray(Method method)
          Returns true if method for array type.
static boolean isPrimitiveField(Class<?> type)
          Checks if @type is primitive
static Object parseValue(String value, Class classType)
          Creates a instance of classType with specified value.
static String prepareSting(String propertyName, boolean isUpper, boolean setter)
          Constructs the method name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReflectUtil

public ReflectUtil()
Method Detail

getClassInPath

public static Class<?> getClassInPath(String path,
                                      String className)
                               throws IOException,
                                      ClassNotFoundException
Throws:
IOException
ClassNotFoundException

prepareSting

public static String prepareSting(String propertyName,
                                  boolean isUpper,
                                  boolean setter)
Constructs the method name.

Parameters:
propertyName - the name of property
isUpper - if flag set to true, the first letter in property name replaced to uppper.
setter - the setter flag, if sets to true the method name concats with set prefix, v.v get.

parseValue

public static Object parseValue(String value,
                                Class classType)
Creates a instance of classType with specified value.

Parameters:
value - the value
classType - the class
Throws:
RuntimeException - if classType is undefined

createGenericInstance

public static Object createGenericInstance(Class clazz)
                                    throws InstantiationException,
                                           IllegalAccessException
Creates the generic instance if clazz.

Parameters:
clazz - the class
Throws:
InstantiationException
IllegalAccessException

isPrimitiveField

public static boolean isPrimitiveField(Class<?> type)
Checks if @type is primitive

Parameters:
type - the type

invokeAddToList

public static void invokeAddToList(Object instance,
                                   Method method,
                                   String value,
                                   Class<?> type)
                            throws IllegalAccessException,
                                   InvocationTargetException,
                                   NoSuchMethodException,
                                   InstantiationException
Invokes the method

Parameters:
instance - the instance
method - the method
value - the value
type - the type
Throws:
IllegalAccessException
InvocationTargetException
NoSuchMethodException
InstantiationException

invokeAddListValue

public static void invokeAddListValue(Object instance,
                                      Object value,
                                      Method method)
Invokes add to list method

Parameters:
instance - the instance
value - the value
method - the method

invokeSetValue

public static void invokeSetValue(Object instance,
                                  Object value,
                                  Method method)
Invokes the method.

Parameters:
instance - the instance
value - the value
method - the method

invokeSetValue

public static void invokeSetValue(Object instance,
                                  String value,
                                  Class<?> type,
                                  Method method)
                           throws NoSuchMethodException,
                                  IllegalAccessException,
                                  InvocationTargetException,
                                  InstantiationException
Invokes the method

Parameters:
instance - the instance
value - the value
type - the type
method - the method
Throws:
NoSuchMethodException
IllegalAccessException
InvocationTargetException
InstantiationException

isArray

public static boolean isArray(Class<?> _class)
Returns true, if array.

Parameters:
_class - - Class
Returns:
true if class is List or ArrayList

isArray

public static boolean isArray(Method method)
Returns true if method for array type.

Parameters:
method - the method
Returns:
true if class is List or ArrayList

concateStrings

public static String concateStrings(Object instance,
                                    String value)
Concatenates the strings.

Parameters:
instance - the instance
value - the value
Returns:
String

clearAttributes

public static void clearAttributes(Object source,
                                   Class<? extends Annotation> attributeMarker)


Copyright © 2000-2014 EPAM Systems. All Rights Reserved.