i-net Clear Reports

com.inet.report.config
Class Configuration

java.lang.Object
  extended by com.inet.report.config.Configuration
All Implemented Interfaces:
java.lang.Comparable

public class Configuration
extends java.lang.Object
implements java.lang.Comparable

Storage of the various properties used by i-net Clear Reports to determine various behaviors, paths, and options. A description of each property and its possible values can be found here.

Configurations belong to one of three different, separate "scopes", which determine which Preferences to use as the backing store for the configuration properties.

Since:
8.0

Field Summary
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.
 
Method Summary
 void clear()
          Removes all properties from this configuration.
 int compareTo(java.lang.Object arg0)
          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.
protected  void fireEvent(int eventType)
          Fires an event saying that this configuration has changed.
protected  void fireModificationEvent(java.util.List changedProps)
          Fires an event saying that this configuration has been modified
 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.
 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.
protected  void importDatasources()
          imports the datasource properties into data source configurations
 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.
 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)
          Puts all properties in the given map into this configuration, overwriting any properties which already exist.
 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.
 

Field Detail

SCOPE_SYSTEM

public static final int SCOPE_SYSTEM
Constant for the scope of a configuration.
This scope means the configuration is stored in the system preferences

Since:
8.0
See Also:
Constant Field Values

SCOPE_USER

public static final int SCOPE_USER
Constant for the scope a configuration.
This scope means the configuration is stored in the user preferences

Since:
8.0
See Also:
Constant Field Values

SCOPE_TEMP

public static final int SCOPE_TEMP
Constant for the scope a configuration.
This scope means the configuration will not be permanently stored.

Since:
8.0
See Also:
Constant Field Values

NAME_TEMP

public 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:
8.0.
See Also:
Constant Field Values
Method Detail

getName

public 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

getScope

public int getScope()
Returns the scope of this configuration, which determines where (and if) the Preferences are to be stored.

Returns:
scope of this configuration
See Also:
SCOPE_SYSTEM, SCOPE_USER, SCOPE_TEMP

get

public java.lang.String get(java.lang.String key)
Returns the value to which the specified key is mapped, or null 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

get

public 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.
Note that this fetches the actual value stored in the Preferences behind this Configuration.

Parameters:
key - key for which to look up the value
def - default value to fall back on if the value is not stored
Returns:
the associated value if there is one and def otherwise

put

public void put(java.lang.String key,
                java.lang.String value)
Maps the specified key to the specified value.
Setting 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().

Parameters:
key - the key must not be null
value - the value to store, removes the mapping if null
Throws:
java.lang.IllegalStateException - if the preferences node underlying this configuration no longer exists
See Also:
Preferences.put(String, String)

getProperties

public java.util.Properties getProperties()
Returns the configuration's properties copied as a Properties object.
The list of properties which are used by i-net Clear Reports can be found here. 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
See Also:
Properties

toString

public java.lang.String toString()
Returns the scope and the name of the configuration as String.

Overrides:
toString in class java.lang.Object
Returns:
string representation of the given configuration: <scope>::<name>

putAll

public 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 method flush().

Parameters:
map - map from which to extract all properties and copy into this Configuration

putAll

public void putAll(java.util.Map map,
                   boolean importDatasources)
Puts all properties in the given map into this configuration, overwriting any properties which already exist. Additionally, if importDatasources is true, the properties are searched for data source properties, and data source configurations are created and configured as necessary. Note that this change will be stored permanently at some point after this method invocation. To force permanent storage, use the method flush().

Parameters:
map - Properties to import into this configuration
importDatasources - whether or not to take datasource properties and create and configure data sources.

importDatasources

protected void importDatasources()
imports the datasource properties into data source configurations


getDescription

public 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
See Also:
setDescription(String), get(String)

setDescription

public 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

equals

public boolean equals(java.lang.Object obj)
Compares the specified configuration with this configuration.

Overrides:
equals in class java.lang.Object
Parameters:
obj - Configuration
Returns:
true if scope, name, description and properties of both configurations are equals, false otherwise.

compareTo

public int compareTo(java.lang.Object arg0)
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)

Parameters:
arg0 - object to compare this configuration with
Returns:
0 if equal, negative number if "less than", positive number if "greater than"

clear

public void clear()
Removes all properties from this configuration.


isEmpty

public boolean isEmpty()
Returns whether this configuration has any properties set

Returns:
whether this configuration has any properties set

flush

public 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
See Also:
getScope(), Preferences.flush()

fireEvent

protected void fireEvent(int eventType)
Fires an event saying that this configuration has changed.

Parameters:
eventType - type of event, see ConfigurationChangeEvent.TYPE_CHANGE etc.

fireModificationEvent

protected void fireModificationEvent(java.util.List changedProps)
Fires an event saying that this configuration has been modified

Parameters:
changedProps - keys of the properties which were changed

i-net Clear Reports

Copyright © 1999-2011 by i-net software GmbH