|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.apache.commons.configuration.AbstractConfiguration
Abstract configuration class. Provide basic functionality but does not store any data. If you want to write your own Configuration class then you should implement only abstract methods from this class.
Field Summary | |
protected static String |
END_TOKEN
end token |
protected static String |
START_TOKEN
start token |
Constructor Summary | |
AbstractConfiguration()
|
Method Summary | |
void |
addProperty(String key,
Object value)
{@inheritDoc} |
protected abstract void |
addPropertyDirect(String key,
Object value)
Adds a key/value pair to the Configuration. |
void |
clear()
{@inheritDoc} |
abstract void |
clearProperty(String key)
{@inheritDoc} |
abstract boolean |
containsKey(String key)
{@inheritDoc} |
BigDecimal |
getBigDecimal(String key)
{@inheritDoc} |
BigDecimal |
getBigDecimal(String key,
BigDecimal defaultValue)
{@inheritDoc} |
BigInteger |
getBigInteger(String key)
{@inheritDoc} |
BigInteger |
getBigInteger(String key,
BigInteger defaultValue)
{@inheritDoc} |
boolean |
getBoolean(String key)
{@inheritDoc} |
boolean |
getBoolean(String key,
boolean defaultValue)
{@inheritDoc} |
Boolean |
getBoolean(String key,
Boolean defaultValue)
{@inheritDoc} |
byte |
getByte(String key)
{@inheritDoc} |
byte |
getByte(String key,
byte defaultValue)
{@inheritDoc} |
Byte |
getByte(String key,
Byte defaultValue)
{@inheritDoc} |
static char |
getDelimiter()
Retrieve the current delimiter. |
double |
getDouble(String key)
{@inheritDoc} |
double |
getDouble(String key,
double defaultValue)
{@inheritDoc} |
Double |
getDouble(String key,
Double defaultValue)
{@inheritDoc} |
float |
getFloat(String key)
{@inheritDoc} |
float |
getFloat(String key,
float defaultValue)
{@inheritDoc} |
Float |
getFloat(String key,
Float defaultValue)
{@inheritDoc} |
int |
getInt(String key)
{@inheritDoc} |
int |
getInt(String key,
int defaultValue)
{@inheritDoc} |
Integer |
getInteger(String key,
Integer defaultValue)
{@inheritDoc} |
abstract Iterator |
getKeys()
{@inheritDoc} |
Iterator |
getKeys(String prefix)
{@inheritDoc} |
List |
getList(String key)
{@inheritDoc} |
List |
getList(String key,
List defaultValue)
{@inheritDoc} |
long |
getLong(String key)
{@inheritDoc} |
long |
getLong(String key,
long defaultValue)
{@inheritDoc} |
Long |
getLong(String key,
Long defaultValue)
{@inheritDoc} |
Properties |
getProperties(String key)
{@inheritDoc} |
Properties |
getProperties(String key,
Properties defaults)
Get a list of properties associated with the given configuration key. |
short |
getShort(String key)
{@inheritDoc} |
short |
getShort(String key,
short defaultValue)
{@inheritDoc} |
Short |
getShort(String key,
Short defaultValue)
{@inheritDoc} |
String |
getString(String key)
{@inheritDoc} |
String |
getString(String key,
String defaultValue)
{@inheritDoc} |
String[] |
getStringArray(String key)
{@inheritDoc} |
protected Object |
interpolate(Object value)
Returns the interpolated value. |
protected String |
interpolate(String base)
interpolate key names to handle ${key} stuff |
protected String |
interpolateHelper(String base,
List priorVariables)
Recursive handler for multple levels of interpolation. |
abstract boolean |
isEmpty()
{@inheritDoc} |
boolean |
isThrowExceptionOnMissing()
Returns true if missing values throw Exceptions. |
protected Object |
resolveContainerStore(String key)
Returns an object from the store described by the key. |
static void |
setDelimiter(char delimiter)
For configurations extending AbstractConfiguration, allow them to change the delimiter from the default comma (","). |
void |
setProperty(String key,
Object value)
{@inheritDoc} |
void |
setThrowExceptionOnMissing(boolean throwExceptionOnMissing)
Allows to set the throwExceptionOnMissing flag. |
Configuration |
subset(String prefix)
{@inheritDoc} |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.apache.commons.configuration.Configuration |
getProperty |
Field Detail |
protected static final String START_TOKEN
protected static final String END_TOKEN
Constructor Detail |
public AbstractConfiguration()
Method Detail |
public static void setDelimiter(char delimiter)
delimiter
- The new delimiterpublic static char getDelimiter()
public void setThrowExceptionOnMissing(boolean throwExceptionOnMissing)
throwExceptionOnMissing
flag. This
flag controls the behavior of property getter methods that return
objects if the requested property is missing. If the flag is set to
false (which is the default value), these methods will return
null. If set to true, they will throw a
NoSuchElementException
exception. Note that getter methods
for primitive data types are not affected by this flag.throwExceptionOnMissing
- The new value for the propertypublic boolean isThrowExceptionOnMissing()
public void addProperty(String key, Object value)
addProperty
in interface Configuration
org.apache.commons.configuration.Configuration
key
- The key to add the property to.value
- The value to add.protected abstract void addPropertyDirect(String key, Object value)
key
- key to use for mappingvalue
- object to storeprotected String interpolate(String base)
base
- string to interpolateprotected Object interpolate(Object value)
value
- the value to interpolateprotected String interpolateHelper(String base, List priorVariables)
base
- string with the ${key} variablespriorVariables
- serves two purposes: to allow checking for loops,
and creating a meaningful exception message should a loop occur. It's
0'th element will be set to the value of base from the first call. All
subsequent interpolated variables are added afterward.public Configuration subset(String prefix)
subset
in interface Configuration
org.apache.commons.configuration.Configuration
prefix
- The prefix used to select the properties.SubsetConfiguration
public abstract boolean isEmpty()
isEmpty
in interface Configuration
org.apache.commons.configuration.Configuration
true
if the configuration contains no property,
false
otherwise.public abstract boolean containsKey(String key)
containsKey
in interface Configuration
org.apache.commons.configuration.Configuration
key
- the key whose presence in this configuration is to be testedtrue
if the configuration contains a value for this
key, false
otherwisepublic void setProperty(String key, Object value)
setProperty
in interface Configuration
org.apache.commons.configuration.Configuration
key
- The key of the property to changevalue
- The new valuepublic abstract void clearProperty(String key)
clearProperty
in interface Configuration
org.apache.commons.configuration.Configuration
key
- the key to remove along with corresponding value.public void clear()
clear
in interface Configuration
public abstract Iterator getKeys()
getKeys
in interface Configuration
org.apache.commons.configuration.Configuration
public Iterator getKeys(String prefix)
getKeys
in interface Configuration
org.apache.commons.configuration.Configuration
prefix
- The prefix to test against.Configuration.getKeys()
public Properties getProperties(String key)
getProperties
in interface Configuration
org.apache.commons.configuration.Configuration
key
- The configuration key.ConversionException
- is thrown if the key maps to an
object that is not a String/List.IllegalArgumentException
- if one of the tokens is
malformed (does not contain an equals sign).public Properties getProperties(String key, Properties defaults)
key
- The configuration key.defaults
- Any default values for the returned
Properties
object. Ignored if null
.ConversionException
- is thrown if the key maps to an object that
is not a String/List of Strings.IllegalArgumentException
- if one of the tokens is malformed (does
not contain an equals sign).public boolean getBoolean(String key)
getBoolean
in interface Configuration
org.apache.commons.configuration.Configuration
key
- The configuration key.ConversionException
- is thrown if the key maps to an
object that is not a Boolean.public boolean getBoolean(String key, boolean defaultValue)
getBoolean
in interface Configuration
org.apache.commons.configuration.Configuration
key
- The configuration key.defaultValue
- The default value.ConversionException
- is thrown if the key maps to an
object that is not a Boolean.public Boolean getBoolean(String key, Boolean defaultValue)
getBoolean
in interface Configuration
org.apache.commons.configuration.Configuration
key
- The configuration key.defaultValue
- The default value.ConversionException
- is thrown if the key maps to an
object that is not a Boolean.public byte getByte(String key)
getByte
in interface Configuration
org.apache.commons.configuration.Configuration
key
- The configuration key.ConversionException
- is thrown if the key maps to an
object that is not a Byte.public byte getByte(String key, byte defaultValue)
getByte
in interface Configuration
org.apache.commons.configuration.Configuration
key
- The configuration key.defaultValue
- The default value.ConversionException
- is thrown if the key maps to an
object that is not a Byte.public Byte getByte(String key, Byte defaultValue)
getByte
in interface Configuration
org.apache.commons.configuration.Configuration
key
- The configuration key.defaultValue
- The default value.ConversionException
- is thrown if the key maps to an object that
is not a Byte.public double getDouble(String key)
getDouble
in interface Configuration
org.apache.commons.configuration.Configuration
key
- The configuration key.ConversionException
- is thrown if the key maps to an
object that is not a Double.public double getDouble(String key, double defaultValue)
getDouble
in interface Configuration
org.apache.commons.configuration.Configuration
key
- The configuration key.defaultValue
- The default value.ConversionException
- is thrown if the key maps to an
object that is not a Double.public Double getDouble(String key, Double defaultValue)
getDouble
in interface Configuration
org.apache.commons.configuration.Configuration
key
- The configuration key.defaultValue
- The default value.ConversionException
- is thrown if the key maps to an
object that is not a Double.public float getFloat(String key)
getFloat
in interface Configuration
org.apache.commons.configuration.Configuration
key
- The configuration key.ConversionException
- is thrown if the key maps to an
object that is not a Float.public float getFloat(String key, float defaultValue)
getFloat
in interface Configuration
org.apache.commons.configuration.Configuration
key
- The configuration key.defaultValue
- The default value.ConversionException
- is thrown if the key maps to an
object that is not a Float.public Float getFloat(String key, Float defaultValue)
getFloat
in interface Configuration
org.apache.commons.configuration.Configuration
key
- The configuration key.defaultValue
- The default value.ConversionException
- is thrown if the key maps to an
object that is not a Float.public int getInt(String key)
getInt
in interface Configuration
org.apache.commons.configuration.Configuration
key
- The configuration key.ConversionException
- is thrown if the key maps to an
object that is not a Integer.public int getInt(String key, int defaultValue)
getInt
in interface Configuration
org.apache.commons.configuration.Configuration
key
- The configuration key.defaultValue
- The default value.ConversionException
- is thrown if the key maps to an
object that is not a Integer.public Integer getInteger(String key, Integer defaultValue)
getInteger
in interface Configuration
org.apache.commons.configuration.Configuration
key
- The configuration key.defaultValue
- The default value.ConversionException
- is thrown if the key maps to an object that
is not a Integer.public long getLong(String key)
getLong
in interface Configuration
org.apache.commons.configuration.Configuration
key
- The configuration key.ConversionException
- is thrown if the key maps to an
object that is not a Long.public long getLong(String key, long defaultValue)
getLong
in interface Configuration
org.apache.commons.configuration.Configuration
key
- The configuration key.defaultValue
- The default value.ConversionException
- is thrown if the key maps to an
object that is not a Long.public Long getLong(String key, Long defaultValue)
getLong
in interface Configuration
org.apache.commons.configuration.Configuration
key
- The configuration key.defaultValue
- The default value.ConversionException
- is thrown if the key maps to an
object that is not a Long.public short getShort(String key)
getShort
in interface Configuration
org.apache.commons.configuration.Configuration
key
- The configuration key.ConversionException
- is thrown if the key maps to an
object that is not a Short.public short getShort(String key, short defaultValue)
getShort
in interface Configuration
org.apache.commons.configuration.Configuration
key
- The configuration key.defaultValue
- The default value.ConversionException
- is thrown if the key maps to an
object that is not a Short.public Short getShort(String key, Short defaultValue)
getShort
in interface Configuration
org.apache.commons.configuration.Configuration
key
- The configuration key.defaultValue
- The default value.ConversionException
- is thrown if the key maps to an
object that is not a Short.public BigDecimal getBigDecimal(String key)
getBigDecimal
in interface Configuration
org.apache.commons.configuration.Configuration
key
- The configuration key.public BigDecimal getBigDecimal(String key, BigDecimal defaultValue)
getBigDecimal
in interface Configuration
org.apache.commons.configuration.Configuration
key
- The configuration key.defaultValue
- The default value.public BigInteger getBigInteger(String key)
getBigInteger
in interface Configuration
org.apache.commons.configuration.Configuration
key
- The configuration key.public BigInteger getBigInteger(String key, BigInteger defaultValue)
getBigInteger
in interface Configuration
org.apache.commons.configuration.Configuration
key
- The configuration key.defaultValue
- The default value.public String getString(String key)
getString
in interface Configuration
org.apache.commons.configuration.Configuration
key
- The configuration key.ConversionException
- is thrown if the key maps to an object that
is not a String.public String getString(String key, String defaultValue)
getString
in interface Configuration
org.apache.commons.configuration.Configuration
key
- The configuration key.defaultValue
- The default value.ConversionException
- is thrown if the key maps to an object that
is not a String.public String[] getStringArray(String key)
getStringArray
in interface Configuration
org.apache.commons.configuration.Configuration
key
- The configuration key.ConversionException
- is thrown if the key maps to an
object that is not a String/List of Strings.public List getList(String key)
getList
in interface Configuration
org.apache.commons.configuration.Configuration
key
- The configuration key.ConversionException
- is thrown if the key maps to an
object that is not a List.public List getList(String key, List defaultValue)
getList
in interface Configuration
org.apache.commons.configuration.Configuration
key
- The configuration key.defaultValue
- The default value.ConversionException
- is thrown if the key maps to an
object that is not a List.protected Object resolveContainerStore(String key)
key
- The property key.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |