net.sf.navel.beans
Class ProxyManipulator

java.lang.Object
  extended by net.sf.navel.beans.ProxyManipulator

public class ProxyManipulator
extends java.lang.Object

Public interface for doing reflection-like dynamic programming of the underlying values of a Navel backed JavaBean.

Author:
cmdln

Method Summary
static void clear(java.lang.Object bean)
          Allows clear of a Navel bean's internal storage.
static boolean clear(java.lang.Object bean, java.lang.String propertyName)
          Useful for removing values from the underlying Map, such as when trying to ignore certain property values like for persistence applications.
static java.util.Map<java.lang.String,java.lang.Object> copyAll(java.lang.Object bean)
          Overload that assumes false for flattening of the internal values.
static java.util.Map<java.lang.String,java.lang.Object> copyAll(java.lang.Object bean, boolean flatten)
          Allows a copy of the bean's internal state to be retrieve by an arbitrary caller.
static java.lang.Object get(java.lang.Object bean, java.lang.String propertyName)
          Allows dynamic programming of the internal storage of a JavaBeanHandler, useful for translation between Navel beans and other kinds of objects or declarative interrogation of the state of the bean.
static boolean isImmutable(java.lang.Object bean)
          Simple interrogates the underlying PropertyValues object to see if it is immutable.
static boolean isSet(java.lang.Object bean, java.lang.String propertyName)
          Check to see if the specified property has an entry, even one with a null value, in the storage map.
static void put(java.lang.Object bean, java.lang.String propertyName, java.lang.Object propertyValue)
          Allows for dynamic programming of a JavaBean's properties.
static void putAll(java.lang.Object bean, java.util.Map<java.lang.String,java.lang.Object> values)
          This allows direct access to the underlying Map storage to put multiple values all at once.
static java.lang.Object resolve(java.lang.Object bean, java.lang.String propertyExpression)
           
static java.util.Map<java.lang.String,java.lang.Object> resolveAll(java.lang.Object bean)
          Overload that assumes false for flattening out nested proxies.
static java.util.Map<java.lang.String,java.lang.Object> resolveAll(java.lang.Object bean, boolean resolveNested)
          Utility to resolve the values for delegates properties since copyAll(Object) ignores any attached PropertyDelegate instances.
static java.lang.Class<?> typeOf(java.lang.Class<?> beanType, java.lang.String dotExpression)
          Utility method for digging out a target type based on an expression.
static boolean valuesEqual(java.lang.Object oneBean, java.lang.Object anotherBean)
          Compares just the internal storage of two Navel beans for equivalence.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

get

public static java.lang.Object get(java.lang.Object bean,
                                   java.lang.String propertyName)
Allows dynamic programming of the internal storage of a JavaBeanHandler, useful for translation between Navel beans and other kinds of objects or declarative interrogation of the state of the bean. WARNING: This will bypass any attached PropertyDelegate instances!

Parameters:
bean - Object to query, must be a Navel bean.
propertyName - Property to get, may be a nested property using the dot notation. Also may be an indexed property.
Returns:
Whatever value is at the indicated property.

copyAll

public static java.util.Map<java.lang.String,java.lang.Object> copyAll(java.lang.Object bean)
Overload that assumes false for flattening of the internal values. WARNING: This will bypass any attached PropertyDelegate instances!

Returns:

copyAll

public static java.util.Map<java.lang.String,java.lang.Object> copyAll(java.lang.Object bean,
                                                                       boolean flatten)
Allows a copy of the bean's internal state to be retrieve by an arbitrary caller. WARNING: This will bypass any attached PropertyDelegate instances!

Parameters:
bean - Must be navel bean.
flatten - If true, then the nested proxies will be flattened into the output.
Returns:
A shallow copy of the bean's internal state.

put

public static void put(java.lang.Object bean,
                       java.lang.String propertyName,
                       java.lang.Object propertyValue)
