org.apache.hivemind.util
Class PropertyUtils

java.lang.Object
  extended by org.apache.hivemind.util.PropertyUtils

public class PropertyUtils
extends java.lang.Object

A collection of static methods used to perform property-level access on arbitrary objects.

Author:
Howard Lewis Ship

Method Summary
static void clearCache()
          Clears all cached information.
static void configureProperties(java.lang.Object target, java.lang.String initializer)
          Initializes the properties of an object from a string.
static PropertyAdaptor getPropertyAdaptor(java.lang.Object target, java.lang.String propertyName)
          Returns the PropertyAdaptor for the given target object and property name.
static java.lang.Class getPropertyType(java.lang.Object target, java.lang.String propertyName)
          Returns the type of the named property.
static java.util.List getReadableProperties(java.lang.Object target)
          Returns an unordered List of the names of all readable properties of the target.
static java.util.List getWriteableProperties(java.lang.Object target)
          Returns an unordered List of the names of all writable properties of the target.
static boolean isReadable(java.lang.Object target, java.lang.String propertyName)
           
static boolean isWritable(java.lang.Object target, java.lang.String propertyName)
          Returns true of the instance contains a writable property of the given type.
static java.lang.Object read(java.lang.Object target, java.lang.String propertyName)
          Updates the property of the target object.
static void smartWrite(java.lang.Object target, java.lang.String propertyName, java.lang.String value)
          An improved version of write(Object, String, Object) where the value starts as a string and is converted to the correct property type before being assigned.
static void write(java.lang.Object target, java.lang.String propertyName, java.lang.Object value)
          Updates the property of the target object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

write

public static void write(java.lang.Object target,
                         java.lang.String propertyName,
                         java.lang.Object value)
Updates the property of the target object.

Parameters:
target - the object to update
propertyName - the name of the property to be updated
value - the value to be stored into the target object property

smartWrite

public static void smartWrite(java.lang.Object target,
                              java.lang.String propertyName,
                              java.lang.String value)
An improved version of write(Object, String, Object) where the value starts as a string and is converted to the correct property type before being assigned.

Since:
1.1

configureProperties

public static void configureProperties(java.lang.Object target,
                                       java.lang.String initializer)
Initializes the properties of an object from a string. The string is a comma-seperated sequence of property names and values. Property names are seperated from values be an equals sign. Spaces before and after the property names are trimmed. For boolean properties, the equals sign and value may be omitted (a value of true is assumed), or the property name may be prefixed with an exclamation point to indicated false value. Example: validate,maxLength=10,displayName=User Id.

Parameters:
target - the object to be configured
initializer - the string encoding the properties and values to be configured in the target object
Since:
1.1

isWritable

public static boolean isWritable(java.lang.Object target,
                                 java.lang.String propertyName)
Returns true of the instance contains a writable property of the given type.

Parameters:
target - the object to inspect
propertyName - the name of the property to check

isReadable

public static boolean isReadable(java.lang.Object target,
                                 java.lang.String propertyName)

read

public static java.lang.Object read(java.lang.Object target,
                                    java.lang.String propertyName)
Updates the property of the target object.

Parameters:
target - the object to update
propertyName - the name of a property toread

getPropertyType

public static java.lang.Class getPropertyType(java.lang.Object target,
                                              java.lang.String propertyName)
Returns the type of the named property.

Parameters:
target - the object to examine
propertyName - the name of the property to check

getPropertyAdaptor

public static PropertyAdaptor getPropertyAdaptor(java.lang.Object target,
                                                 java.lang.String propertyName)
Returns the PropertyAdaptor for the given target object and property name.

Throws:
ApplicationRuntimeException - if the property does not exist.

getReadableProperties

public static java.util.List getReadableProperties(java.lang.Object target)
Returns an unordered List of the names of all readable properties of the target.


getWriteableProperties

public static java.util.List getWriteableProperties(java.lang.Object target)
Returns an unordered List of the names of all writable properties of the target.


clearCache

public static void clearCache()
Clears all cached information. Invokes Introspector.flushCaches().



Copyright © 2003-2007 Apache Software Foundation. All Rights Reserved.