Package com.germinus.easyconf
Class ComponentProperties
java.lang.Object
com.germinus.easyconf.ComponentProperties
Part of a component configuration which contains its properties.
The properties can be accessed by type and automatic conversion will be
performed. The supported types are: BigDecimal, BigInteger, Boolean, Byte,
Double, Float, Integer, List, Long, Short, String and StringArray
It is based on the
Configuration interface from Jakarta
Commons Configuration but it is given a different name which makes more sense
inside EasyConf.
The boolean flag throwExceptionOnMissing controls the behaviour of this class
when a property that does not exist is queried. If set to true (the default)
a NoSuchElementException will be thrown if the given key does not
exist and no default was provided. If set to false, null will be
returned except for the method getList() which will return an empty
unmodifyiable list.- Version:
- $Revision: 1.23 $
- Author:
- Jorge Ferrer
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Listprivate static final Logstatic final String(package private) AggregatedProperties -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancontainsKey(String key) booleangetBigDecimal(String key) getBigDecimal(String key, Filter filter) getBigDecimal(String key, Filter filter, BigDecimal defaultValue) getBigDecimal(String key, BigDecimal defaultValue) getBigInteger(String key) getBigInteger(String key, Filter filter) getBigInteger(String key, Filter filter, BigInteger defaultValue) getBigInteger(String key, BigInteger defaultValue) booleangetBoolean(String key) booleangetBoolean(String key, boolean defaultValue) booleangetBoolean(String key, Filter filter) booleangetBoolean(String key, Filter filter, boolean defaultValue) getBoolean(String key, Filter filter, Boolean defaultValue) getBoolean(String key, Boolean defaultValue) bytebytebytebyteGet theClassrepresentation of the class name specified in the given propertySimilar to the previous methods but complementing the property key with the given filterEquivalent to the previous method but giving a default value which will be used if no value has been specified in the configurations fileGet theClassrepresentation of the class name specified in the given property.Class[]getClassArray(String key) Get an array ofClassobjects for the class names specified in the given propertyClass[]getClassArray(String key, Filter filter) Similar to the previous methods but complementing the property key with the given filterClass[]getClassArray(String key, Filter filter, Class[] defaultValue) Equivalent to the previous method but giving a default value which will be used if no value has been specified in the configurations fileClass[]getClassArray(String key, Class[] defaultValue) Get an array ofClassobjects for the class names specified in the given property.Returned the configured delay period for this component or null if reloading is not being performeddoubledoubledoubledoublefloatfloatfloatfloatintintintintgetInteger(String key, Filter filter, Integer defaultValue) getInteger(String key, Integer defaultValue) getKeys()Get a list of the sources which have been loaded for this componentlonglonglonglongReturns a copy of the configuration into a java.util.Properties class.getProperty(String key) protected ObjectgetPropertyWithFilter(String key, Filter filter, Class theClass, Object defaultValue) shortshortshortshortGet the String value of the given key.String[]getStringArray(String key) String[]getStringArray(String key, Filter filter) String[]getStringArray(String key, Filter filter, String[] defaultValue) String[]getStringArray(String key, String[] defaultValue) protected static ObjectgetTypedPropertyWithDefault(String key, Class theClass, Configuration properties, Object defaultValue) booleaninthashCode()booleanisEmpty()booleanprotected StringlistToString(List list) voidsetProperty(String key, Object value) voidsetThrowExceptionOnMissing(boolean throwExceptionOnMissing) Set the flag throwExceptionOnMissing.ConfigurationConfigurationReturns a decorator of the configuration of type org.apache.commons.configuration.Configuration Note that any changes made to this decorator will be made to the original configuration and viceversa.DataConfigurationReturns a decorator of the configuration of type org.apache.commons.configuration.DataConfiguration.DynaBeanReturns a decorator of the configuration that can be used as a DynaBean.toMap()Returns a decorator of the configuration that implements the Map interface.toString()protected voidvalidateValue(String key, Object value)
-
Field Details
-
NULL_STRING
-
EMPTY_LIST
-
log
private static final Log log -
properties
AggregatedProperties properties
-
-
Constructor Details
-
ComponentProperties
ComponentProperties(AggregatedProperties conf)
-
-
Method Details
-
toMap
Returns a decorator of the configuration that implements the Map interface. Note that any changes made to this decorator will be made to the original configuration and viceversa.- Returns:
- a
java.util.Mapinstance
-
toDynaBean
public DynaBean toDynaBean()Returns a decorator of the configuration that can be used as a DynaBean. Note that any changes made to this decorator will be made to the original configuration and viceversa.- Returns:
- a
DynaBeaninstance
-
toConfiguration
public Configuration toConfiguration()Returns a decorator of the configuration of type org.apache.commons.configuration.Configuration Note that any changes made to this decorator will be made to the original configuration and viceversa.- Returns:
- a
Configurationinstance
-
toDataConfiguration
public DataConfiguration toDataConfiguration()Returns a decorator of the configuration of type org.apache.commons.configuration.DataConfiguration. This decorator has many extra methods for retrieving typed properties such as color, URL, locale, Calendar and lists and array of any of these types. Note that any changes made to this decorator will be made to the original configuration and viceversa.- Returns:
- a
DataConfigurationinstance
-
getProperties
Returns a copy of the configuration into a java.util.Properties class. Multivalued properties will be converted to comma-separated strings. Any changes made to the configuration will not be available to the Properties and viceversa.- Returns:
- a
Propertiesinstance
-
getProperty
-
containsKey
-
equals
-
getKeys
-
getKeys
-
hashCode
public int hashCode() -
isEmpty
public boolean isEmpty() -
setProperty
-
subset
-
toString
-
getBigDecimal
-
getBigDecimal
-
getBigDecimal
-
getBigDecimal
-
getBigInteger
-
getBigInteger
-
getBigInteger
-
getBigInteger
-
getBoolean
-
getBoolean
-
getBoolean
- Throws:
NoClassDefFoundError
-
getBoolean
-
getBoolean
public Boolean getBoolean(String key, Filter filter, Boolean defaultValue) throws NoClassDefFoundError - Throws:
NoClassDefFoundError
-
getBoolean
-
getByte
-
getByte
-
getByte
-
getByte
-
getByte
-
getByte
-
getDouble
-
getDouble
-
getDouble
-
getDouble
-
getDouble
-
getDouble
-
getClass
Get theClassrepresentation of the class name specified in the given property- Throws:
ClassNotFoundException- if the specified class is not found
-
getClass
Get theClassrepresentation of the class name specified in the given property. Or thedefaultValueif no value has been given to the property.- Throws:
ClassNotFoundException- if a class has been configured but it is not found
-
getClass
Similar to the previous methods but complementing the property key with the given filter- Throws:
ClassNotFoundException
-
getClass
Equivalent to the previous method but giving a default value which will be used if no value has been specified in the configurations file- Throws:
ClassNotFoundException
-
getClassArray
Get an array ofClassobjects for the class names specified in the given property- Throws:
ClassNotFoundException- if the any of the configured classes is not found
-
getClassArray
Get an array ofClassobjects for the class names specified in the given property. Or thedefaultValueif no value has been given to the property.- Throws:
ClassNotFoundException- if the any of the configured classes is not found
-
getClassArray
Similar to the previous methods but complementing the property key with the given filter- Throws:
ClassNotFoundException
-
getClassArray
public Class[] getClassArray(String key, Filter filter, Class[] defaultValue) throws ClassNotFoundException Equivalent to the previous method but giving a default value which will be used if no value has been specified in the configurations file- Throws:
ClassNotFoundException
-
getFloat
-
getFloat
-
getFloat
-
getFloat
-
getFloat
-
getFloat
-
getInt
-
getInt
-
getInteger
-
getInt
-
getInteger
-
getInt
-
getList
-
getList
-
getList
-
getList
-
getLong
-
getLong
-
getLong
-
getLong
-
getLong
-
getLong
-
getShort
-
getShort
-
getShort
-
getShort
-
getShort
-
getShort
-
getString
Get the String value of the given key. If it contains a list of values, they will be serialized to a comma-separated format (use getList or getStringArray if you want separated list items) -
getString
-
getString
-
getString
-
getStringArray
-
getStringArray
-
getStringArray
-
getStringArray
-
hasBaseConfiguration
public boolean hasBaseConfiguration() -
getLoadedSources
Get a list of the sources which have been loaded for this component -
setThrowExceptionOnMissing
public void setThrowExceptionOnMissing(boolean throwExceptionOnMissing) Set the flag throwExceptionOnMissing. See the class documentation for more details. -
isThrowExceptionOnMissing
public boolean isThrowExceptionOnMissing() -
getDelayPeriod
Returned the configured delay period for this component or null if reloading is not being performed -
getComponentName
-
getPropertyWithFilter
-
getTypedPropertyWithDefault
-
validateValue
-
listToString
-