public interface Configuration
extends java.lang.Comparable
Configurations belong to one of three different, separate "scopes", which determine which Preferences to use as the backing store for the configuration properties.
SCOPE_SYSTEM
means the configuration is stored in the system preferences.SCOPE_USER
means the configuration is stored in the user preferences.SCOPE_TEMP
means the configuration is not stored permanently at all, but only used for the current session.Modifier and Type | Field and Description |
---|---|
static java.lang.String |
NAME_TEMP
The name to use for a copy of a configuration stored in the temporary scope with custom properties.
|
static int |
SCOPE_SYSTEM
Constant for the scope of a configuration.
|
static int |
SCOPE_TEMP
Constant for the scope a configuration.
|
static int |
SCOPE_USER
Constant for the scope a configuration.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Removes all properties from this configuration.
|
int |
compareTo(java.lang.Object obj)
Compares this configuration with another object by comparing its name with the string
representation of the object (or if the object is a configuration, with its name)
|
boolean |
equals(java.lang.Object obj)
Compares the specified configuration with this configuration.
|
void |
flush()
Forces any changes in the contents of this configuration to the
persistent store for this scope.
|
java.lang.String |
get(java.lang.String key)
Returns the value to which the specified key is mapped, or
null otherwise. |
java.lang.String |
get(java.lang.String key,
java.lang.String def)
Returns the value to which the specified key is mapped, or
def otherwise. |
default java.lang.String |
get(com.inet.config.ConfigKey key)
Returns the string value to which the specified ConfigKey is mapped, or the default otherwise.
|
java.lang.String |
getDescription()
Returns the description set for this configuration, which is found in the property
"configuration.description", i.e. this is equivalent to calling get("configuration.description").
|
java.lang.String |
getName()
Returns the name of this configuration.
|
java.util.Properties |
getProperties()
Returns the configuration's properties copied as a Properties object.
|
int |
getScope()
Returns the scope of this configuration, which determines where (and if) the Preferences are to be stored.
|
default T |
getValue(com.inet.config.ConfigKey key)
Returns the current value of the ConfigKey in this configuration.
|
boolean |
isEmpty()
Returns whether this configuration has any properties set
|
void |
put(java.lang.String key,
java.lang.String value)
Maps the specified key to the specified value.
|
default void |
put(com.inet.config.ConfigKey key,
java.lang.String value)
Maps the specified key to the specified value.
|
void |
putAll(java.util.Map map)
Convenience method which puts all properties in the given map into this configuration, overwriting
any properties which already exist.
|
void |
putAll(java.util.Map map,
boolean importDatasources)
Deprecated.
As of i-net Clear Reports 14, use
putAll(Map) |
default void |
putValue(com.inet.config.ConfigKey key,
java.lang.Object value)
Convert a value to String and put it in this configuration.
|
void |
setDescription(java.lang.String description)
Sets a description for this configuration.
|
java.lang.String |
toString()
Returns the scope and the name of the configuration as
String . |
static final int SCOPE_SYSTEM
static final int SCOPE_USER
static final int SCOPE_TEMP
static final java.lang.String NAME_TEMP
java.lang.String getName()
int getScope()
SCOPE_SYSTEM
,
SCOPE_USER
,
SCOPE_TEMP
java.lang.String get(java.lang.String key)
null
otherwise.
Note that this fetches the actual value stored in the Preferences behind this Configuration.key
- key for which to look up the valuenull
otherwisejava.lang.String get(java.lang.String key, java.lang.String def)
def
otherwise.key
- key for which to look up the valuedef
- default value to fall back on if the value is not storeddef
otherwisedefault java.lang.String get(com.inet.config.ConfigKey key)
key
- key for which to look up the valuedefault T getValue(com.inet.config.ConfigKey key)
key
- key for which to look up the valuevoid put(java.lang.String key, java.lang.String value)
null
as a value will effectively remove the mapping associated with the key from
this Configuration
. Note that this change will be stored permanently
at some point after this method invocation. To force permanent storage, use the method flush()
.key
- the key must not be null
value
- the value to store, removes the mapping if null
java.lang.IllegalStateException
- if the preferences node underlying this configuration no longer existsPreferences.put(String, String)
default void put(@Nonnull com.inet.config.ConfigKey key, java.lang.String value)
null
as a value will effectively remove the mapping associated with the key from
this Configuration
. Note that this change will be stored permanently
at some point after this method invocation. To force permanent storage, use the method flush()
.key
- the key must not be null
value
- the value to store, removes the mapping if null
java.lang.IllegalStateException
- if the preferences node underlying this configuration no longer existsPreferences.put(String, String)
default void putValue(@Nonnull com.inet.config.ConfigKey key, java.lang.Object value)
key
- the key must not be null
value
- the value to store, removes the mapping if null
java.util.Properties getProperties()
Properties
java.lang.String toString()
String
.toString
in class java.lang.Object
void putAll(java.util.Map map)
flush()
.map
- map from which to extract all properties and copy into this Configuration@Deprecated void putAll(java.util.Map map, boolean importDatasources)
putAll(Map)
flush()
.map
- Properties to import into this configurationimportDatasources
- ignoredjava.lang.String getDescription()
setDescription(String)
,
get(String)
void setDescription(java.lang.String description)
description
- description of this configurationboolean equals(java.lang.Object obj)
equals
in class java.lang.Object
obj
- Configurationtrue
if scope, name, description and properties of both configurations are equals, false
otherwise.int compareTo(java.lang.Object obj)
obj
- object to compare this configuration withvoid clear()
boolean isEmpty()
clear()
void flush() throws java.util.prefs.BackingStoreException
java.util.prefs.BackingStoreException
- if it is not possible to write to the current scopegetScope()
,
Preferences.flush()
Copyright © 1999-2020 by i-net software GmbH