de.fhg.igd.logging
Class ConfigurationParameters

java.lang.Object
  extended byde.fhg.igd.logging.ConfigurationParameters
All Implemented Interfaces:
Cloneable

public class ConfigurationParameters
extends Object
implements Cloneable

This is a container class for all parameters needed by the LoggingConfiguration.

Notice: This class is not synchronized/thread-safe.

Version:
"$Id: ConfigurationParameters.java 1913 2007-08-08 02:41:53Z jpeters $"
Author:
Matthias Pressfreund

Nested Class Summary
static class ConfigurationParameters.BestMatch
          This is wrapper class for a best matching configuration entry, which is for example the return type of LoggingConfiguration.getOutput(String) and LoggingConfiguration.getLogLevel(String).
 
Field Summary
protected  Map buffers_
          The storage for user configured buffer sizes, URL objects are used as keys, Integer objects as values
protected static ConfigurationParameters default_
          The default parameters
static Integer DEFAULT_BUFFER_LOCAL
          The default value of the buffer property (for local destination URLs)
static Integer DEFAULT_BUFFER_NETWORK
          The default value of the buffer property (for network destination URLs)
static Long DEFAULT_INTERVAL
          The default value of the interval property
static String DEFAULT_LOGGER
          The default value of the logger property
static LogLevel DEFAULT_LOGLEVEL
          The default value of the loglevel property
static URL DEFAULT_OUTPUT
          The default value of the output property
protected  Long interval_
          The interval property value
protected  ConfigurationParameters last_
          The undo information
protected  String logger_
          The logger property value
protected  Map loglevels_
          The storage for user configured log levels, class/package name String objects are used as keys, LogLevel objects as values
protected  Map outputs_
          The storage for user configured output URLs, class/package name String objects are used as keys, URL objects as values
static String PROPERTY_BUFFER
          The name of the buffer property
static String PROPERTY_INTERVAL
          The name of the interval property
static String PROPERTY_LOGGER
          The name of the logger property
static String PROPERTY_LOGLEVEL
          The name of the loglevel property
static String PROPERTY_OUTPUT
          The name of the output property
 
Constructor Summary
ConfigurationParameters()
          Create an empty ConfigurationParameters container.
 
Method Summary
 boolean addOutput(String name, URL output)
          Add an output URL for the given name.
 Object clone()
           
static String convertBuffer(Integer buffer)
          Convert an Integer value into a buffer String as it might be used in the configuration file.
static String convertInterval(Long interval)
          Convert a Long value into an interval String as it might be used in the configuration file.
static ConfigurationParameters create(Properties properties)
          Create a ConfigurationParameters container initialized from a set of property values.
 boolean equals(Object obj)
           
protected static String findBestName(Map map, String target)
          Find the best matching key for the given name in the specified Map.
 String findBestName(String target)
          Find the best matching name that has either an output or a loglevel configuration entry for the given target name.
 ConfigurationParameters.BestMatch getBestLogLevel(String name)
          Get the best matching LogLevel for the given name.
 ConfigurationParameters.BestMatch getBestOutput(String name)
          Get the best matching Set of output URLs for the given name.
 Integer getBuffer(URL output)
          Get the current buffer property value for the given output URL.
 Map getBufferMap()
          Get all defined buffers.
static ConfigurationParameters getDefault()
          Get the default ConfigurationParameters.
 Long getInterval()
          Get the current interval property value.
 String getLogger()
          Get the current logger property value.
 LogLevel getLogLevel(String name)
          Get the loglevel for the given name.
 Map getLoglevelMap()
          Get all defined loglevels.
 Set getOutput(String name)
          Get the output URL for the given name.
 Map getOutputMap()
          Get all defined output URLs.
 int hashCode()
           
static Integer parseBuffer(String buffer)
          Parse a buffer String as an Integer value.
static Long parseInterval(String interval)
          Parse an interval String as a Long value.
static LogLevel parseLogLevel(String loglevel)
          Parse a loglevel String as a LogLevel object.
static URL parseOutput(String output)
          Parse an output String as an Output value.
 boolean removeOutput(String name, URL output)
          Remove the output URL for the given name.
 void save(OutputStream os)
          Save the current parameters into a stream.
 boolean setBuffer(URL output, Integer buffer)
          Define a buffer property value for a specific output URL.
 boolean setInterval(Long interval)
          Set the interval property value.
 boolean setLogger(String logger)
          Set the logger property value.
 boolean setLogLevel(String name, LogLevel level)
          Define a loglevel property value for a specific name.
 String toString()
           
 void undo()
          Undo the most recent property change.
 boolean unsetBuffer(URL output)
          Delete a buffer property value for a specific output URL.
 boolean unsetLogLevel(String name)
          Delete the loglevel property value for a specific name.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

