Class PropertyManager
java.lang.Object
com.pnfsoftware.jeb.util.events.EventSource
com.pnfsoftware.jeb.core.properties.impl.PropertyManager
- All Implemented Interfaces:
IPropertyManager
,IEventSource
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.
-
Field Summary
Fields inherited from class com.pnfsoftware.jeb.util.events.EventSource
onEventCallCount
Fields inherited from interface com.pnfsoftware.jeb.core.properties.IPropertyManager
DEPTH_BASIC, DEPTH_FULL, DEPTH_MASTER
-
Constructor Summary
ConstructorDescriptionPropertyManager
(IPropertyDefinitionManager pdm, IConfiguration config) Create a property manager without a master PM.PropertyManager
(IPropertyDefinitionManager pdm, IConfiguration config, IPropertyManager master) Create a property manager, attach it to a PDM.PropertyManager
(IPropertyDefinitionManager pdm, IPropertyManager master) Create a configuration object-less property manager. -
Method Summary
Modifier and TypeMethodDescriptionvoid
dispose()
Release resources used by this manager.boolean
getBoolean
(String name) Safely retrieve a boolean property.boolean
getBoolean
(String name, boolean defaultOnNull) Safely retrieve a boolean property.getBooleanUnsafe
(String name) Retrieve a boolean property.Get the configuration object.int
getInteger
(String name) Safely retrieve an integer property.int
getInteger
(String name, int defaultOnNull) Safely retrieve an integer property.getIntegerUnsafe
(String name) Retrieve an integer property.Get the PDM.Safely retrieve a string property.Safely retrieve a string property.getStringUnsafe
(String name) Retrieve a string property.Get a property value.Get a property value with optional control on depth search and property validation.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) Set an integer property.boolean
setInteger
(String name, Integer value, PropertyChangeObject co) Set an integer property.void
setOwnerName
(String ownerName) boolean
Set a string property.boolean
setString
(String name, String value, PropertyChangeObject co) Set a string property.boolean
Set a property value.boolean
setValue
(String name, Object value, boolean validateValue, PropertyChangeObject co) Set a property value with optional control on property validation.toString()
Methods inherited from class com.pnfsoftware.jeb.util.events.EventSource
addListener, countListeners, getListeners, getParentSource, insertListener, notifyListeners, notifyListeners, notifyListeners, relay, removeListener, setParentSource
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.pnfsoftware.jeb.util.events.IEventSource
addListener, countListeners, getListeners, getParentSource, insertListener, notifyListeners, removeListener, setParentSource
-
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 PDMconfig
- optional, in which case a master PM should be specifiedmaster
- optional, in which case a configuration object should be specified
-
PropertyManager
Create a property manager without a master PM.- Parameters:
pdm
- optional PDMconfig
- mandatory configuration object
-
PropertyManager
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 PDMmaster
- mandatory master PM
-
-
Method Details
-
dispose
public void dispose()Description copied from interface:IPropertyManager
Release resources used by this manager.- Specified by:
dispose
in interfaceIPropertyManager
-
getPropertyDefinitionManager
Description copied from interface:IPropertyManager
Get the PDM. Implementations may not provide a definition manager.- Specified by:
getPropertyDefinitionManager
in interfaceIPropertyManager
- Returns:
- the PDM, null if none
-
getConfiguration
Description copied from interface:IPropertyManager
Get the configuration object.- Specified by:
getConfiguration
in interfaceIPropertyManager
- Returns:
- the configuration object
-
getValue
Description copied from interface:IPropertyManager
Get a property value. Same asgetValue(name, DEPTH_FULL, true, true)
.- Specified by:
getValue
in interfaceIPropertyManager
- 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 interfaceIPropertyManager
- Parameters:
name
- property namecheckingDepth
- one of theDEPTH_*
constantresolveDefault
- if the property has a definition, but does not have a value, the default value (as defined) would be returned instead of potentially nullvalidateValue
- 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
Description copied from interface:IPropertyManager
Set a property value.- Specified by:
setValue
in interfaceIPropertyManager
- Parameters:
name
- property namevalue
- property value; null to remove the property- Returns:
- success indicator
-
setValue
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 interfaceIPropertyManager
- Parameters:
name
- property namevalue
- property value; null to remove the propertyvalidateValue
- validate the property value against its definitionco
- (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 latercommit
all changes at once- Returns:
- success indicator
-
getBoolean
Description copied from interface:IPropertyManager
Safely retrieve a boolean property. On error, false is returned.- Specified by:
getBoolean
in interfaceIPropertyManager
- Parameters:
name
- property name- Returns:
- success indicator
-
getBoolean
Description copied from interface:IPropertyManager
Safely retrieve a boolean property.- Specified by:
getBoolean
in interfaceIPropertyManager
- Parameters:
name
- the property name- Returns:
- success indicator
-
getBooleanUnsafe
Description copied from interface:IPropertyManager
Retrieve a boolean property. This method may throw or return null.- Specified by:
getBooleanUnsafe
in interfaceIPropertyManager
- Parameters:
name
- property name- Returns:
-
setBoolean
Description copied from interface:IPropertyManager
Set a boolean property.- Specified by:
setBoolean
in interfaceIPropertyManager
- Parameters:
name
- property namevalue
- property value; null to remove the property- Returns:
- success indicator
-
setBoolean
Description copied from interface:IPropertyManager
Set a boolean property.- Specified by:
setBoolean
in interfaceIPropertyManager
- Parameters:
name
- property namevalue
- the property value; null to remove the propertyco
- 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 callingPropertyChangeObject.commit()
- Returns:
- success indicator
-
getInteger
Description copied from interface:IPropertyManager
Safely retrieve an integer property. On error, zero is returned.Selection properties are integer properties.
- Specified by:
getInteger
in interfaceIPropertyManager
- Parameters:
name
- property name- Returns:
- the property value
-
getInteger
Description copied from interface:IPropertyManager
Safely retrieve an integer property.Selection properties are integer properties.
- Specified by:
getInteger
in interfaceIPropertyManager
- Parameters:
name
- property name- Returns:
- the property value
-
getIntegerUnsafe
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 interfaceIPropertyManager
- Parameters:
name
- property name- Returns:
- the property value
-
setInteger
Description copied from interface:IPropertyManager
Set an integer property.Selection properties are integer properties.
- Specified by:
setInteger
in interfaceIPropertyManager
- Parameters:
name
- property namevalue
- property value; null to remove the property- Returns:
- success indicator
-
setInteger
Description copied from interface:IPropertyManager
Set an integer property.Selection properties are integer properties.
- Specified by:
setInteger
in interfaceIPropertyManager
- Parameters:
name
- property namevalue
- property value; null to remove the propertyco
- 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 callingPropertyChangeObject.commit()
- Returns:
- success indicator
-
getString
Description copied from interface:IPropertyManager
Safely retrieve a string property. On error, the empty string is returned.- Specified by:
getString
in interfaceIPropertyManager
- Parameters:
name
- property name- Returns:
- the property value
-
getString
Description copied from interface:IPropertyManager
Safely retrieve a string property.- Specified by:
getString
in interfaceIPropertyManager
- Parameters:
name
- property name- Returns:
- the property value
-
getStringUnsafe
Description copied from interface:IPropertyManager
Retrieve a string property.- Specified by:
getStringUnsafe
in interfaceIPropertyManager
- Parameters:
name
- property name- Returns:
- the property value
-
setString
Description copied from interface:IPropertyManager
Set a string property.- Specified by:
setString
in interfaceIPropertyManager
- Parameters:
name
- the property name; null to remove the propertyvalue
- the property value
-
setString
Description copied from interface:IPropertyManager
Set a string property.- Specified by:
setString
in interfaceIPropertyManager
- Parameters:
name
- property namevalue
- property value; null to remove the propertyco
- 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 callingPropertyChangeObject.commit()
- Returns:
- success indicator
-
setOwnerName
-
getOwnerName
-
toString
-