|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.openmdx.base.application.configuration.AbstractConfiguration
public abstract class AbstractConfiguration
A configuration holds multiple configuration entries, is versioned and has a name. A configuration entry is a name-value pair with with an additional annotation field. The value field is a list of simple objects. The annotation field holds additional describing information on a configuration entry. This class is not threadsafe. Thread safety must be guaranteed by the callers.
| Constructor Summary | |
|---|---|
AbstractConfiguration(String name)
Creates a new configuration object based on version 0.0 |
|
AbstractConfiguration(String name,
int majorVersion,
int minorVersion)
Creates a new configuration object. |
|
| Method Summary | |
|---|---|
void |
addAll(AbstractConfiguration configuration,
boolean preserve)
Add all configuration entries from a configuration. |
protected void |
addEntryDescription(ConfigurationEntryDescription[] entryDescriptions)
Adds configuration entry descriptions to the existing entry descriptions |
void |
addValue(String name,
Object value,
int index)
Adds a new value at a specified position to a multi-valued configuration entry. |
void |
applyDefaults()
Apply the defaults from the configuration entry descriptions. |
boolean |
entryExists(String name)
Returns true if the entry exists and has at least one value. |
Map |
getEntryDescriptions()
Returns the entry descriptions as an unmodifiable Map of
ConfigurationEntryDescription objects. |
Set |
getEntryNames()
Returns the configuration entry names of this configuration |
int |
getMajorVersion()
Returns the configuration's major version. |
int |
getMinorVersion()
Returns the configuration's minor version. |
String |
getName()
Returns the configuration name. |
Object |
getValue(String name)
Returns the value of a configuration entry. |
List |
getValues(String name)
Returns the values of a configuration entry. |
void |
removeAllEntries()
Removes all configuration entries. |
void |
removeEntry(String name)
Remove a configuration entry. |
void |
setValue(String name,
Object value)
Sets a new single-valued configuration entry or multi-valued value in a configuration entry. |
void |
setValues(String name,
Object[] values)
Adds a new multi-valued configuration entry. |
void |
setVersion(int majorVersion,
int minorVersion)
Sets a new version. |
String |
toString()
Returns a multiline, formatted string representation of the configuration. |
abstract Report |
validate()
Validates the configuration. |
Report |
verify()
Verifies the configuration. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public AbstractConfiguration(String name,
int majorVersion,
int minorVersion)
name - The name of this configurationmajorVersion - The major version of the configuration [0,1,2,..]minorVersion - The minor version of the configuration [0,1,2,..]public AbstractConfiguration(String name)
name - The name of this configuration| Method Detail |
|---|
public final String getName()
public final int getMajorVersion()
public final int getMinorVersion()
public final void setVersion(int majorVersion,
int minorVersion)
majorVersion - The major version of the configuration [0,1,2,..]minorVersion - The minor version of the configuration [0,1,2,..]public void applyDefaults()
Note: Applying defaults is not undoable.
public void addValue(String name,
Object value,
int index)
throws IndexOutOfBoundsException
name - A string specifying the name of the configuration
entryvalue - An object representing the value of the configuration
entry. May be null.index - The index for value the multi-valued entry. Must not
be negative. Use 0 for a single-valued entry.
IndexOutOfBoundsException - if the specified value index is
negative.
public void addAll(AbstractConfiguration configuration,
boolean preserve)
configuration - The configuration to be addedpreserve - Preserve existing entries from beeing overwritten
public void setValue(String name,
Object value)
throws IndexOutOfBoundsException,
IllegalArgumentException
name - A string specifying the name of the configuration
entryvalue - An object representing the value of the configuration
entry. May be null.
IndexOutOfBoundsException - if the specified array index is
negative.
IllegalArgumentException - if the specified array index suffix
has an invalid format.
public void setValues(String name,
Object[] values)
throws IllegalArgumentException
name - A string specifying the name of the configuration entry.
Must not have an have an array specifiervalues - An array with 0, 1 or more value objects. All objects
must be of identical type. The type must one of the supported value
types. May be a null if there are no values at all.
IllegalArgumentException - if the specified configuration entry
name contains an array specifier.public List getValues(String name)
name - A string specifying the name of the configuration entry
public Object getValue(String name)
throws InvalidCardinalityException
name - A string specifying the name of the configuration entry
InvalidCardinalityException - if the referenced configuration is
multi-valued.public boolean entryExists(String name)
public Set getEntryNames()
Set the configuration entry names of
this configurationpublic void removeEntry(String name)
name - A string specifying the name of the configuration entrypublic void removeAllEntries()
public Map getEntryDescriptions()
Map of
ConfigurationEntryDescription objects. The entry
description name builds the map's key. Returns always a Map (that may
have no entries).
public abstract Report validate()
validate in interface ConfigurationConfiguration.verify()public final Report verify()
The verification process verifies that:
verify in interface Configurationpublic String toString()
Produces a multiline string following the sample:
CfgName: Test <-- config name
Version: 1.0 <-- version (major,minor)
port=9100 <-- single-valued
filter[0]=Filter01 <-- multi-valued (3 values)
filter[1]=Filter02 :
filter[2]=Filter03 :
toString in class Object
protected void addEntryDescription(ConfigurationEntryDescription[] entryDescriptions)
throws IllegalArgumentException
entryDescriptions - The entry descriptions
IllegalArgumentException - if one of the specified entry
descriptions already exists.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||