PROPERTY_LOGGER

public static final String PROPERTY_LOGGER
The name of the logger property

See Also:
Constant Field Values

PROPERTY_INTERVAL

public static final String PROPERTY_INTERVAL
The name of the interval property

See Also:
Constant Field Values

PROPERTY_BUFFER

public static final String PROPERTY_BUFFER
The name of the buffer property

See Also:
Constant Field Values

PROPERTY_OUTPUT

public static final String PROPERTY_OUTPUT
The name of the output property

See Also:
Constant Field Values

PROPERTY_LOGLEVEL

public static final String PROPERTY_LOGLEVEL
The name of the loglevel property

See Also:
Constant Field Values

DEFAULT_LOGGER

public static final String DEFAULT_LOGGER
The default value of the logger property

See Also:
Constant Field Values

DEFAULT_INTERVAL

public static final Long DEFAULT_INTERVAL
The default value of the interval property


DEFAULT_BUFFER_LOCAL

public static final Integer DEFAULT_BUFFER_LOCAL
The default value of the buffer property (for local destination URLs)


DEFAULT_BUFFER_NETWORK

public static final Integer DEFAULT_BUFFER_NETWORK
The default value of the buffer property (for network destination URLs)


DEFAULT_OUTPUT

public static final URL DEFAULT_OUTPUT
The default value of the output property


DEFAULT_LOGLEVEL

public static final LogLevel DEFAULT_LOGLEVEL
The default value of the loglevel property


logger_

protected String logger_
The logger property value


interval_

protected Long interval_
The interval property value


buffers_

protected Map buffers_
The storage for user configured buffer sizes, URL objects are used as keys, Integer objects as values


outputs_

protected Map outputs_
The storage for user configured output URLs, class/package name String objects are used as keys, URL objects as values


loglevels_

protected Map loglevels_
The storage for user configured log levels, class/package name String objects are used as keys, LogLevel objects as values


last_

protected ConfigurationParameters last_
The undo information


default_

protected static ConfigurationParameters default_
The default parameters

Constructor Detail

ConfigurationParameters

public ConfigurationParameters()
Create an empty ConfigurationParameters container.

Method Detail

getDefault

public static ConfigurationParameters getDefault()
Get the default ConfigurationParameters.

Returns:
The default ConfigurationParameters

create

public static ConfigurationParameters create(Properties properties)
Create a ConfigurationParameters container initialized from a set of property values.

Parameters:
properties - The initialization properties
Returns:
The ConfigurationParameters container
Throws:
IllegalArgumentException - if the given properties contain one or more invalid entries

setLogger

public boolean setLogger(String logger)
Set the logger property value.

Parameters:
logger - The new logger property value
Returns:
true if the property value was changed successfully
Throws:
NullPointerException - if logger is null

getLogger

public String getLogger()
Get the current logger property value.

Returns:
The current logger property value

setInterval

public boolean setInterval(Long interval)
Set the interval property value.

Parameters:
interval - The new interval property value
Returns:
true if the property value was changed successfully
Throws:
NullPointerException - if interval is null

getInterval

public Long getInterval()
Get the current interval property value.

Returns:
The current interval property value

setBuffer

public boolean setBuffer(URL output,
                         Integer buffer)
Define a buffer property value for a specific output URL.

Parameters:
output - The output URL to define the buffer for
buffer - The buffer value
Returns:
true if the property value was set successfully
Throws:
NullPointerException - if output or buffer is null

unsetBuffer

public boolean unsetBuffer(URL output)
Delete a buffer property value for a specific output URL.

Parameters:
output - The output URL to delete the buffer for
Returns:
true if the property value was set successfully
Throws:
NullPointerException - if output is null

getBuffer

public Integer getBuffer(URL output)
Get the current buffer property value for the given output URL.

Notice: In case there is no buffer value defined for the given output URL, the default buffer size (which depends on the URL protocol identifier) will be returned.

Parameters:
output - The output URL
Returns:
The current buffer property value for the given output URL

getBufferMap

public Map getBufferMap()
Get all defined buffers.

Returns:
The buffer mappings, URL objects are used as keys, Integer objects as values

addOutput

public boolean addOutput(String name,
                         URL output)
Add an output URL for the given name.

Parameters:
name - The name to add the output URL for
output - The new output URL
Returns:
true if the property value was set successfully
Throws:
NullPointerException - if name or output is null

removeOutput

