Interface IPropertyManager

All Superinterfaces:
IEventSource
All Known Implementing Classes:
PropertyManager, SimplePropertyManager

public interface IPropertyManager extends IEventSource
Define a property manager (PM). Implementations of this class connect an optional IPropertyDefinitionManager and an IConfiguration together to offer clients a single point of entry to set and get legal properties.

A property should be defined and registered (see IPropertyDefinition and IPropertyDefinitionManager). If an attempt is made to access (read or write) an undefined property, the attempt will:
- if writing, always succeed (i.e., the property will be reading even though it is not specifically defined in a PDM)
- if reading using an unsafe reader, fail: the reader will return null
- if reading using a safe reader, succeed or fail gracefully (e.g., return a default value if no value exists in the PM)

  • Field Details

    • DEPTH_BASIC

      static final int DEPTH_BASIC
      default depth: current PM, always stay in the property assigned namespace
      See Also:
    • DEPTH_MASTER

      static final int DEPTH_MASTER
      check the master PM (if any)
      See Also:
    • DEPTH_FULL

      static final int DEPTH_FULL
      check for a same-named property in parent namespace (if allowed)
      See Also:
  • Method Details

    • dispose

      void dispose()
      Release resources used by this manager.
    • getPropertyDefinitionManager

      IPropertyDefinitionManager getPropertyDefinitionManager()
      Get the PDM. Implementations may not provide a definition manager.
      Returns:
      the PDM, null if none
    • getConfiguration

      IConfiguration getConfiguration()
      Get the configuration object.
      Returns:
      the configuration object
    • getBoolean

      boolean getBoolean(String name)
      Safely retrieve a boolean property. On error, false is returned.
      Parameters:
      name - property name
      Returns:
      success indicator
    • getBoolean

      boolean getBoolean(String name, boolean defaultOnNull)
      Safely retrieve a boolean property.
      Parameters:
      name - the property name
      defaultOnNull -
      Returns:
      success indicator
    • getBooleanUnsafe

      Boolean getBooleanUnsafe(String name)
      Retrieve a boolean property. This method may throw or return null.
      Parameters:
      name - property name
      Returns:
    • setBoolean

      boolean setBoolean(String name, Boolean value)
      Set a boolean property.
      Parameters:
      name - property name
      value - property value; null to remove the property
      Returns:
      success indicator
    • setBoolean

      boolean setBoolean(String name, Boolean value, PropertyChangeObject co)
      Set a boolean property.
      Parameters:
      name - property name
      value - the property value; null to remove the property
      co - optional change object; if present, the property is recorded into that object instead of the PM, and changes are committed to the PM only after calling PropertyChangeObject.commit()
      Returns:
      success indicator
    • getInteger

      int getInteger(String name)
      Safely retrieve an integer property. On error, zero is returned.

      Selection properties are integer properties.

      Parameters:
      name - property name
      Returns:
      the property value
    • getInteger

      int getInteger(String name, int defaultOnNull)
      Safely retrieve an integer property.

      Selection properties are integer properties.

      Parameters:
      name - property name
      defaultOnNull -
      Returns:
      the property value
    • getIntegerUnsafe

      Integer getIntegerUnsafe(String name)
      Retrieve an integer property. This method may throw or return null.

      Selection properties are integer properties.

      Parameters:
      name - property name
      Returns:
      the property value
    • setInteger

      boolean setInteger(String name, Integer value)
      Set an integer property.

      Selection properties are integer properties.

      Parameters:
      name - property name
      value - property value; null to remove the property
      Returns:
      success indicator
    • setInteger

      boolean setInteger(String name, Integer value, PropertyChangeObject co)
      Set an integer property.

      Selection properties are integer properties.

      Parameters:
      name - property name
      value - property value; null to remove the property
      co - optional change object; if present, the property is recorded into that object instead of the PM, and changes are committed to the PM only after calling PropertyChangeObject.commit()
      Returns:
      success indicator
    • getString

      String getString(String name)
      Safely retrieve a string property. On error, the empty string is returned.
      Parameters:
      name - property name
      Returns:
      the property value
    • getString

      String getString(String name, String defaultOnNull)
      Safely retrieve a string property.
      Parameters:
      name - property name
      defaultOnNull -
      Returns:
      the property value
    • getStringUnsafe

      String getStringUnsafe(String name)
      Retrieve a string property.
      Parameters:
      name - property name
      Returns:
      the property value
    • setString

      boolean setString(String name, String value)
      Set a string property.
      Parameters:
      name - the property name; null to remove the property
      value - the property value
    • setString

      boolean setString(String name, String value, PropertyChangeObject co)
      Set a string property.
      Parameters:
      name - property name
      value - property value; null to remove the property
      co - optional change object; if present, the property is recorded into that object instead of the PM, and changes are committed to the PM only after calling PropertyChangeObject.commit()
      Returns:
      success indicator
    • getValue

      Object getValue(String name)
      Get a property value. Same as getValue(name, DEPTH_FULL, true, true).
      Parameters:
      name - property name
      Returns:
      the property value
    • getValue

      Object getValue(String name, int checkingDepth, boolean resolveDefault, boolean validateValue)
      Get a property value with optional control on depth search and property validation. By default, property getters do a maximum depth search and validate values.
      Parameters:
      name - property name
      checkingDepth - one of the DEPTH_* constant
      resolveDefault - if the property has a definition, but does not have a value, the default value (as defined) would be returned instead of potentially null
      validateValue - if the property has a definition, validate the property value against its definition
      Returns:
      the property value object (an Object, Boolean, Integer, or String) or null
    • setValue

      boolean setValue(String name, Object value)
      Set a property value.
      Parameters:
      name - property name
      value - property value; null to remove the property
      Returns:
      success indicator
    • setValue

      boolean setValue(String name, Object value, boolean validateValue, PropertyChangeObject co)
      Set a property value with optional control on property validation. By default, property setters validate values.
      Parameters:
      name - property name
      value - property value; null to remove the property
      validateValue - validate the property value against its definition
      co - (optional) if a change-object is provided, the changes will not be recorded to the manager, but added to the change-object itself; client can later commit all changes at once
      Returns:
      success indicator