Package org.apache.any23.configuration
Class DefaultConfiguration
- java.lang.Object
-
- org.apache.any23.configuration.DefaultConfiguration
-
- All Implemented Interfaces:
Configuration
- Direct Known Subclasses:
DefaultModifiableConfiguration
public class DefaultConfiguration extends Object implements Configuration
Default implementation ofConfiguration
. The default property values are read from the /default-configuration.properties properties file in classpath.- Author:
- Michele Mostarda (michele.mostarda@gmail.com)
-
-
Field Summary
Fields Modifier and Type Field Description static String
DEFAULT_CONFIG_FILE
Default configuration file.static String
FLAG_PROPERTY_OFF
static String
FLAG_PROPERTY_ON
protected static org.slf4j.Logger
logger
protected Properties
properties
protected static DefaultConfiguration
singleton
-
Constructor Summary
Constructors Modifier Constructor Description protected
DefaultConfiguration(Properties properties)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ModifiableConfiguration
copy()
boolean
defineProperty(String propertyName)
Checks whether a property is defined or not in configuration.String
getConfigurationDump()
Returns a human readable string containing the configuration dump.boolean
getFlagProperty(String propertyName)
Returns the value of a flag property.String[]
getProperties()
Returns all the defined configuration properties.String
getProperty(String propertyName, String defaultValue)
Returns the value of a specified property, of the default value if property is not defined.int
getPropertyIntOrFail(String propertyName)
Returns theInteger
value of the specifiedpropertyName
or raises an exception ifpropertyName
is not defined.String
getPropertyOrFail(String propertyName)
Returns the value of the specifiedpropertyName
or raises an exception ifpropertyName
is not defined.static DefaultConfiguration
singleton()
-
-
-
Field Detail
-
DEFAULT_CONFIG_FILE
public static final String DEFAULT_CONFIG_FILE
Default configuration file.- See Also:
- Constant Field Values
-
FLAG_PROPERTY_ON
public static final String FLAG_PROPERTY_ON
- See Also:
- Constant Field Values
-
FLAG_PROPERTY_OFF
public static final String FLAG_PROPERTY_OFF
- See Also:
- Constant Field Values
-
logger
protected static final org.slf4j.Logger logger
-
singleton
protected static final DefaultConfiguration singleton
-
properties
protected final Properties properties
-
-
Constructor Detail
-
DefaultConfiguration
protected DefaultConfiguration(Properties properties)
-
-
Method Detail
-
singleton
public static DefaultConfiguration singleton()
- Returns:
- the singleton configuration instance. Such instance is unmodifiable.
-
copy
public static ModifiableConfiguration copy()
- Returns:
- a copy of the singleton instance. such instance is modifiable.
-
getProperties
public String[] getProperties()
Description copied from interface:Configuration
Returns all the defined configuration properties.- Specified by:
getProperties
in interfaceConfiguration
- Returns:
- list of defined properties.
-
defineProperty
public boolean defineProperty(String propertyName)
Description copied from interface:Configuration
Checks whether a property is defined or not in configuration.- Specified by:
defineProperty
in interfaceConfiguration
- Parameters:
propertyName
- name of property to check.- Returns:
true
if defined,false
otherwise.
-
getProperty
public String getProperty(String propertyName, String defaultValue)
Description copied from interface:Configuration
Returns the value of a specified property, of the default value if property is not defined.- Specified by:
getProperty
in interfaceConfiguration
- Parameters:
propertyName
- name of propertydefaultValue
- default value if not found.- Returns:
- the value associated to propertyName.
-
getPropertyOrFail
public String getPropertyOrFail(String propertyName)
Description copied from interface:Configuration
Returns the value of the specifiedpropertyName
or raises an exception ifpropertyName
is not defined.- Specified by:
getPropertyOrFail
in interfaceConfiguration
- Parameters:
propertyName
- name of property to be returned.- Returns:
- property value.
-
getPropertyIntOrFail
public int getPropertyIntOrFail(String propertyName)
Description copied from interface:Configuration
Returns theInteger
value of the specifiedpropertyName
or raises an exception ifpropertyName
is not defined.- Specified by:
getPropertyIntOrFail
in interfaceConfiguration
- Parameters:
propertyName
- name of property to be returned.- Returns:
- property value.
-
getFlagProperty
public boolean getFlagProperty(String propertyName)
Description copied from interface:Configuration
Returns the value of a flag property. Such properties can assume only two values:on
if flag is active (true
is returned).off
if flag is inactive (false
is returned).
- Specified by:
getFlagProperty
in interfaceConfiguration
- Parameters:
propertyName
- name of property flag.- Returns:
true
foron
,false
foroff
.
-
getConfigurationDump
public String getConfigurationDump()
Description copied from interface:Configuration
Returns a human readable string containing the configuration dump.- Specified by:
getConfigurationDump
in interfaceConfiguration
- Returns:
- a string describing the configuration options.
-
-