|
i-net Clear Reports | |||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectcom.inet.report.config.ConfigurationManager
public class ConfigurationManager
Manager in charge of storing, creating, copying, renaming, deleting, and fetching configurations. A configuration is a storage of the various preferences 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.
Configuration.SCOPE_SYSTEM means the configuration is stored in the system preferences.Configuration.SCOPE_USER means the configuration is stored in the user preferences.Configuration.SCOPE_TEMP means the configuration is not stored permanently at all, but only used for the
current session.
Preferences,
Configuration| Field Summary | |
|---|---|
static java.lang.String |
NAME_DEFAULT
The name to use for USER or SYSTEM configurations which are to be used by default. |
static java.lang.String |
NAME_TEMP_DEFAULT
The name to use for TEMP configurations which are to be used by default. |
| Method Summary | |
|---|---|
void |
addConfigurationChangeListener(ConfigurationChangeListener listener)
Adds a listener for a ConfigurationChangeEvent. |
void |
copy(int srcScope,
java.lang.String srcName,
int destScope,
java.lang.String destName)
Creates a copy of the specified source configuration at the specified destination with the given name. |
Configuration |
create(int scope,
java.lang.String name)
Creates a new, empty configuration with the given name and context and stores it in the appropriate Preferences. |
protected com.inet.report.config.PreferencesAccessor |
createPreferencesAccessor(java.util.prefs.Preferences prefs)
creates an accessor for being able to put and retrieve long values |
void |
delete(Configuration config)
Irreversible removes the specified configuration from storage. |
void |
delete(int scope,
java.lang.String name)
Irreversible removes the specified configuration from storage. |
void |
exportToStream(int srcScope,
java.lang.String srcName,
java.io.OutputStream out)
Writes the properties in the configuration specified to the output stream in a format suitable for loading it back using the importFromStream method. |
Configuration |
get(int scope,
java.lang.String name)
Fetches the configuration specified by the name and the scope. |
Configuration[] |
getAll(int scope)
Returns all configurations in the given scope. |
java.net.InetAddress[] |
getAvailableIPAddresses()
Returns all available IP addresses on the current system as a InetAddress array, each IP address as an individual InetAddress. |
Configuration |
getCurrent()
Returns the current Configuration. |
static ConfigurationManager |
getInstance()
Returns the singleton instance of the ConfigurationManager. |
LicenseKeyInfo |
getLicenseKeyInfo(java.lang.String licenseKey)
Blocks for 2 seconds, then returns an object holding information about the license key given. |
static java.lang.String |
getScopeName(int scope)
For debug purposes: returns the name of the given scope: "System", "User", or "Temp". |
void |
importFromStream(int destScope,
java.lang.String destName,
java.io.InputStream in)
Imports all of the preferences represented by the properties stored in the stream. |
static boolean |
isReadable(int scope)
Checks if the scope is readable by the current user. |
static boolean |
isWriteable(int scope)
Checks if the scope is writeable by the current user. |
void |
put(int scope,
java.lang.String name,
Configuration source)
Stores the configuration at the position specified. |
void |
removeConfigurationChangeListener(ConfigurationChangeListener listener)
Removes a ConfigurationChangeListener. |
void |
rename(int srcScope,
java.lang.String srcName,
int destScope,
java.lang.String destName)
Renames and/or moves a configuration. |
void |
setCurrent(Configuration config)
Sets the given configuration as the one currently being used by i-net Clear Reports instead of the default configuration as specified in getCurrent(). |
Configuration |
setTemporaryProperties(java.util.Properties props)
Creates and returns a new temporary configuration called "<temp copy>", imports the given properties and sets the created configuration as the current configuration. |
| Field Detail |
|---|
public static final java.lang.String NAME_DEFAULT
getCurrent() for more information
on the order of where the default configuration is searched for.
public static final java.lang.String NAME_TEMP_DEFAULT
getCurrent() for more information
on the order of where the default configuration is searched for.
| Method Detail |
|---|
public static ConfigurationManager getInstance()
public void copy(int srcScope,
java.lang.String srcName,
int destScope,
java.lang.String destName)
throws java.lang.SecurityException
srcName - name of configuration to copysrcScope - scope of configuration to copydestName - name of new, copied configuration. The name must be unique for the given scope.destScope - scope to store the new, copied configuration in - SCOPE_SYSTEM, SCOPE_USER, SCOPE_TEMP
java.lang.SecurityException - if you do not have permission to create a new configuration in the scope specified or
if you do not have permission to read from the source configuration.Configuration.SCOPE_SYSTEM,
Configuration.SCOPE_USER,
Configuration.SCOPE_TEMP
public Configuration create(int scope,
java.lang.String name)
throws java.lang.SecurityException
name - name the new configuration should have. This name must be unique for the given scope.scope - scope to store the new configuration in - SCOPE_SYSTEM, SCOPE_USER, or SCOPE_TEMP
java.lang.SecurityException - if you do not have permission to store a configuration in the scope specified.Configuration.SCOPE_SYSTEM,
Configuration.SCOPE_USER,
Configuration.SCOPE_TEMP
public void delete(Configuration config)
throws java.lang.SecurityException
getCurrent() is being removed, this will additionally call setCurrent(null).
config - Configuration to remove from storage
java.lang.SecurityException - if you do not have permission to remove the configuration from storage, i.e. if the
configuration is in a scope for which you do not have write permission.
public void delete(int scope,
java.lang.String name)
throws java.lang.SecurityException
getCurrent() is being removed, this will additionally call setCurrent(null).
name - name of the configuration to deletescope - scope of the configuration to delete, scope has to be exactly one of the defined scopes
java.lang.SecurityException - if you do not have permission to delete the configuration in the scope specified.
java.lang.IllegalArgumentException - if you try to delete a non-existent configurationConfiguration.SCOPE_SYSTEM,
Configuration.SCOPE_USER,
Configuration.SCOPE_TEMP
public void exportToStream(int srcScope,
java.lang.String srcName,
java.io.OutputStream out)
throws java.lang.SecurityException,
java.io.IOException
After the stream is written to, it is flushed, but remains open after this method returns.
srcName - name of the configuration to exportsrcScope - scope of the configuration to exportout - the output stream on which to emit the configuration's properties
java.lang.SecurityException - if you do not have permission to read from the scope specified
java.io.IOException - if writing to the specified output stream results in an IOExceptionProperties.store(OutputStream, String),
Configuration.SCOPE_SYSTEM,
Configuration.SCOPE_USER,
Configuration.SCOPE_TEMP
public Configuration get(int scope,
java.lang.String name)
throws java.lang.SecurityException
scope - scope of configuration to fetchname - name of configuration to fetch
java.lang.SecurityException - if it is not possible to read from the scope's root because of security reasonsConfiguration.SCOPE_SYSTEM,
Configuration.SCOPE_USER,
Configuration.SCOPE_TEMPpublic Configuration[] getAll(int scope)
Configuration.SCOPE_SYSTEM - The system preferencesConfiguration.SCOPE_USER - The user preferencesConfiguration.SCOPE_TEMP - Preferences held temporarily without a backing storeSCOPE_SYSTEM | SCOPE_USERwould fetch all configurations in the system and user preferences, for example.
scope - Scope to fetch the configurations from
java.lang.IllegalArgumentException - if you provide a scope which is neither one of the scopes nor put together by a
bit-wise "OR" operation of more than one scope.Configuration.SCOPE_SYSTEM,
Configuration.SCOPE_USER,
Configuration.SCOPE_TEMPpublic java.net.InetAddress[] getAvailableIPAddresses()
public void setCurrent(Configuration config)
getCurrent(). Note that you can set null here, this will cause the
default configuration to be used instead. Note also that this setting is not persistent, in other words it
applies only for this session.
config - Configuration to set as the "current" configuration for this session only.public Configuration getCurrent()
setCurrent(Configuration) for this session, this configuration
is returned. If it has changed since the setCurrent call, a new instance is created with refreshed content.
Configuration.SCOPE_TEMP
public void importFromStream(int destScope,
java.lang.String destName,
java.io.InputStream in)
throws java.lang.SecurityException,
java.io.IOException
If a configuration specified by the name and scope already exists, properties will be replaced by the properties in the stream if they exist there. If a configuration does not exist, one will be created at the position given.
destName - name of the configuration to import the preferences into. If no such configuration exists, one
will be created.destScope - sScope of the configuration to import the preferences into.in - the input stream from which to read the properties
java.lang.SecurityException - if you do not have permission to write to the configuration specified
java.io.IOException - If reading from the specified input stream results in an IOExceptionProperties.load(InputStream),
exportToStream(int, String, OutputStream),
Configuration.SCOPE_SYSTEM,
Configuration.SCOPE_USER,
Configuration.SCOPE_TEMPpublic LicenseKeyInfo getLicenseKeyInfo(java.lang.String licenseKey)
licenseKey - License Key to check
LicenseKeyInfo
public void put(int scope,
java.lang.String name,
Configuration source)
throws java.lang.SecurityException
scope - scope the configuration is to be stored inname - name the configuration is to havesource - Configuration to store - if null is set, this will be the equivalent to
delete(int, String).
java.lang.SecurityException - if you do not have permission to write to the given scopeConfiguration.SCOPE_SYSTEM,
Configuration.SCOPE_USER,
Configuration.SCOPE_TEMP
public void rename(int srcScope,
java.lang.String srcName,
int destScope,
java.lang.String destName)
throws java.lang.SecurityException
copy(int, String, int, String) with the given parameters, and then calling
delete(Configuration) on the old configuration. The new name does not need to be different from the old
name, however it must not be empty nor null and must be unique for the scope given.
srcScope - Scope of the configuration to rename or movesrcName - Name of the configuration to rename or movedestScope - New scope to give the configurationdestName - New name to give the configuration
java.lang.SecurityException - if you do not have permission to read, write, or delete a configuration in its given
scope.Configuration.SCOPE_SYSTEM,
Configuration.SCOPE_USER,
Configuration.SCOPE_TEMPpublic Configuration setTemporaryProperties(java.util.Properties props)
props - properties to pass the new configuration
create(int, String),
Configuration.putAll(java.util.Map),
setCurrent(Configuration)protected com.inet.report.config.PreferencesAccessor createPreferencesAccessor(java.util.prefs.Preferences prefs)
prefs - underlying prefs
public static boolean isReadable(int scope)
scope - Possible values:
java.lang.IllegalArgumentException - if scope if not Configuration.SCOPE_SYSTEM, Configuration.SCOPE_USER or
Configuration.SCOPE_TEMP.public static boolean isWriteable(int scope)
scope - Possible values:
java.lang.IllegalArgumentException - if scope if not Configuration.SCOPE_SYSTEM, Configuration.SCOPE_USER or
Configuration.SCOPE_TEMP.public static java.lang.String getScopeName(int scope)
scope - scope to return name for
public void addConfigurationChangeListener(ConfigurationChangeListener listener)
Configuration has changed through Configuration.put(String, String) or Configuration.putAll(java.util.Map).getCurrent())
listener - ConfigurationChangeListener, may not be null
java.lang.IllegalArgumentException - if listener is nullConfigurationChangeListener,
ConfigurationChangeEventpublic void removeConfigurationChangeListener(ConfigurationChangeListener listener)
listener - listener to remove, may not be null
java.lang.IllegalArgumentException - if listener is null
|
i-net Clear Reports | |||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||