jodd.introspector
Class ClassDescriptor

java.lang.Object
  extended by jodd.introspector.ClassDescriptor

public class ClassDescriptor
extends java.lang.Object

A descriptor class for all methods/fields/constructors of a class. Static methods/fields are ignored. Hash table are pre-built to speed up query.

Descriptors are 'lazy': various internal caches are created only on request.

Throughout this class, public members are defined as members defined with "public" keyword and declared in a public type. Public members declared by a non-public class is considered non-public because access to it from outside is prohibited by the java access control anyway.

Public members defined in public classes are always preferred even when we allow private/protected members and types to be visible. So if a non-public subtype and a public super type both have a field with the same name, the field in the public super type is always used.


Field Summary
protected  jodd.introspector.Ctors allCtors
           
protected  jodd.introspector.Fields allFields
           
protected  jodd.introspector.Methods allMethods
           
protected  jodd.introspector.Properties allProperties
           
protected  jodd.introspector.Ctors publicCtors
           
protected  jodd.introspector.Fields publicFields
           
protected  jodd.introspector.Methods publicMethods
           
protected  jodd.introspector.Properties publicProperties
           
 
Constructor Summary
protected ClassDescriptor(java.lang.Class type)
           
 
Method Summary
 java.lang.String[] getAllBeanGetterNames()
          Returns all public bean getters names.
 java.lang.String[] getAllBeanGetterNames(boolean suppressSecurity)
          Returns all bean getters names.
 java.lang.reflect.Method[] getAllBeanGetters()
          Returns all public bean getters.
 java.lang.reflect.Method[] getAllBeanGetters(boolean suppressSecurity)
          Returns all bean getters.
 java.lang.String[] getAllBeanSetterNames()
          Returns an array of all public bean setters names.
 java.lang.String[] getAllBeanSetterNames(boolean suppressSecurity)
          Returns an array of all bean setters names.
 java.lang.reflect.Method[] getAllBeanSetters()
          Returns an array of all public bean setters.
 java.lang.reflect.Method[] getAllBeanSetters(boolean suppressSecurity)
          Returns an array of all bean setters.
 java.lang.reflect.Constructor[] getAllCtors()
          Returns an array of all public ctors.
 java.lang.reflect.Constructor[] getAllCtors(boolean suppressSecurity)
          Returns an array of all ctors.
 java.lang.reflect.Field[] getAllFields()
          Returns an array of all public fields.
 java.lang.reflect.Field[] getAllFields(boolean suppressSecurity)
          Returns an array of all fields.
 java.lang.reflect.Method[] getAllMethods()
          Returns an array of all public methods.
 java.lang.reflect.Method[] getAllMethods(boolean supressSecurity)
          Returns an array of all methods.
 java.lang.reflect.Method[] getAllMethods(java.lang.String name)
          Returns an array of all public methods with the same name.
 java.lang.reflect.Method[] getAllMethods(java.lang.String name, boolean supressSecurity)
          Returns an array of all methods with the same name.
 java.lang.reflect.Method getBeanGetter(java.lang.String name)
          Returns public bean getter identified by name.
 java.lang.reflect.Method getBeanGetter(java.lang.String name, boolean suppressSecurity)
          Returns bean getter identified by name.
 java.lang.reflect.Method getBeanSetter(java.lang.String name)
          Returns public bean setter identified by name.
 java.lang.reflect.Method getBeanSetter(java.lang.String name, boolean suppressSecurity)
          Returns bean setter identified by name.
 java.lang.reflect.Constructor getCtor(java.lang.Class[] args)
          Returns the public ctor identified by arguments or null if not found.
 java.lang.reflect.Constructor getCtor(java.lang.Class[] args, boolean suppressSecurity)
          Returns the constructor identified by arguments or null if not found.
 int getCtorCount()
          Returns the total number of public constructors.
 int getCtorCount(boolean suppressSecurity)
          Returns the total number of constructors.
 java.lang.reflect.Constructor getDefaultCtor()
          Returns the public default ctor or null if not found.
 java.lang.reflect.Constructor getDefaultCtor(boolean suppressSecurity)
          Returns the default ctor or null if not found.
 java.lang.reflect.Field getField(java.lang.String name)
          Returns the public field identified by name or null if not found.
 java.lang.reflect.Field getField(java.lang.String name, boolean suppressSecurity)
          Returns the field identified by name or null if not found.
 int getFieldCount()
          Returns the total number of public fields.
 int getFieldCount(boolean suppressSecurity)
          Returns the total number of fields.
 java.lang.reflect.Method getMethod(java.lang.String name)
          Returns the public method identified by name or null if not found.
 java.lang.reflect.Method getMethod(java.lang.String name, boolean suppressSecurity)
          Returns the method identified by name or null if not found.
 java.lang.reflect.Method getMethod(java.lang.String name, java.lang.Class[] params)
          Returns the public method identified by name and parameters.
 java.lang.reflect.Method getMethod(java.lang.String name, java.lang.Class[] params, boolean suppressSecurity)
          Returns the method identified by name and parameters.
 java.lang.Class getType()
          Get the class object that this descriptor describes.
 int getUsageCount()
          Returns number of class description usages.
