Dashboard Builder Commons 6.2.0.Beta2

org.jboss.dashboard.commons.misc
Class ReflectionUtils

java.lang.Object
  extended by org.jboss.dashboard.commons.misc.ReflectionUtils

public class ReflectionUtils
extends Object


Field Summary
static String ARRAYS_DELIMITER
           
 
Constructor Summary
ReflectionUtils()
           
 
Method Summary
static List<Field> getClassFields(Class clazz, Class type, boolean isStatic, String[] fieldsToIgnore)
           
static List<Field> getClassHierarchyFields(Class clazz, Class fieldType, boolean isStatic, String[] fieldsToIgnore)
           
static Class[] getClassHierarchyInterfaces(Class clazz)
           
static Field getField(Object obj, String propertyName)
           
static String getGetMethodName(String fieldName)
          Generates the name of a get method for the given field name.
static Method getGetter(Object obj, String propertyName)
           
static Object getPrivateField(Object o, String fieldName)
           
static String getSetMethodName(String fieldName)
          Generates the name of a create method for the given field name.
static Method getSetter(Object obj, Method getter, String propertyName)
           
static Object invokeMethod(Object o, String methodName, Object[] params)
           
static boolean isGetMethod(Method method)
          Checks if the given method is a get method.
static boolean isIsMethod(Method method)
          Checks if the given method is a 'is' method.
static boolean isSetMethod(Method method)
          Checks if the given method is a set method.
static void main(String[] args)
           
static
<T> T
newInstanceForClass(Class<T> type)
           
static Object parseAndSetFieldValue(Object obj, String fieldName, String fieldValue)
           
static Object parseAndSetFieldValues(Object obj, String fieldName, String[] fieldValues)
           
static
<T> T
parseValue(String value, Class<T> type)
           
static Object setFieldFile(Object obj, String fieldName, File fieldValue)
           
static Object setFieldValue(Object obj, String fieldName, Object fieldValue)
           
static Object[] toArray(String value, Class type)
           
static boolean toBoolean(String parameter)
           
static byte toByte(String parameter)
           
static byte[] toByteArray(File f)
           
static char toChar(String parameter)
           
static double toDouble(String parameter)
           
static Object toFile(String paramValue)
           
static float toFloat(String parameter)
           
static int toInt(String parameter)
           
static long toLong(String parameter)
           
static short toShort(String parameter)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ARRAYS_DELIMITER

public static final String ARRAYS_DELIMITER
See Also:
Constant Field Values
Constructor Detail

ReflectionUtils

public ReflectionUtils()
Method Detail

getPrivateField

public static Object getPrivateField(Object o,
                                     String fieldName)

invokeMethod

public static Object invokeMethod(Object o,
                                  String methodName,
                                  Object[] params)

getClassHierarchyFields

public static List<Field> getClassHierarchyFields(Class clazz,
                                                  Class fieldType,
                                                  boolean isStatic,
                                                  String[] fieldsToIgnore)

getClassFields

public static List<Field> getClassFields(Class clazz,
                                         Class type,
                                         boolean isStatic,
                                         String[] fieldsToIgnore)

getClassHierarchyInterfaces

public static Class[] getClassHierarchyInterfaces(Class clazz)

getGetMethodName

public static final String getGetMethodName(String fieldName)
Generates the name of a get method for the given field name.

Parameters:
fieldName - the field name to generate a method name for
Returns:
the generated get method name

getSetMethodName

public static final String getSetMethodName(String fieldName)
Generates the name of a create method for the given field name.

Parameters:
fieldName - the field name to generate a method name for
Returns:
the generated create method name

isSetMethod

public static final boolean isSetMethod(Method method)
Checks if the given method is a set method.

Parameters:
method - the Method to check
Returns:
true if it is a set method

isGetMethod

public static final boolean isGetMethod(Method method)
Checks if the given method is a get method.

Parameters:
method - the Method to check
Returns:
true if it is a get method

isIsMethod

public static final boolean isIsMethod(Method method)
Checks if the given method is a 'is' method.

Parameters:
method - the Method to check
Returns:
true if it is a 'is' method

parseAndSetFieldValues

public static Object parseAndSetFieldValues(Object obj,
                                            String fieldName,
                                            String[] fieldValues)
                                     throws Exception
Throws:
Exception

parseAndSetFieldValue

public static Object parseAndSetFieldValue(Object obj,
                                           String fieldName,
                                           String fieldValue)
                                    throws Exception
Throws:
Exception

setFieldValue

public static Object setFieldValue(Object obj,
                                   String fieldName,
                                   Object fieldValue)
                            throws Exception
Throws:
Exception

setFieldFile

public static Object setFieldFile(Object obj,
                                  String fieldName,
                                  File fieldValue)
                           throws Exception
Throws:
Exception

getField

public static Field getField(Object obj,
                             String propertyName)

getGetter

public static Method getGetter(Object obj,
                               String propertyName)

getSetter

public static Method getSetter(Object obj,
                               Method getter,
                               String propertyName)

newInstanceForClass

public static <T> T newInstanceForClass(Class<T> type)

parseValue

public static <T> T parseValue(String value,
                               Class<T> type)
                    throws Exception
Throws:
Exception

toArray

public static Object[] toArray(String value,
                               Class type)
                        throws Exception
Throws:
Exception

toInt

public static int toInt(String parameter)
                 throws Exception
Throws:
Exception

toBoolean

public static boolean toBoolean(String parameter)
                         throws Exception
Throws:
Exception

toLong

public static long toLong(String parameter)
                   throws Exception
Throws:
Exception

toChar

public static char toChar(String parameter)
                   throws Exception
Throws:
Exception

toDouble

public static double toDouble(String parameter)
                       throws Exception
Throws:
Exception

toFloat

public static float toFloat(String parameter)
                     throws Exception
Throws:
Exception

toByte

public static byte toByte(String parameter)
                   throws Exception
Throws:
Exception

toShort

public static short toShort(String parameter)
                     throws Exception
Throws:
Exception

toFile

public static Object toFile(String paramValue)

toByteArray

public static byte[] toByteArray(File f)
                          throws IOException
Throws:
IOException

main

public static void main(String[] args)

Dashboard Builder Commons 6.2.0.Beta2

Copyright © 2012-2014 JBoss by Red Hat. All Rights Reserved.