Class PropertyManager

java.lang.Object
com.pnfsoftware.jeb.util.events.EventSource
com.pnfsoftware.jeb.core.properties.impl.PropertyManager
All Implemented Interfaces:
IPropertyManager, IEventSource

public class PropertyManager extends EventSource implements IPropertyManager
Standard implementation of IPropertyManager using one or more property definition managers (PDMs) to define legal properties.

This implementation supports chaining property managers so lookups can fall back to a master manager when a configuration object does not contain a value.

  • Constructor Details

    • PropertyManager

      public PropertyManager(IPropertyDefinitionManager pdm, IConfiguration config, IPropertyManager master)
      Create a property manager, attach it to a PDM.

      If both a configuration object and a master PM are specified, the configuration object is searched first.

      Parameters:
      pdm - optional PDM
      config - optional, in which case a master PM should be specified
      master - optional, in which case a configuration object should be specified
    • PropertyManager

      public PropertyManager(IPropertyDefinitionManager pdm, IConfiguration config)
      Create a property manager without a master PM.
      Parameters:
      pdm - optional PDM
      config - mandatory configuration object
    • PropertyManager

      public PropertyManager(IPropertyDefinitionManager pdm, IPropertyManager master)
      Create a configuration object-less property manager. In that case, the master PM is mandatory and will be used as a proxy when setting or getting properties.
      Parameters:
      pdm - optional PDM
      master - mandatory master PM
  • Method Details

    • dispose

      public void dispose()
      Description copied from interface: IPropertyManager
      Release resources used by this manager.
      Specified by:
      dispose in interface IPropertyManager
    • getPropertyDefinitionManager

      public IPropertyDefinitionManager getPropertyDefinitionManager()
      Description copied from interface: IPropertyManager
      Get the PDM. Implementations may not provide a definition manager.
      Specified by:
      getPropertyDefinitionManager in interface IPropertyManager
      Returns:
      the PDM, null if none
    • getConfiguration

      public IConfiguration getConfiguration()
      Description copied from interface: IPropertyManager
      Get the configuration object.
      Specified by:
      getConfiguration in interface IPropertyManager
      Returns:
      the configuration object
    • getValue

      public Object getValue(String name)
      Description copied from interface: IPropertyManager
      Get a property value. Same as getValue(name, DEPTH_FULL, true, true).
      Specified by:
      getValue in interface IPropertyManager
      Parameters:
      name - property name
      Returns:
      the property value
    • getValue

      public Object getValue(String name, int checkingDepth, boolean resolveDefault, boolean validateValue)
      Description copied from interface: IPropertyManager
      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.
      Specified by:
      getValue in interface IPropertyManager
      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

      public boolean setValue(String name, Object value)
      Description copied from interface: IPropertyManager
      Set a property value.
      Specified by:
      setValue in interface IPropertyManager
      Parameters:
      name - property name
      value - property value; null to remove the property
      Returns:
      success indicator
    • setValue

      public boolean setValue(String name, Object value, boolean validateValue, PropertyChangeObject co)
      Description copied from interface: IPropertyManager
      Set a property value with optional control on property validation. By default, property setters validate values.
      Specified by:
      setValue in interface IPropertyManager
      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
    • getBoolean

      public boolean getBoolean(String name)
      Description copied from interface: IPropertyManager
      Safely retrieve a boolean property. On error, false is returned.
      Specified by:
      getBoolean in interface IPropertyManager
      Parameters:
      name - property name
      Returns:
      success indicator
    • getBoolean

      public boolean getBoolean(String name, boolean defaultOnNull)
      Description copied from interface: IPropertyManager
      Safely retrieve a boolean property.
      Specified by:
      getBoolean in interface IPropertyManager
      Parameters:
      name - the property name
      defaultOnNull -
      Returns:
      success indicator
    • getBooleanUnsafe

      public Boolean getBooleanUnsafe(String name)
      Description copied from interface: IPropertyManager
      Retrieve a boolean property. This method may throw or return null.
      Specified by:
      getBooleanUnsafe in interface IPropertyManager
      Parameters:
      name - property name
      Returns:
      the property value, or null if it is absent or invalid
    • setBoolean

      public boolean setBoolean(String name, Boolean value)
      Description copied from interface: IPropertyManager
      Set a boolean property.
      Specified by:
      setBoolean in interface IPropertyManager
      Parameters:
      name - property name
      value - property value; null to remove the property
      Returns:
      success indicator
    • setBoolean

      public boolean setBoolean(String name, Boolean value, PropertyChangeObject co)
      Description copied from interface: IPropertyManager
      Set a boolean property.
      Specified by:
      setBoolean in interface IPropertyManager
      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

      public int getInteger(String name)
      Description copied from interface: IPropertyManager
      Safely retrieve an integer property. On error, zero is returned.

      Selection properties are integer properties.

      Specified by:
      getInteger in interface IPropertyManager
      Parameters:
      name - property name
      Returns:
      the property value
    • getInteger

      public int getInteger(String name, int defaultOnNull)
      Description copied from interface: IPropertyManager
      Safely retrieve an integer property.

      Selection properties are integer properties.

      Specified by:
      getInteger in interface IPropertyManager
      Parameters:
      name - property name
      defaultOnNull -
      Returns:
      the property value
    • getIntegerUnsafe

      public Integer getIntegerUnsafe(String name)
      Description copied from interface: IPropertyManager
      Retrieve an integer property. This method may throw or return null.

      Selection properties are integer properties.

      Specified by:
      getIntegerUnsafe in interface IPropertyManager
      Parameters:
      name - property name
      Returns:
      the property value
    • setInteger

      public boolean setInteger(String name, Integer value)
      Description copied from interface: IPropertyManager
      Set an integer property.

      Selection properties are integer properties.

      Specified by:
      setInteger in interface IPropertyManager
      Parameters:
      name - property name
      value - property value; null to remove the property
      Returns:
      success indicator
    • setInteger

      public boolean setInteger(String name, Integer value, PropertyChangeObject co)
      Description copied from interface: IPropertyManager
      Set an integer property.

      Selection properties are integer properties.

      Specified by:
      setInteger in interface IPropertyManager
      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

      public String getString(String name)
      Description copied from interface: IPropertyManager
      Safely retrieve a string property. On error, the empty string is returned.
      Specified by:
      getString in interface IPropertyManager
      Parameters:
      name - property name
      Returns:
      the property value
    • getString

      public String getString(String name, String defaultOnNull)
      Description copied from interface: IPropertyManager
      Safely retrieve a string property.
      Specified by:
      getString in interface IPropertyManager
      Parameters:
      name - property name
      defaultOnNull -
      Returns:
      the property value
    • getStringUnsafe

      public String getStringUnsafe(String name)
      Description copied from interface: IPropertyManager
      Retrieve a string property.
      Specified by:
      getStringUnsafe in interface IPropertyManager
      Parameters:
      name - property name
      Returns:
      the property value
    • setString

      public boolean setString(String name, String value)
      Description copied from interface: IPropertyManager
      Set a string property.
      Specified by:
      setString in interface IPropertyManager
      Parameters:
      name - the property name; null to remove the property
      value - the property value
    • setString

      public boolean setString(String name, String value, PropertyChangeObject co)
      Description copied from interface: IPropertyManager
      Set a string property.
      Specified by:
      setString in interface IPropertyManager
      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
    • setOwnerName

      public void setOwnerName(String ownerName)
      Set an optional display name used by debugging output.
      Parameters:
      ownerName - display name for this property manager
    • getOwnerName

      public String getOwnerName()
      Get the optional display name used by debugging output.
      Returns:
      the owner name
    • toString

      public String toString()
      Overrides:
      toString in class Object