public class

PropertyManager

extends EventSource
implements IPropertyManager
java.lang.Object
   ↳ com.pnfsoftware.jeb.util.events.EventSource
     ↳ com.pnfsoftware.jeb.core.properties.impl.PropertyManager

Class Overview

Standard implementation of a property manager (PM) using one or more definition managers (PDM) to define legal properties.

This implementation allows the chaining of property managers: if a configuration object does not contain a searched property, that property may be searched in a "master" property manager.

On a property change, this class notifies all listeners, including the property managers that have it registered as a master.

Summary

[Expand]
Inherited Constants
From interface com.pnfsoftware.jeb.core.properties.IPropertyManager
[Expand]
Inherited Fields
From class com.pnfsoftware.jeb.util.events.EventSource
Public Constructors
PropertyManager(IPropertyDefinitionManager pdm, IConfiguration config, IPropertyManager master)
Create a property manager, attach it to a PDM.
PropertyManager(IPropertyDefinitionManager pdm, IConfiguration config)
Create a property manager without a master PM.
PropertyManager(IPropertyDefinitionManager pdm, IPropertyManager master)
Create a configuration object-less property manager.
Public Methods
void dispose()
Release resources used by this manager.
boolean getBoolean(String name, boolean defaultOnNull)
Safely retrieve a boolean property.
boolean getBoolean(String name)
Safely retrieve a boolean property.
Boolean getBooleanUnsafe(String name)
Retrieve a boolean property.
IConfiguration getConfiguration()
Get the configuration object.
int getInteger(String name)
Safely retrieve an integer property.
int getInteger(String name, int defaultOnNull)
Safely retrieve an integer property.
Integer getIntegerUnsafe(String name)
Retrieve an integer property.
String getOwnerName()
IPropertyDefinitionManager getPropertyDefinitionManager()
Get the PDM.
String getString(String name)
Safely retrieve a string property.
String getString(String name, String defaultOnNull)
Safely retrieve a string property.
String getStringUnsafe(String name)
Retrieve a string property.
Object getValue(String name, int checkingDepth, boolean resolveDefault, boolean validateValue)
Get a property value with optional control on depth search and property validation.
Object getValue(String name)
Get a property value.
boolean setBoolean(String name, Boolean value)
Set a boolean property.
boolean setBoolean(String name, Boolean value, PropertyChangeObject co)
Set a boolean property.
boolean setInteger(String name, Integer value, PropertyChangeObject co)
Set an integer property.
boolean setInteger(String name, Integer value)
Set an integer property.
void setOwnerName(String ownerName)
boolean setString(String name, String value, PropertyChangeObject co)
Set a string property.
boolean setString(String name, String value)
Set a string property.
boolean setValue(String name, Object value, boolean validateValue, PropertyChangeObject co)
Set a property value with optional control on property validation.
boolean setValue(String name, Object value)
Set a property value.
String toString()
[Expand]
Inherited Methods
From class com.pnfsoftware.jeb.util.events.EventSource
From class java.lang.Object
From interface com.pnfsoftware.jeb.core.properties.IPropertyManager
From interface com.pnfsoftware.jeb.util.events.IEventSource

Public Constructors

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

public PropertyManager (IPropertyDefinitionManager pdm, IConfiguration config)

Create a property manager without a master PM.

Parameters
pdm optional PDM
config mandatory configuration object

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

Public Methods

public void dispose ()

Release resources used by this manager.

public boolean getBoolean (String name, boolean defaultOnNull)

Safely retrieve a boolean property.

Parameters
name the property name
Returns
  • success indicator

public boolean getBoolean (String name)

Safely retrieve a boolean property. On error, false is returned.

Parameters
name property name
Returns
  • success indicator

public Boolean getBooleanUnsafe (String name)

Retrieve a boolean property. This method may throw or return null.

Parameters
name property name

public IConfiguration getConfiguration ()

Get the configuration object.

Returns
  • the configuration object

public 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

public int getInteger (String name, int defaultOnNull)

Safely retrieve an integer property.

Selection properties are integer properties.

Parameters
name property name
Returns
  • the property value

public 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

public String getOwnerName ()

public IPropertyDefinitionManager getPropertyDefinitionManager ()

Get the PDM. Implementations may not provide a definition manager.

Returns
  • the PDM, null if none

public String getString (String name)

Safely retrieve a string property. On error, the empty string is returned.

Parameters
name property name
Returns
  • the property value

public String getString (String name, String defaultOnNull)

Safely retrieve a string property.

Parameters
name property name
Returns
  • the property value

public String getStringUnsafe (String name)

Retrieve a string property.

Parameters
name property name
Returns
  • the property value

public 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

public Object getValue (String name)

Get a property value. Same as getValue(name, DEPTH_FULL, true, true).

Parameters
name property name
Returns
  • the property value

public 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

public 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 commit()
Returns
  • success indicator

public 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 commit()
Returns
  • success indicator

public 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

public void setOwnerName (String ownerName)

public 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 commit()
Returns
  • success indicator

public boolean setString (String name, String value)

Set a string property.

Parameters
name the property name; null to remove the property
value the property value

public 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

public 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

public String toString ()