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 List
private static final Log
static final String
(package private) AggregatedProperties
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
containsKey
(String key) boolean
getBigDecimal
(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) boolean
getBoolean
(String key) boolean
getBoolean
(String key, boolean defaultValue) boolean
getBoolean
(String key, Filter filter) boolean
getBoolean
(String key, Filter filter, boolean defaultValue) getBoolean
(String key, Filter filter, Boolean defaultValue) getBoolean
(String key, Boolean defaultValue) byte
byte
byte
byte
Get theClass
representation 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 theClass
representation of the class name specified in the given property.Class[]
getClassArray
(String key) Get an array ofClass
objects 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 ofClass
objects for the class names specified in the given property.Returned the configured delay period for this component or null if reloading is not being performeddouble
double
double
double
float
float
float
float
int
int
int
int
getInteger
(String key, Filter filter, Integer defaultValue) getInteger
(String key, Integer defaultValue) getKeys()
Get a list of the sources which have been loaded for this componentlong
long
long
long
Returns a copy of the configuration into a java.util.Properties class.getProperty
(String key) protected Object
getPropertyWithFilter
(String key, Filter filter, Class theClass, Object defaultValue) short
short
short
short
Get 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 Object
getTypedPropertyWithDefault
(String key, Class theClass, Configuration properties, Object defaultValue) boolean
int
hashCode()
boolean
isEmpty()
boolean
protected String
listToString
(List list) void
setProperty
(String key, Object value) void
setThrowExceptionOnMissing
(boolean throwExceptionOnMissing) Set the flag throwExceptionOnMissing.Configuration
Configuration
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.DataConfiguration
Returns a decorator of the configuration of type org.apache.commons.configuration.DataConfiguration.DynaBean
Returns 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 void
validateValue
(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.Map
instance
-
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
DynaBean
instance
-
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
Configuration
instance
-
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
DataConfiguration
instance
-
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
Properties
instance
-
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 theClass
representation of the class name specified in the given property- Throws:
ClassNotFoundException
- if the specified class is not found
-
getClass
Get theClass
representation of the class name specified in the given property. Or thedefaultValue
if 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 ofClass
objects 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 ofClass
objects for the class names specified in the given property. Or thedefaultValue
if 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
-