Allows for dynamic programming of a JavaBean's properties. If the bean argument is a Navel bean, it will use the standard validation to ensure correct names and types. If it is a Navel bean, it will also use the same logic as the ProxyFactory to initialize uninitialized nested properties of those are interfaces so can be properly proxied. WARNING: This will bypass any attached PropertyDelegate instances!

Parameters:
bean - Target whose property, simply or nested, to set.
propertyName - Property to set, may be a nested property using the dot notation. Also may be an indexed property.
propertyValue - Value to set at the specified name.

putAll

public static void putAll(java.lang.Object bean,
                          java.util.Map<java.lang.String,java.lang.Object> values)
This allows direct access to the underlying Map storage to put multiple values all at once. Unline BeanManipulator.populate(), this method does not call the actually mutators but it does strictly validate the supplied Map to ensure it is consistent with the JavaBean's interfaces. WARNING: This will bypass any attached PropertyDelegate instances!

Parameters:
bean - Target bean to apply the Map argument, must be a Navel bean. To apply a Map to a plain, old JavaBean, use BeanManipulator.
values - Values to insert into the Navel bean's internal storage, will be validated with the same rules used by the ProxyFactory during construction.

isSet

public static boolean isSet(java.lang.Object bean,
                            java.lang.String propertyName)
Check to see if the specified property has an entry, even one with a null value, in the storage map. WARNING: This will bypass any attached PropertyDelegate instances!

Parameters:
bean - Object to check, must be a Navel bean.
propertyName - Property to check, must be valid for the Navel bean.
Returns:
Whether the internal storage has an entry for this property.

clear

public static boolean clear(java.lang.Object bean,
                            java.lang.String propertyName)
Useful for removing values from the underlying Map, such as when trying to ignore certain property values like for persistence applications.

Parameters:
bean - Bean to clear.
propertyName - Name of the property to clear.
Returns:
Whether the state of the bean was affected.

clear

public static void clear(java.lang.Object bean)
Allows clear of a Navel bean's internal storage.

Parameters:
bean - Must be a Navel bean.

resolve

public static java.lang.Object resolve(java.lang.Object bean,
                                       java.lang.String propertyExpression)

resolveAll

public static java.util.Map<java.lang.String,java.lang.Object> resolveAll(java.lang.Object bean)
Overload that assumes false for flattening out nested proxies.

Parameters:
bean - Proxy to resolve.
Returns:
A Map containing the results of calling PropertyDelegate.get(PropertyValues, String) for all the registered instances, empty if no delegates are registered.

resolveAll

public static java.util.Map<java.lang.String,java.lang.Object> resolveAll(java.lang.Object bean,
                                                                          boolean resolveNested)
Utility to resolve the values for delegates properties since copyAll(Object) ignores any attached PropertyDelegate instances. This methid does not currently resolve nested beans.

Parameters:
bean - Proxy to resolve.
resolveNeste - If true, the nested proxies will also be resolved and flattened into the output.
Returns:
A Map containing the results of calling PropertyDelegate.get(PropertyValues, String) for all the registered instances, empty if no delegates are registered.

typeOf

public static java.lang.Class<?> typeOf(java.lang.Class<?> beanType,
                                        java.lang.String dotExpression)
Utility method for digging out a target type based on an expression.

Parameters:
beanType - Ancestor type from which the property expression descends.
dotExpression - A dot-notation property expression that indicates some target property of interest.
Returns:
The type of the property specified by the dotExpression argument.

valuesEqual

public static boolean valuesEqual(java.lang.Object oneBean,
                                  java.lang.Object anotherBean)
Compares just the internal storage of two Navel beans for equivalence. This is similar to the original equals semantic in Navel2.

Parameters:
oneBean - One bean to compare.
anotherBean - The other bean to compare.
Returns:
Whether the storage of the two beans is equivalent.

isImmutable

public static boolean isImmutable(java.lang.Object bean)
Simple interrogates the underlying PropertyValues object to see if it is immutable.

Parameters:
bean - Must be a Navel bean.
Returns:
True only if the Navel been is immutable.