adavid.reflect
Class ClassReflect

java.lang.Object
  |
  +--adavid.reflect.ClassReflect

public class ClassReflect
extends java.lang.Object

useful functions to perform operations on Class without any instance


Field Summary
static int ALLACCESS
          filter mode definition
static int ANY
           
static java.lang.Class CHAR
          classes used for tests: better to have then once here, and they are usable by other classes as well
static java.lang.Class CHARACTER
          classes used for tests: better to have then once here, and they are usable by other classes as well
static java.lang.Class COLOR
          classes used for tests: better to have then once here, and they are usable by other classes as well
static int NO
           
static int PACKAGE
          filter mode definition
static java.lang.Class STRING
          classes used for tests: better to have then once here, and they are usable by other classes as well
static java.lang.Class STRINGBUFFER
          classes used for tests: better to have then once here, and they are usable by other classes as well
static int YES
           
 
Constructor Summary
ClassReflect(java.lang.Class theClass)
          wraps a class in order to return a proper string representation with respect to the flags
 
Method Summary
static void enableSort(boolean b)
           
static void enableSortModifiers(boolean b)
           
static java.lang.Class[] findClasses(java.lang.String name, boolean all)
          tries to make a class from its name, possibly incomplete (without package prefix) returns all found classes with the given name (several packages) if the flag is true
static int getAbstractFilter()
           
static int getAccessFilter()
           
static java.lang.Class getClass(java.lang.String name)
          used to initialize the Class static members
static java.lang.String getColorName(java.awt.Color color)
          returns the string representation of a color, try the name representation
 java.lang.reflect.Constructor[] getConstructors()
           
static java.lang.reflect.Constructor[] getConstructors(java.lang.Class obj)
          returns the corresponding constructors with respect to the above filters
 java.lang.reflect.Field[] getFields()
           
static java.lang.reflect.Field[] getFields(java.lang.Class obj)
          returns the corresponding fields with respect to the above filters
static int getFinalFilter()
           
 java.lang.Class[] getHierarchy()
           
static java.lang.Class[] getHierarchy(java.lang.Class current)
          returns the class hierarchy of a given class
 java.lang.Class[] getInterfaces()
           
 java.lang.reflect.Method[] getMethods()
           
static java.lang.reflect.Method[] getMethods(java.lang.Class obj)
          returns the corresponding methods with respect to the above filters
static java.lang.StringBuffer getModifiers(java.lang.Class theClass)
          returns the modifiers of a class
static java.lang.StringBuffer getModifiers(java.lang.reflect.Constructor constructor)
          returns the modifiers of the given constructor
static java.lang.StringBuffer getModifiers(java.lang.reflect.Field field)
          returns the modifiers string of a field
static java.lang.StringBuffer getModifiers(java.lang.reflect.Method method)
          returns the modifiers prefix for a method
static java.lang.String[] getNames(java.lang.Class[] list)
          returns the long representation of the classes in argument
static java.lang.String[] getNames(java.lang.Class[] list, boolean isShort)
          returns short/long representation of the classes in argument
static int getNativeFilter()
           
static java.lang.String[] getShortNames(java.lang.Class[] list)
          returns the short representation of the classes in argument
static java.lang.String[] getShortNames(java.lang.String[] list)
          returns the short representation of the classes in argument
static SortableClass getSortableClass(java.lang.Class type)
          returns the SortableClass of a class according to the flags above
static SortableClass[] getSortableClasses(java.lang.Class[] classes)
           
static SortableConstructor getSortableConstructor(java.lang.reflect.Constructor constructor)
          returns the SortableConstructor object of this constructor, according to the flags above
static SortableConstructor[] getSortableConstructors(java.lang.reflect.Constructor[] constructors)
           
static SortableField getSortableField(java.lang.reflect.Field field)
          returns the SortableField of the field given in arguments, according to the flags above
static SortableField[] getSortableFields(java.lang.reflect.Field[] fields)
           
static SortableMethod getSortableMethod(java.lang.reflect.Method method)
          returns a sortable method with its strings in accord to the above flags
static SortableMethod[] getSortableMethods(java.lang.reflect.Method[] methods)
           
static int getStaticFilter()
           
static java.lang.String getString(java.lang.Class type)
          returns the string representation of a class, in accord to the above flags
static java.lang.String getString(java.lang.reflect.Constructor constructor)
          returns the string representation of the constructor given in argument, according to the flags above, but without modifiers
static java.lang.String getString(java.lang.reflect.Field field)
          returns the string representation of the field given in argument, according to the flags above, but without modifiers
static java.lang.String getString(java.lang.reflect.Method method)
          returns a string representation of the method according to the above flags, but without modifiers
static java.lang.String[] getStrings(java.lang.Class[] classes)
           
