maspack.properties
Class PropertyUtils

java.lang.Object
  extended by maspack.properties.PropertyUtils

public class PropertyUtils
extends java.lang.Object


Constructor Summary
PropertyUtils()
           
 
Method Summary
static java.lang.Object correctedValue(java.lang.Object value, java.lang.String err, StringHolder errMsg)
           
static CompositeProperty createInstance(PropertyInfo info, HasProperties host)
          Creates a default instance of a composite property.
static java.util.LinkedList<Property> createProperties(HasProperties host)
           
static boolean equalValues(java.lang.Object val1, java.lang.Object val2)
          Returns true if two objects are equal, including if they are both equal to null.
static java.lang.Class[] findCompositePropertySubclasses(java.lang.Class clazz)
           
static java.lang.Object illegalValue(java.lang.String err, StringHolder errMsg)
           
static boolean isConnectedToHierarchy(Property prop)
           
static void propagateRemoval(HasProperties host)
          Updates a node hierarchy to reflect the removal of a property host.
static PropertyMode propagateValue(HasProperties host, java.lang.String propName, java.lang.Object value, PropertyMode mode)
           
static boolean propertiesMatch(PropertyInfo info1, PropertyInfo info2)
           
static void setInheritedValue(PropertyInfo info, HasProperties host, java.lang.Object value)
          Sets the value of an inheritable property to an inherited value.
static PropertyMode setModeAndUpdate(HasProperties host, java.lang.String propName, PropertyMode oldMode, PropertyMode newMode)
           
static PropTreeCell updateAllInheritedProperties(HierarchyNode node)
          Updates the all inherited properties within a specified hierarchy node and all its descendants.
static void updateAndPropagateInheritedProperties(HasProperties host)
          Updates all inherited properties within a host, and then propagates the resulting values down throughout a node hierarchy.
static void updateCompositeProperty(CompositeProperty obj)
          Updates the hierarchy to reflect property changes in a particular composite property.
static void updateCompositeProperty(HasProperties host, java.lang.String propName, CompositeProperty oldObj, CompositeProperty newObj)
          Updates a composite property when it is introduced to a host.
static void updateInheritedProperties(CompositeProperty cprop, HasProperties host, java.lang.String cpropName)
          Updates the inherited properties within a specified CompositeProperty, in the context of a specified host and property name.
static void updateInheritedProperties(HierarchyNode node, PropTreeCell inherited)
          Updates the all inherited properties within a specified hierarchy node and all its descendants.
static java.lang.Object validValue(java.lang.Object value, StringHolder errMsg)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PropertyUtils

public PropertyUtils()
Method Detail

findCompositePropertySubclasses

public static java.lang.Class[] findCompositePropertySubclasses(java.lang.Class clazz)

setInheritedValue

public static void setInheritedValue(PropertyInfo info,
                                     HasProperties host,
                                     java.lang.Object value)
Sets the value of an inheritable property to an inherited value. The reason for using this routine instead of the property's set method is to prevent the property's mode from being automatically set to Explicit.

Parameters:
info - property information
host - host of the property
value - value to set it to

updateCompositeProperty

public static void updateCompositeProperty(HasProperties host,
                                           java.lang.String propName,
                                           CompositeProperty oldObj,
                                           CompositeProperty newObj)
Updates a composite property when it is introduced to a host. The host should call this routine whenever such an introduction occurs, which will typically occurs within the associated set routine. The routine will update the property and host information for the composite property. Also, if the host is associated with a node hierarchy, then (1) any inherited property values within the composite will be updated to reflect the explicit settings of ancestor nodes, and (2) any explicit property values will be propagated to descendant nodes.

Parameters:
host - host to which the composite property is being introduced
propName - name of the composite property within the host
oldObj - previous composite property, if any, or null otherwise
newObj - composite property which is being introduced

updateCompositeProperty

public static void updateCompositeProperty(CompositeProperty obj)
Updates the hierarchy to reflect property changes in a particular composite property. It is assumed that the composite property is already attached to the hierarchy, and that the changes have not been made through the property value accesssors (since otherwise they would already have been propagated). This routine will update and propagate all inherited values, as well as all explicit values.

Parameters:
obj - composite property object

updateInheritedProperties

public static void updateInheritedProperties(CompositeProperty cprop,
                                             HasProperties host,
                                             java.lang.String cpropName)
Updates the inherited properties within a specified CompositeProperty, in the context of a specified host and property name. The CompositeProperty does not need to be attached to the host in order to do the update. Instead, it will be temporarily attached and then detached.

Parameters:
cprop - CompositeProperty to update
host - Host for this composite property
cpropName - Name for the composite property within hosthost

updateAllInheritedProperties

public static PropTreeCell updateAllInheritedProperties(HierarchyNode node)
Updates the all inherited properties within a specified hierarchy node and all its descendants. This routine should be called whenever a node is added to the hierarchy.

If the node itself has inherited properties, then this routine returns a property tree giving the inherited values for thsese properties, which can be resused to set inherited values for another node with the same inherited properties and the same parent.

Parameters:
node - hierarchy node which needs updating
Returns:
property tree giving inherited property values for the node, or null if the node does not have inherited values.

updateInheritedProperties

public static void updateInheritedProperties(HierarchyNode node,
                                             PropTreeCell inherited)
Updates the all inherited properties within a specified hierarchy node and all its descendants. Inherited values for the node itself are supplied by a property tree which has been precomputed (most likely using a call to updateInheritedProperties(node)). It is the responsibility of the caller to ensure that this property tree is consistent with the properties exported by node.

Parameters:
node - hierarchy node which needs updating
inherited - property tree giving inherited values for node

propagateRemoval

public static void propagateRemoval(HasProperties host)
Updates a node hierarchy to reflect the removal of a property host. This involves resetting any inherited properties in the descendant nodes which depended on explicitly set properties in the removed host.

Parameters:
host - property host which has been removed

updateAndPropagateInheritedProperties

public static void updateAndPropagateInheritedProperties(HasProperties host)
Updates all inherited properties within a host, and then propagates the resulting values down throughout a node hierarchy.

Parameters:
host - property host which has been removed

createInstance

public static CompositeProperty createInstance(PropertyInfo info,
                                               HasProperties host)
Creates a default instance of a composite property.

Parameters:
info - information about the property
host - property host for this property
Returns:
new composite property instance

propertiesMatch

public static boolean propertiesMatch(PropertyInfo info1,
                                      PropertyInfo info2)

equalValues

public static boolean equalValues(java.lang.Object val1,
                                  java.lang.Object val2)
Returns true if two objects are equal, including if they are both equal to null.

Parameters:
val1 - first value to compare
val2 - second value to compare
Returns:
true if both values are null or if val1.equals(val2) == true

createProperties

public static java.util.LinkedList<Property> createProperties(HasProperties host)

setModeAndUpdate

public static PropertyMode setModeAndUpdate(HasProperties host,
                                            java.lang.String propName,
                                            PropertyMode oldMode,
                                            PropertyMode newMode)

isConnectedToHierarchy

public static boolean isConnectedToHierarchy(Property prop)

propagateValue

public static PropertyMode propagateValue(HasProperties host,
                                          java.lang.String propName,
                                          java.lang.Object value,
                                          PropertyMode mode)

validValue

public static java.lang.Object validValue(java.lang.Object value,
                                          StringHolder errMsg)

illegalValue

public static java.lang.Object illegalValue(java.lang.String err,
                                            StringHolder errMsg)

correctedValue

public static java.lang.Object correctedValue(java.lang.Object value,
                                              java.lang.String err,
                                              StringHolder errMsg)