Package com.inet.config
Interface Configuration
-
- All Superinterfaces:
java.lang.Comparable
public interface Configuration extends java.lang.Comparable
Storage of the various properties used by the application to determine various behaviors, paths, and options. A description of each property and its possible values can be found in the help of the configuration manager web interface.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.
- Since:
- inetcore 1.0
-
-
Field Summary
Fields Modifier and Type Field 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.
This scope means the configuration is stored in the system preferencesstatic int
SCOPE_TEMP
Constant for the scope a configuration.
This scope means the configuration will not be permanently stored.static int
SCOPE_USER
Constant for the scope a configuration.
This scope means the configuration is stored in the user preferences
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method 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.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.
Note that this fetches the actual value stored in the Preferences behind this Configuration.java.lang.String
get(java.lang.String key)
Returns the value to which the specified key is mapped, ornull
otherwise.java.lang.String
get(java.lang.String key, java.lang.String def)
Returns the value to which the specified key is mapped, ordef
otherwise.
Note that this fetches the actual value stored in the Preferences behind this Configuration.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.
This name will never be empty nor null and will be unique for its scope.java.util.Properties
getProperties()
Returns the configuration's properties copied as a Properties object.
The list of properties which are used by the application can be found in the Report URL Parameters.int
getScope()
Returns the scope of this configuration, which determines where (and if) the Preferences are to be stored.default <T> 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 setdefault void
put(com.inet.config.ConfigKey key, java.lang.String value)
Maps the specified key to the specified value.
Settingnull
as a value will effectively remove the mapping associated with the key from thisConfiguration
.void
put(java.lang.String key, java.lang.String value)
Maps the specified key to the specified value.
Settingnull
as a value will effectively remove the mapping associated with the key from thisConfiguration
.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, useputAll(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 asString
.
-
-
-
Field Detail
-
SCOPE_SYSTEM
static final int SCOPE_SYSTEM
Constant for the scope of a configuration.
This scope means the configuration is stored in the system preferences- Since:
- inetcore 1.0
- See Also:
- Constant Field Values
-
SCOPE_USER
static final int SCOPE_USER
Constant for the scope a configuration.
This scope means the configuration is stored in the user preferences- Since:
- inetcore 1.0
- See Also:
- Constant Field Values
-
SCOPE_TEMP
static final int SCOPE_TEMP
Constant for the scope a configuration.
This scope means the configuration will not be permanently stored.- Since:
- inetcore 1.0
- See Also:
- Constant Field Values
-
NAME_TEMP
static final java.lang.String NAME_TEMP
The name to use for a copy of a configuration stored in the temporary scope with custom properties.- Since:
- inetcore 1.0.
- See Also:
- Constant Field Values
-
-
Method Detail
-
getName
java.lang.String getName()
Returns the name of this configuration.
This name will never be empty nor null and will be unique for its scope.- Returns:
- The name of this configuration
- Since:
- inetcore 1.0.
-
getScope
int getScope()
Returns the scope of this configuration, which determines where (and if) the Preferences are to be stored.- Returns:
- scope of this configuration
- Since:
- inetcore 1.0.
- See Also:
SCOPE_SYSTEM
,SCOPE_USER
,SCOPE_TEMP
-
get
java.lang.String get(java.lang.String key)
Returns the value to which the specified key is mapped, ornull
otherwise. Note that this fetches the actual value stored in the Preferences behind this Configuration.- Parameters:
key
- key for which to look up the value- Returns:
- the associated value if there is one and
null
otherwise - Since:
- inetcore 1.0.
-
get
java.lang.String get(java.lang.String key, java.lang.String def)
Returns the value to which the specified key is mapped, ordef
otherwise.
Note that this fetches the actual value stored in the Preferences behind this Configuration.- Parameters:
key
- key for which to look up the valuedef
- default value to fall back on if the value is not stored- Returns:
- the associated value if there is one and
def
otherwise - Since:
- inetcore 1.0.
-
get
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.
Note that this fetches the actual value stored in the Preferences behind this Configuration.- Parameters:
key
- key for which to look up the value- Returns:
- the associated value if there is one and default otherwise
- Since:
- inetcore 4.0.
-
getValue
default <T> T getValue(com.inet.config.ConfigKey key)
Returns the current value of the ConfigKey in this configuration. Note that this fetches the actual value stored in the Preferences behind this Configuration.- Type Parameters:
T
- the return type, equals to ConfigKey.getType()- Parameters:
key
- key for which to look up the value- Returns:
- the associated value if there is one and default otherwise
- Since:
- inetcore 4.0.
-
put
void put(java.lang.String key, java.lang.String value)
Maps the specified key to the specified value.
Settingnull
as a value will effectively remove the mapping associated with the key from thisConfiguration
. Note that this change will be stored permanently at some point after this method invocation. To force permanent storage, use the methodflush()
.- Parameters:
key
- the key must not benull
value
- the value to store, removes the mapping ifnull
- Throws:
java.lang.IllegalStateException
- if the preferences node underlying this configuration no longer exists- Since:
- inetcore 1.0.
- See Also:
Preferences.put(String, String)
-
put
default void put(@Nonnull com.inet.config.ConfigKey key, java.lang.String value)
Maps the specified key to the specified value.
Settingnull
as a value will effectively remove the mapping associated with the key from thisConfiguration
. Note that this change will be stored permanently at some point after this method invocation. To force permanent storage, use the methodflush()
.- Parameters:
key
- the key must not benull
value
- the value to store, removes the mapping ifnull
- Throws:
java.lang.IllegalStateException
- if the preferences node underlying this configuration no longer exists- Since:
- inetcore 4.0.
- See Also:
Preferences.put(String, String)
-
putValue
default void putValue(@Nonnull com.inet.config.ConfigKey key, java.lang.Object value)
Convert a value to String and put it in this configuration. It will throw an ClassCastException if the value is not of the Configkey type.- Parameters:
key
- the key must not benull
value
- the value to store, removes the mapping ifnull
- Since:
- inetcore 5.1.
-
getProperties
java.util.Properties getProperties()
Returns the configuration's properties copied as a Properties object.
The list of properties which are used by the application can be found in the Report URL Parameters. Note that this is only a copy, any changes you make to these properties will not be reflected in the Preferences.- Returns:
- properties of the current configuration
- Since:
- inetcore 1.0.
- See Also:
Properties
-
toString
java.lang.String toString()
Returns the scope and the name of the configuration asString
.- Overrides:
toString
in classjava.lang.Object
- Returns:
- string representation of the given configuration: <scope>::<name>
- Since:
- inetcore 1.0.
-
putAll
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. Note that this change will be stored permanently at some point after this method invocation. To force permanent storage, use the methodflush()
.- Parameters:
map
- map from which to extract all properties and copy into this Configuration- Since:
- inetcore 1.0.
-
putAll
@Deprecated void putAll(java.util.Map map, boolean importDatasources)
Deprecated.As of i-net Clear Reports 14, useputAll(Map)
Puts all properties in the given map into this configuration, overwriting any properties which already exist. Note that this change will be stored permanently at some point after this method invocation. To force permanent storage, use the methodflush()
.- Parameters:
map
- Properties to import into this configurationimportDatasources
- ignored- Since:
- inetcore 1.0.
-
getDescription
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").- Returns:
- the description of the configuration
- Since:
- inetcore 1.0.
- See Also:
setDescription(String)
,get(String)
-
setDescription
void setDescription(java.lang.String description)
Sets a description for this configuration. This is stored in the property "configuration.description", i.e. this is equivalent to calling put("configuration.description",description"). The description can be any String, including null.- Parameters:
description
- description of this configuration- Since:
- inetcore 1.0.
-
equals
boolean equals(java.lang.Object obj)
Compares the specified configuration with this configuration.- Overrides:
equals
in classjava.lang.Object
- Parameters:
obj
- Configuration- Returns:
true
if scope, name, description and properties of both configurations are equals,false
otherwise.- Since:
- inetcore 1.0.
-
compareTo
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)- Specified by:
compareTo
in interfacejava.lang.Comparable
- Parameters:
obj
- object to compare this configuration with- Returns:
- 0 if equal, negative number if "less than", positive number if "greater than"
- Since:
- inetcore 1.0.
-
clear
void clear()
Removes all properties from this configuration.- Since:
- inetcore 1.0.
-
isEmpty
boolean isEmpty()
Returns whether this configuration has any properties set- Returns:
- whether this configuration has any properties set
- Since:
- inetcore 1.0.
- See Also:
clear()
-
flush
void flush() throws java.util.prefs.BackingStoreException
Forces any changes in the contents of this configuration to the persistent store for this scope. Once this method returns, it is safe to assume that all changes made in the configuration prior to the method invocation have become permanent.- Throws:
java.util.prefs.BackingStoreException
- if it is not possible to write to the current scope- Since:
- inetcore 1.0.
- See Also:
getScope()
,Preferences.flush()
-
-