static java.lang.String[] getStrings(java.lang.reflect.Constructor[] constructors)
           
static java.lang.String[] getStrings(java.lang.reflect.Field[] fields)
           
static java.lang.String[] getStrings(java.lang.reflect.Method[] methods)
          convenient methods:+ modifiers
static int getSynchronizedFilter()
           
static int getTransientFilter()
           
static int getVolatileFilter()
           
 java.lang.Class getWrappedClass()
          methods relative to the wrapped class
static boolean isExtensionOf(java.lang.Class data, java.lang.Class parent)
          says if the class data is an extension of the class parent
static boolean isExtensionOf(java.lang.Class data, java.lang.String className)
          says if the class data is an extension of the className class name
static boolean isImplementationOf(java.lang.Class data, java.lang.String classname)
          says if the class data implements a given interface
static boolean isSameClass(java.lang.Class c, java.lang.String className)
          says if the class is the same as the className class name
static boolean isShorterNames()
           
static boolean isShorterTypes()
           
static boolean isSortEnabled()
           
static boolean isSortModifiers()
           
static void main(java.lang.String[] args)
          test
static void putString(java.lang.Class[] list, java.lang.StringBuffer buffer)
          fills the buffer with the string representations of the list given in argument
static void setAbstractFilter(int filter)
           
static void setAccessFilter(int filter)
          manages the different filters
static void setFinalFilter(int filter)
           
static void setNativeFilter(int filter)
           
static void setShorterNames(boolean b)
          manage the different modes
static void setShorterTypes(boolean b)
           
static void setStaticFilter(int filter)
           
static void setSynchronizedFilter(int filter)
           
static void setTransientFilter(int filter)
           
static void setVolatileFilter(int filter)
           
 java.lang.String toString()
          returns a formated string of the class content
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

STRING

public static final java.lang.Class STRING
classes used for tests: better to have then once here, and they are usable by other classes as well

CHAR

public static final java.lang.Class CHAR
classes used for tests: better to have then once here, and they are usable by other classes as well

CHARACTER

public static final java.lang.Class CHARACTER
classes used for tests: better to have then once here, and they are usable by other classes as well

STRINGBUFFER

public static final java.lang.Class STRINGBUFFER
classes used for tests: better to have then once here, and they are usable by other classes as well

COLOR

public static final java.lang.Class COLOR
classes used for tests: better to have then once here, and they are usable by other classes as well

PACKAGE

public static final int PACKAGE
filter mode definition

ALLACCESS

public static final int ALLACCESS
filter mode definition

YES

public static final int YES

NO

public static final int NO

ANY

public static final int ANY
Constructor Detail

ClassReflect

public ClassReflect(java.lang.Class theClass)
wraps a class in order to return a proper string representation with respect to the flags
Method Detail

getClass

public static java.lang.Class getClass(java.lang.String name)
used to initialize the Class static members

toString

public java.lang.String toString()
returns a formated string of the class content
Overrides:
toString in class java.lang.Object

getWrappedClass

public java.lang.Class getWrappedClass()
methods relative to the wrapped class

getConstructors

public java.lang.reflect.Constructor[] getConstructors()

getFields

public java.lang.reflect.Field[] getFields()

getMethods

public java.lang.reflect.Method[] getMethods()

getHierarchy

public java.lang.Class[] getHierarchy()

getInterfaces

public java.lang.Class[] getInterfaces()

getHierarchy

public static java.lang.Class[] getHierarchy(java.lang.Class current)
returns the class hierarchy of a given class

isImplementationOf

public static boolean isImplementationOf(java.lang.Class data,
                                         java.lang.String classname)
says if the class data implements a given interface

isExtensionOf

public static boolean isExtensionOf(java.lang.Class data,
                                    java.lang.Class parent)
says if the class data is an extension of the class parent

isExtensionOf

public static boolean isExtensionOf(java.lang.Class data,
                                    java.lang.String className)
says if the class data is an extension of the className class name

isSameClass

public static boolean isSameClass(java.lang.Class c,
                                  java.lang.String className)
says if the class is the same as the className class name

setShorterNames

public static void setShorterNames(boolean b)
manage the different modes

isShorterNames

public static boolean isShorterNames()

setShorterTypes

public static void setShorterTypes(boolean b)

isShorterTypes

public static boolean isShorterTypes()

enableSort

public static void enableSort(boolean b)

isSortEnabled

public static boolean isSortEnabled()

enableSortModifiers

public static void enableSortModifiers(boolean b)

isSortModifiers

public static boolean isSortModifiers()

setAccessFilter

public static void setAccessFilter(int filter)
manages the different filters

getAccessFilter

public static int getAccessFilter()

