net.sf.navel.beans
Class PropertyValues

java.lang.Object
  extended by net.sf.navel.beans.PropertyValues
All Implemented Interfaces:
java.io.Serializable

public class PropertyValues
extends java.lang.Object
implements java.io.Serializable

The storage class that supports the data bucket behavior for all simple properties of a JavaBean. Expose an interface that allows for programmatic manipulation of the bean contents, safely. That is putting new values by property names are checked to ensure the do not violate the properties the bean exposes through its compile time interfaces.

Author:
cmdln
See Also:
Serialized Form

Method Summary
 void clear()
          Clears all of the internal storage entries.
 boolean containsKey(java.lang.String dotExpression)
          Figure out if the supplied expression refers to a valid entry in the underlying storage.
 java.util.Map<java.lang.String,java.lang.Object> copyValues(boolean flatten)
          Return a copy of the internal values, generally safe to manipulate.
 boolean equals(java.lang.Object obj)
           
 java.lang.Object get(java.lang.String dotExpression)
          Evaluates the supplied expression and returns the corresponding value, if there is one.
 ProxyDescriptor getProxyDescriptor()
           
 int hashCode()
           
 boolean isImmutable()
           
 void put(java.lang.String dotExpression, java.lang.Object value)
          Checks that the supplied expression is valid for the JavaBean's compile time property set, that the type matches or can be coerced, and adds the supplied value to internal storage.
 void putAll(java.util.Map<java.lang.String,java.lang.Object> newValues)
          Forwards to the internal map, after resolving nested and list properties and validating the new map.
 java.lang.Object remove(java.lang.String dotExpression)
          Evaluates the supplied expression and removes the corresponding value, if there is one.
static void resetToStringTemplate()
          Restore the default format template for toString().
 java.lang.Object resolve(java.lang.String dotExpression)
           
 java.util.Map<java.lang.String,java.lang.Object> resolveDelegates(boolean flatten)
          Interrogate the registered PropertyDelegate instances and invoke their PropertyDelegate.get(PropertyValues, String) method to generate a Map of synthetic values.
static void setToStringTemplate(java.lang.String toStringTemplate)
          Allows callers to specify their own template for use with String.format(String, Object...) which excepts one argument.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

setToStringTemplate

public static void setToStringTemplate(java.lang.String toStringTemplate)
Allows callers to specify their own template for use with String.format(String, Object...) which excepts one argument.
  1. Map.toString() result

Parameters:
toStringTemplate - Custom format template.

resetToStringTemplate

public static void resetToStringTemplate()
Restore the default format template for toString().


getProxyDescriptor

public ProxyDescriptor getProxyDescriptor()

copyValues

public java.util.Map<java.lang.String,java.lang.Object> copyValues(boolean flatten)
Return a copy of the internal values, generally safe to manipulate. Does not perform a deep copy, however, so be careful of de-referencing nested values on elements of the copy.

Parameters:
flatten - If true, the nested beans will be flattened, calculating new keys in the flat return map that are valid dot-notation expressions representing where the original values where in the normalized storage graph.
Returns:
A shallow copy of the internal values of this instance.

resolveDelegates

public java.util.Map<java.lang.String,java.lang.Object> resolveDelegates(boolean flatten)
Interrogate the registered PropertyDelegate instances and invoke their PropertyDelegate.get(PropertyValues, String) method to generate a Map of synthetic values.

Parameters:
flatten - Whether the delegates on any nested proxies should also be resolved and flattened into the output Map.
Returns:
A Map of just the returns of PropertyDelegate.get(PropertyValues, String) keyed by the properties to which the respective delegates are registered.

put

public void put(java.lang.String dotExpression,
                java.lang.Object value)
Checks that the supplied expression is valid for the JavaBean's compile time property set, that the type matches or can be coerced, and adds the supplied value to internal storage.

Parameters:
dotExpression - A property in the set of properties introspected when the associated Proxy and JavaBeanHandler were created by the ProxyFactory.
value - Checked for type safety against the appropriate property.

putAll

public void putAll(java.util.Map<java.lang.String,java.lang.Object> newValues)
Forwards to the internal map, after resolving nested and list properties and validating the new map. Will overwrite values at the same keys in the internal storage.


get

public java.lang.Object get(java.lang.String dotExpression)
Evaluates the supplied expression and returns the corresponding value, if there is one.

Parameters:
dotExpression - Property names chained with the dot (.) character, may also use the bracket characters ([]) with an index value to de-reference lists and arrays.
Returns:
Null if there is no corresponding value, otherwise the value indicated by the expression.
Throws:
InvalidExpressionException - If the dot expression doesn't parse with the given bean interfaces.

resolve

public java.lang.Object resolve(java.lang.String dotExpression)

containsKey

public boolean containsKey(java.lang.String dotExpression)
Figure out if the supplied expression refers to a valid entry in the underlying storage.

Parameters:
dotExpression - Property names chained with the dot (.) character, may also use the bracket characters ([]) with an index value to de-reference lists and arrays.
Returns:
True if an entry exists, even if its value is null, false if there is no entry at all.
Throws:
InvalidExpressionException - If the dot expression doesn't parse with the given bean interfaces.

remove

public java.lang.Object remove(java.lang.String dotExpression)
Evaluates the supplied expression and removes the corresponding value, if there is one.

Parameters:
dotExpression - Property names chained with the dot (.) character, may also use the bracket characters ([]) with an index value to de-reference lists and arrays.
Returns:
Null if nothing was removed, otherwise the value indicated by the expression.
Throws:
InvalidExpressionException - If the dot expression doesn't parse with the given bean interfaces.

clear

public void clear()
Clears all of the internal storage entries.


isImmutable

public boolean isImmutable()
Returns:
Whether calls that would affect the state of this instance will throw unchecked exceptions.

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object
See Also:
Object.equals(java.lang.Object)

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object
See Also:
Object.hashCode()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
See Also:
Object.toString()