freemarker.ext.beans2
Class ObjectFeatures<T>

java.lang.Object
  extended by freemarker.ext.beans2.ObjectFeatures<T>
All Implemented Interfaces:
Features<T>

public class ObjectFeatures<T>
extends java.lang.Object
implements Features<T>

Determine an object's features for a particular class. Object features include a class's properties, as well as all methods and fields -- static or non-static. Methods are pre-sorted based on arguments and class hierarchy to allow fast resolution of overloaded methods.

Since:
1.9
Version:
$Id: ObjectFeatures.java 1067 2011-06-06 10:55:28Z run2000 $
Author:
Nicholas Cull

Constructor Summary
ObjectFeatures(java.lang.Class<T> clazz)
          Create object features for a given class.
 
Method Summary
 T[] getEnumValues()
          Get an array of all enumeration values for the enum class.
 java.lang.reflect.Field getField(java.lang.String name)
          Get a Field object for the given name.
 java.util.List<java.lang.reflect.Method> getMethods(java.lang.String name)
          Get a list of all methods for the given name.
 java.beans.PropertyDescriptor getProperty(java.lang.String name)
          Get a PropertyDescriptor object for the given name.
 java.lang.String toString()
          Returns a string representation of the object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ObjectFeatures

public ObjectFeatures(java.lang.Class<T> clazz)
               throws java.beans.IntrospectionException
Create object features for a given class. Pre-cache any property, method, and field information at construction time to allow fast lookup of the class's features.

Parameters:
clazz - the class to be introspected
Throws:
java.beans.IntrospectionException - there was a problem introspecting the given class
Method Detail

getMethods

public java.util.List<java.lang.reflect.Method> getMethods(java.lang.String name)
Description copied from interface: Features
Get a list of all methods for the given name. There may be several overloaded methods for a given name.

Specified by:
getMethods in interface Features<T>
Parameters:
name - the name of the method to be retrieved
Returns:
a List of Method objects for the given name

getProperty

public java.beans.PropertyDescriptor getProperty(java.lang.String name)
Description copied from interface: Features
Get a PropertyDescriptor object for the given name. Property names are unique for a given class, so no overloading is required.

Specified by:
getProperty in interface Features<T>
Parameters:
name - the name of the property to be retrieved
Returns:
a PropertyDescriptor for the given name

getField

public java.lang.reflect.Field getField(java.lang.String name)
Description copied from interface: Features
Get a Field object for the given name. Field names are unique for a given class, so no overloading is required.

Specified by:
getField in interface Features<T>
Parameters:
name - the name of the field to be retrieved
Returns:
a Field object for the given name

getEnumValues

public T[] getEnumValues()
Description copied from interface: Features
Get an array of all enumeration values for the enum class.

Specified by:
getEnumValues in interface Features<T>
Returns:
an array of all enumerated values for this class, or null if the class is not an enum

toString

public java.lang.String toString()
Returns a string representation of the object.

Overrides:
toString in class java.lang.Object
Returns:
a string representation of the object.