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 StringDEFAULT_CONFIG_FILEDefault configuration file.static StringFLAG_PROPERTY_OFFstatic StringFLAG_PROPERTY_ONprotected static org.slf4j.Loggerloggerprotected Propertiespropertiesprotected static DefaultConfigurationsingleton
-
Constructor Summary
Constructors Modifier Constructor Description protectedDefaultConfiguration(Properties properties)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ModifiableConfigurationcopy()booleandefineProperty(String propertyName)Checks whether a property is defined or not in configuration.StringgetConfigurationDump()Returns a human readable string containing the configuration dump.booleangetFlagProperty(String propertyName)Returns the value of a flag property.String[]getProperties()Returns all the defined configuration properties.StringgetProperty(String propertyName, String defaultValue)Returns the value of a specified property, of the default value if property is not defined.intgetPropertyIntOrFail(String propertyName)Returns theIntegervalue of the specifiedpropertyNameor raises an exception ifpropertyNameis not defined.StringgetPropertyOrFail(String propertyName)Returns the value of the specifiedpropertyNameor raises an exception ifpropertyNameis not defined.static DefaultConfigurationsingleton()
-
-
-
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:ConfigurationReturns all the defined configuration properties.- Specified by:
getPropertiesin interfaceConfiguration- Returns:
- list of defined properties.
-
defineProperty
public boolean defineProperty(String propertyName)
Description copied from interface:ConfigurationChecks whether a property is defined or not in configuration.- Specified by:
definePropertyin interfaceConfiguration- Parameters:
propertyName- name of property to check.- Returns:
trueif defined,falseotherwise.
-
getProperty
public String getProperty(String propertyName, String defaultValue)
Description copied from interface:ConfigurationReturns the value of a specified property, of the default value if property is not defined.- Specified by:
getPropertyin 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:ConfigurationReturns the value of the specifiedpropertyNameor raises an exception ifpropertyNameis not defined.- Specified by:
getPropertyOrFailin interfaceConfiguration- Parameters:
propertyName- name of property to be returned.- Returns:
- property value.
-
getPropertyIntOrFail
public int getPropertyIntOrFail(String propertyName)
Description copied from interface:ConfigurationReturns theIntegervalue of the specifiedpropertyNameor raises an exception ifpropertyNameis not defined.- Specified by:
getPropertyIntOrFailin interfaceConfiguration- Parameters:
propertyName- name of property to be returned.- Returns:
- property value.
-
getFlagProperty
public boolean getFlagProperty(String propertyName)
Description copied from interface:ConfigurationReturns the value of a flag property. Such properties can assume only two values:onif flag is active (trueis returned).offif flag is inactive (falseis returned).
- Specified by:
getFlagPropertyin interfaceConfiguration- Parameters:
propertyName- name of property flag.- Returns:
trueforon,falseforoff.
-
getConfigurationDump
public String getConfigurationDump()
Description copied from interface:ConfigurationReturns a human readable string containing the configuration dump.- Specified by:
getConfigurationDumpin interfaceConfiguration- Returns:
- a string describing the configuration options.
-
-