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 SummaryFields 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 SummaryConstructors Modifier Constructor Description protectedDefaultConfiguration(Properties properties)
 - 
Method SummaryAll 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_FILEpublic static final String DEFAULT_CONFIG_FILE Default configuration file.- See Also:
- Constant Field Values
 
 - 
FLAG_PROPERTY_ONpublic static final String FLAG_PROPERTY_ON - See Also:
- Constant Field Values
 
 - 
FLAG_PROPERTY_OFFpublic static final String FLAG_PROPERTY_OFF - See Also:
- Constant Field Values
 
 - 
loggerprotected static final org.slf4j.Logger logger 
 - 
singletonprotected static final DefaultConfiguration singleton 
 - 
propertiesprotected final Properties properties 
 
- 
 - 
Constructor Detail- 
DefaultConfigurationprotected DefaultConfiguration(Properties properties) 
 
- 
 - 
Method Detail- 
singletonpublic static DefaultConfiguration singleton() - Returns:
- the singleton configuration instance. Such instance is unmodifiable.
 
 - 
copypublic static ModifiableConfiguration copy() - Returns:
- a copy of the singleton instance. such instance is modifiable.
 
 - 
getPropertiespublic String[] getProperties() Description copied from interface:ConfigurationReturns all the defined configuration properties.- Specified by:
- getPropertiesin interface- Configuration
- Returns:
- list of defined properties.
 
 - 
definePropertypublic boolean defineProperty(String propertyName) Description copied from interface:ConfigurationChecks whether a property is defined or not in configuration.- Specified by:
- definePropertyin interface- Configuration
- Parameters:
- propertyName- name of property to check.
- Returns:
- trueif defined,- falseotherwise.
 
 - 
getPropertypublic 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 interface- Configuration
- Parameters:
- propertyName- name of property
- defaultValue- default value if not found.
- Returns:
- the value associated to propertyName.
 
 - 
getPropertyOrFailpublic String getPropertyOrFail(String propertyName) Description copied from interface:ConfigurationReturns the value of the specifiedpropertyNameor raises an exception ifpropertyNameis not defined.- Specified by:
- getPropertyOrFailin interface- Configuration
- Parameters:
- propertyName- name of property to be returned.
- Returns:
- property value.
 
 - 
getPropertyIntOrFailpublic int getPropertyIntOrFail(String propertyName) Description copied from interface:ConfigurationReturns theIntegervalue of the specifiedpropertyNameor raises an exception ifpropertyNameis not defined.- Specified by:
- getPropertyIntOrFailin interface- Configuration
- Parameters:
- propertyName- name of property to be returned.
- Returns:
- property value.
 
 - 
getFlagPropertypublic 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 interface- Configuration
- Parameters:
- propertyName- name of property flag.
- Returns:
- truefor- on,- falsefor- off.
 
 - 
getConfigurationDumppublic String getConfigurationDump() Description copied from interface:ConfigurationReturns a human readable string containing the configuration dump.- Specified by:
- getConfigurationDumpin interface- Configuration
- Returns:
- a string describing the configuration options.
 
 
- 
 
-