protected  void increaseUsageCount()
          Increases descriptor usage.
protected  void inspectCtors()
          Inspect class ctors and create ctors cache.
protected  void inspectFields()
          Inspect class fields and create fields cache.
protected  void inspectMethods()
          Inspect methods and create methods cache.
protected  void inspectProperties()
          Inspect methods and create properties cache.
 boolean isCollection()
           
 boolean isList()
          Returns true if class is a List.
 boolean isMap()
          Returns true if class is a Map.
 boolean isSet()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

publicFields

protected jodd.introspector.Fields publicFields

allFields

protected jodd.introspector.Fields allFields

publicMethods

protected jodd.introspector.Methods publicMethods

allMethods

protected jodd.introspector.Methods allMethods

publicProperties

protected jodd.introspector.Properties publicProperties

allProperties

protected jodd.introspector.Properties allProperties

publicCtors

protected jodd.introspector.Ctors publicCtors

allCtors

protected jodd.introspector.Ctors allCtors
Constructor Detail

ClassDescriptor

protected ClassDescriptor(java.lang.Class type)
Method Detail

getType

public java.lang.Class getType()
Get the class object that this descriptor describes.


increaseUsageCount

protected void increaseUsageCount()
Increases descriptor usage.


getUsageCount

public int getUsageCount()
Returns number of class description usages.


isMap

public boolean isMap()
Returns true if class is a Map.


isList

public boolean isList()
Returns true if class is a List.


isSet

public boolean isSet()

isCollection

public boolean isCollection()

inspectFields

protected void inspectFields()
Inspect class fields and create fields cache. Default implementation uses ReflectUtil.getAccessibleFields(Class) for retrieving only accessible fields.


getField

public java.lang.reflect.Field getField(java.lang.String name,
                                        boolean suppressSecurity)
Returns the field identified by name or null if not found.

Parameters:
name - field name
suppressSecurity - whether to look at non-public ones.

getField

public java.lang.reflect.Field getField(java.lang.String name)
Returns the public field identified by name or null if not found.


getFieldCount

public int getFieldCount(boolean suppressSecurity)
Returns the total number of fields.


getFieldCount

public int getFieldCount()
Returns the total number of public fields.


getAllFields

public java.lang.reflect.Field[] getAllFields(boolean suppressSecurity)
Returns an array of all fields.


getAllFields

public java.lang.reflect.Field[] getAllFields()
Returns an array of all public fields.


inspectMethods

protected void inspectMethods()
Inspect methods and create methods cache. Default implementation uses ReflectUtil.getAccessibleMethods(Class) for retrieving only accessible methods.


getMethod

public java.lang.reflect.Method getMethod(java.lang.String name,
                                          boolean suppressSecurity)
Returns the method identified by name or null if not found.

Parameters:
name - method name
suppressSecurity - whether to look at non-public ones.

getMethod