public boolean removeOutput(String name,
                            URL output)
Remove the output URL for the given name.

Parameters:
name - The name to remove the output URL for
output - The output URL to remove
Returns:
true if the property value was set successfully
Throws:
NullPointerException - if name or output is null

getBestOutput

public ConfigurationParameters.BestMatch getBestOutput(String name)
Get the best matching Set of output URLs for the given name.

Parameters:
name - The corresponding name of the output URLs
Returns:
The best matching output URLs for the given name

getOutput

public Set getOutput(String name)
Get the output URL for the given name.

Parameters:
name - The name to lookup the output URL for
Returns:
The output URL for the given name or an empty Set if nothing could be found

getOutputMap

public Map getOutputMap()
Get all defined output URLs.

Returns:
The output URL mappings, String objects are used as keys, Sets of URL objects as values

setLogLevel

public boolean setLogLevel(String name,
                           LogLevel level)
Define a loglevel property value for a specific name.

Parameters:
name - The name to define the loglevel for
level - The loglevel value
Returns:
true if the property value was set successfully
Throws:
NullPointerException - if name or level is null

unsetLogLevel

public boolean unsetLogLevel(String name)
Delete the loglevel property value for a specific name.

Parameters:
name - The name to delete the loglevel for
Returns:
true if the property value was set successfully
Throws:
NullPointerException - if name is null

getBestLogLevel

public ConfigurationParameters.BestMatch getBestLogLevel(String name)
Get the best matching LogLevel for the given name.

Parameters:
name - The corresponding name of the LogLevel
Returns:
The best matching LogLevel for the given name

getLogLevel

public LogLevel getLogLevel(String name)
Get the loglevel for the given name.

Parameters:
name - The name to lookup the loglevel for
Returns:
The loglevel for the given name

getLoglevelMap

public Map getLoglevelMap()
Get all defined loglevels.

Returns:
The loglevel mappings, String objects are used as keys, LogLevel objects as values

undo

public void undo()
Undo the most recent property change.


save

public void save(OutputStream os)
Save the current parameters into a stream.

Parameters:
os - The target output stream

findBestName

public String findBestName(String target)
Find the best matching name that has either an output or a loglevel configuration entry for the given target name. If none of the names found in the current configuration matches the given target, an empty String (representing the root name) will be returned.

Parameters:
target - The target name to be searched for
Returns:
The best match for the given target name

findBestName

protected static String findBestName(Map map,
                                     String target)
Find the best matching key for the given name in the specified Map. If none of the keys matches the given name, an empty String (representing the root name) will be returned.

Parameters:
map - The Map to be searched
target - The target name
Returns:
The best matching key for the given target name

parseInterval

public static Long parseInterval(String interval)
Parse an interval String as a Long value. The parser can read int and float values with or without a trailing unit identifier:

Parameters:
interval - The interval String to be parsed
Returns:
The resulting interval value in millis
Throws:
IllegalArgumentException - if the given value could not be parsed

convertInterval

public static String convertInterval(Long interval)
Convert a Long value into an interval String as it might be used in the configuration file. The long value will be converted into the lowest possible float or int value greater than 1, using one of the following unit identifiers:

Parameters:
interval - The interval value (in millis) to be converted
Returns:
The resulting interval String

parseBuffer

public static Integer parseBuffer(String buffer)
Parse a buffer String as an Integer value. The parser can read int and float values with or without a trailing unit identifier:

Parameters:
buffer - The buffer size String to be parsed
Returns:
The resulting buffer value
Throws:
IllegalArgumentException - if the given value could not be parsed

convertBuffer

public static String convertBuffer(Integer buffer)
Convert an Integer value into a buffer String as it might be used in the configuration file. The int value will be converted into the lowest possible float or int value greater than 1, using one of the following unit identifiers:

Parameters:
buffer - The buffer value to be converted
Returns:
The resulting buffer size String

parseOutput

public static URL parseOutput(String output)
Parse an output String as an Output value.

Parameters:
output - The output String to be parsed
Returns:
The resulting output value
Throws:
IllegalArgumentException - if the given value could not be parsed

parseLogLevel

public static LogLevel parseLogLevel(String loglevel)
Parse a loglevel String as a LogLevel object.

Parameters:
loglevel - The loglevel String to be parsed
Returns:
The resulting loglevel object
Throws:
IllegalArgumentException - if the given value could not be parsed

clone

public Object clone()

equals

public boolean equals(Object obj)

hashCode

public int hashCode()

toString

public String toString()


Copyright © Fraunhofer Gesellschaft. All Rights Reserved.