setAbstractFilter

public static void setAbstractFilter(int filter)

getAbstractFilter

public static int getAbstractFilter()

setFinalFilter

public static void setFinalFilter(int filter)

getFinalFilter

public static int getFinalFilter()

setStaticFilter

public static void setStaticFilter(int filter)

getStaticFilter

public static int getStaticFilter()

setNativeFilter

public static void setNativeFilter(int filter)

getNativeFilter

public static int getNativeFilter()

setSynchronizedFilter

public static void setSynchronizedFilter(int filter)

getSynchronizedFilter

public static int getSynchronizedFilter()

setTransientFilter

public static void setTransientFilter(int filter)

getTransientFilter

public static int getTransientFilter()

setVolatileFilter

public static void setVolatileFilter(int filter)

getVolatileFilter

public static int getVolatileFilter()

getSortableClass

public static SortableClass getSortableClass(java.lang.Class type)
returns the SortableClass of a class according to the flags above

getString

public static java.lang.String getString(java.lang.Class type)
returns the string representation of a class, in accord to the above flags

getModifiers

public static java.lang.StringBuffer getModifiers(java.lang.Class theClass)
returns the modifiers of a class

getSortableMethod

public static SortableMethod getSortableMethod(java.lang.reflect.Method method)
returns a sortable method with its strings in accord to the above flags

getString

public static java.lang.String getString(java.lang.reflect.Method method)
returns a string representation of the method according to the above flags, but without modifiers

getModifiers

public static java.lang.StringBuffer getModifiers(java.lang.reflect.Method method)
returns the modifiers prefix for a method

getSortableField

public static SortableField getSortableField(java.lang.reflect.Field field)
returns the SortableField of the field given in arguments, according to the flags above

getString

public static java.lang.String getString(java.lang.reflect.Field field)
returns the string representation of the field given in argument, according to the flags above, but without modifiers

getColorName

public static java.lang.String getColorName(java.awt.Color color)
returns the string representation of a color, try the name representation

getModifiers

public static java.lang.StringBuffer getModifiers(java.lang.reflect.Field field)
returns the modifiers string of a field

getSortableConstructor

public static SortableConstructor getSortableConstructor(java.lang.reflect.Constructor constructor)
returns the SortableConstructor object of this constructor, according to the flags above

getString

public static java.lang.String getString(java.lang.reflect.Constructor constructor)
returns the string representation of the constructor given in argument, according to the flags above, but without modifiers

getModifiers

public static java.lang.StringBuffer getModifiers(java.lang.reflect.Constructor constructor)
returns the modifiers of the given constructor

putString

public static void putString(java.lang.Class[] list,
                             java.lang.StringBuffer buffer)
fills the buffer with the string representations of the list given in argument

getShortNames

public static java.lang.String[] getShortNames(java.lang.Class[] list)
returns the short representation of the classes in argument

getNames

public static java.lang.String[] getNames(java.lang.Class[] list,
                                          boolean isShort)
returns short/long representation of the classes in argument

getShortNames

public static java.lang.String[] getShortNames(java.lang.String[] list)
returns the short representation of the classes in argument

getNames

public static java.lang.String[] getNames(java.lang.Class[] list)
returns the long representation of the classes in argument

getStrings

public static java.lang.String[] getStrings(java.lang.reflect.Method[] methods)
convenient methods:+ modifiers

getStrings

public static java.lang.String[] getStrings(java.lang.reflect.Field[] fields)

getStrings

public static java.lang.String[] getStrings(java.lang.reflect.Constructor[] constructors)

getStrings

public static java.lang.String[] getStrings(java.lang.Class[] classes)

getSortableMethods

public static SortableMethod[] getSortableMethods(java.lang.reflect.Method[] methods)

getSortableFields

public static SortableField[] getSortableFields(java.lang.reflect.Field[] fields)

getSortableConstructors

public static SortableConstructor[] getSortableConstructors(java.lang.reflect.Constructor[] constructors)

getSortableClasses

public static SortableClass[] getSortableClasses(java.lang.Class[] classes)

getFields

public static java.lang.reflect.Field[] getFields(java.lang.Class obj)
returns the corresponding fields with respect to the above filters

getConstructors

public static java.lang.reflect.Constructor[] getConstructors(java.lang.Class obj)
returns the corresponding constructors with respect to the above filters

getMethods

public static java.lang.reflect.Method[] getMethods(java.lang.Class obj)
returns the corresponding methods with respect to the above filters

findClasses

public static java.lang.Class[] findClasses(java.lang.String name,
                                            boolean all)
tries to make a class from its name, possibly incomplete (without package prefix) returns all found classes with the given name (several packages) if the flag is true

main

public static void main(java.lang.String[] args)
test