public java.lang.reflect.Method getMethod(java.lang.String name)
Returns the public method identified by name or null if not found.


getMethod

public java.lang.reflect.Method getMethod(java.lang.String name,
                                          java.lang.Class[] params,
                                          boolean suppressSecurity)
Returns the method identified by name and parameters.


getMethod

public java.lang.reflect.Method getMethod(java.lang.String name,
                                          java.lang.Class[] params)
Returns the public method identified by name and parameters.


getAllMethods

public java.lang.reflect.Method[] getAllMethods(java.lang.String name,
                                                boolean supressSecurity)
Returns an array of all methods with the same name.


getAllMethods

public java.lang.reflect.Method[] getAllMethods(java.lang.String name)
Returns an array of all public methods with the same name.


getAllMethods

public java.lang.reflect.Method[] getAllMethods(boolean supressSecurity)
Returns an array of all methods.


getAllMethods

public java.lang.reflect.Method[] getAllMethods()
Returns an array of all public methods.


inspectProperties

protected void inspectProperties()
Inspect methods and create properties cache.


getBeanSetter

public java.lang.reflect.Method getBeanSetter(java.lang.String name,
                                              boolean suppressSecurity)
Returns bean setter identified by name.


getBeanSetter

public java.lang.reflect.Method getBeanSetter(java.lang.String name)
Returns public bean setter identified by name.


getAllBeanSetters

public java.lang.reflect.Method[] getAllBeanSetters(boolean suppressSecurity)
Returns an array of all bean setters.


getAllBeanSetters

public java.lang.reflect.Method[] getAllBeanSetters()
Returns an array of all public bean setters.


getAllBeanSetterNames

public java.lang.String[] getAllBeanSetterNames(boolean suppressSecurity)
Returns an array of all bean setters names.


getAllBeanSetterNames

public java.lang.String[] getAllBeanSetterNames()
Returns an array of all public bean setters names.


getBeanGetter

public java.lang.reflect.Method getBeanGetter(java.lang.String name,
                                              boolean suppressSecurity)
Returns bean getter identified by name.


getBeanGetter

public java.lang.reflect.Method getBeanGetter(java.lang.String name)
Returns public bean getter identified by name.


getAllBeanGetters

public java.lang.reflect.Method[] getAllBeanGetters(boolean suppressSecurity)
Returns all bean getters.


getAllBeanGetters

public java.lang.reflect.Method[] getAllBeanGetters()
Returns all public bean getters.


getAllBeanGetterNames

public java.lang.String[] getAllBeanGetterNames(boolean suppressSecurity)
Returns all bean getters names.


getAllBeanGetterNames

public java.lang.String[] getAllBeanGetterNames()
Returns all public bean getters names.


inspectCtors

protected void inspectCtors()
Inspect class ctors and create ctors cache. Default implementation uses ReflectUtil.getAccessibleFields(Class) for retrieving only accessible fields.


getDefaultCtor

public java.lang.reflect.Constructor getDefaultCtor(boolean suppressSecurity)
Returns the default ctor or null if not found.


getCtor

public java.lang.reflect.Constructor getCtor(java.lang.Class[] args,
                                             boolean suppressSecurity)
Returns the constructor identified by arguments or null if not found.

Parameters:
args - ctor arguments
suppressSecurity - whether to look at non-public ones.

getCtor

public java.lang.reflect.Constructor getCtor(java.lang.Class[] args)
Returns the public ctor identified by arguments or null if not found.


getDefaultCtor

public java.lang.reflect.Constructor getDefaultCtor()
Returns the public default ctor or null if not found.


getCtorCount

public int getCtorCount(boolean suppressSecurity)
Returns the total number of constructors.


getCtorCount

public int getCtorCount()
Returns the total number of public constructors.


getAllCtors

public java.lang.reflect.Constructor[] getAllCtors(boolean suppressSecurity)
Returns an array of all ctors.


getAllCtors

public java.lang.reflect.Constructor[] getAllCtors()
Returns an array of all public ctors.



Copyright ©2008 Jodd Team