com.mortbay.Util
Class PropertyEnumeration

java.lang.Object
  |
  +--com.mortbay.Util.PropertyEnumeration

public class PropertyEnumeration
extends java.lang.Object
implements java.util.Enumeration

Provide an Enumeration over a Classes Properties Optionally, this class allows the user to enumerate over a Classes public fields. Utility methods allow properties or public fields to be set transparently


Constructor Summary
PropertyEnumeration(java.lang.Class class_, boolean settable, boolean useFields)
          Constructor.
 
Method Summary
static java.lang.Object get(java.lang.Object obj, java.lang.String name)
          utility method for transparently getting a property or field
 java.lang.Class getType()
          Get the type of the current property/field
 java.lang.Class getType(java.lang.String name)
          Get the type of the named property/field
 boolean hasMoreElements()
           
 java.lang.Object nextElement()
           
static boolean set(java.lang.Object obj, java.lang.String name, java.lang.Object value)
          utility method for transparently setting a property or field
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PropertyEnumeration

public PropertyEnumeration(java.lang.Class class_,
                           boolean settable,
                           boolean useFields)
Constructor.
Parameters:
class_ - The Class to Enumerate over
settable - Include only properties that are settable
useFields - Whether to include public fields or not.
Method Detail

hasMoreElements

public boolean hasMoreElements()
Specified by:
hasMoreElements in interface java.util.Enumeration

nextElement

public java.lang.Object nextElement()
Specified by:
nextElement in interface java.util.Enumeration

getType

public java.lang.Class getType()
Get the type of the current property/field

getType

public java.lang.Class getType(java.lang.String name)
Get the type of the named property/field

set

public static boolean set(java.lang.Object obj,
                          java.lang.String name,
                          java.lang.Object value)
                   throws java.lang.IllegalArgumentException,
                          java.lang.reflect.InvocationTargetException,
                          java.lang.IllegalAccessException
utility method for transparently setting a property or field
Parameters:
obj - The object to set the value on
name - The name of the property or field
value - The value to set
Returns:
true if it found the property/field and set it
Throws:
java.lang.IllegalArgumentException - If the value is of the wrong type
java.lang.reflect.InvocationTargetException - If the set throws an Exception
java.lang.IllegalAccessException - If the field is not public

get

public static java.lang.Object get(java.lang.Object obj,
                                   java.lang.String name)
                            throws java.lang.reflect.InvocationTargetException,
                                   java.lang.IllegalAccessException
utility method for transparently getting a property or field
Parameters:
obj - The object to set the value on
name - The name of the property or field
Returns:
The value of the property, or null if an error (or it was null!)
Throws:
java.lang.reflect.InvocationTargetException - If the set throws an Exception
java.lang.IllegalAccessException - If the field is not public