Last update: 2011-06-23

org.proteios
Class ClassDescriptor

java.lang.Object
  extended by org.proteios.ClassDescriptor

public class ClassDescriptor
extends Object

Through the ClassDescriptor you can find methods by defined attributes.

Author:
gregory
See Also:
AttributeDefinition

Constructor Summary
ClassDescriptor(Class<?> cls)
           
 
Method Summary
 List<AttributeDefinition> getAttributes()
          Currently supports Primitive, Nameable and Enumerated attributes
 List<AttributeDefinition> getAttributes(AttributeFilter filter)
           
 Class<?> getDescribedClass()
           
 Method getReadMethod(AttributeDefinition atr)
           
 Method getWriteMethod(AttributeDefinition atr)
           
 Object readValue(Object obj, AttributeDefinition attributeDefinition)
           
 List<AttributeDefinition> sort(List<AttributeDefinition> attributes, List<String> order)
          Returns a filtered list of attributes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClassDescriptor

public ClassDescriptor(Class<?> cls)
Parameters:
cls - to describe
Method Detail

getReadMethod

public Method getReadMethod(AttributeDefinition atr)
                     throws SecurityException,
                            NoSuchMethodException
Throws:
SecurityException
NoSuchMethodException

getWriteMethod

public Method getWriteMethod(AttributeDefinition atr)
                      throws SecurityException,
                             NoSuchMethodException
Throws:
SecurityException
NoSuchMethodException

getAttributes

public List<AttributeDefinition> getAttributes(AttributeFilter filter)
Parameters:
filter - to apply
Returns:
a list of attributes filtered through the above filter

sort

public List<AttributeDefinition> sort(List<AttributeDefinition> attributes,
                                      List<String> order)
Returns a filtered list of attributes.

Parameters:
attributes - List of attribute definitions to be sorted.
order - List of column key strings in desired sort order.
Returns:
List Sorted list of attribute definitions.

getAttributes

public List<AttributeDefinition> getAttributes()
Currently supports Primitive, Nameable and Enumerated attributes

Returns:
list of readable attributes, those with 'get' or 'is' prefixes, or null if none are found.

getDescribedClass

public Class<?> getDescribedClass()

readValue

public Object readValue(Object obj,
                        AttributeDefinition attributeDefinition)
Parameters:
obj - to read the attribute of
attributeDefinition - describing the attribute
Returns:
the value of that attribute or null

Last update: 2011-06-23