|
Forge - Parent 1.0.6-SNAPSHOT | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Configuration
Method Summary | |
---|---|
void |
addProperty(String key,
Object value)
Add a property to the configuration. |
void |
clear()
Remove all properties from the configuration. |
void |
clearProperty(String key)
Remove a property from the configuration. |
boolean |
containsKey(String key)
Check if the configuration contains the specified key. |
BigDecimal |
getBigDecimal(String key)
Get a BigDecimal associated with the given configuration key. |
BigDecimal |
getBigDecimal(String key,
BigDecimal defaultValue)
Get a BigDecimal associated with the given configuration key. |
BigInteger |
getBigInteger(String key)
Get a BigInteger associated with the given configuration key. |
BigInteger |
getBigInteger(String key,
BigInteger defaultValue)
Get a BigInteger associated with the given configuration key. |
boolean |
getBoolean(String key)
Get a boolean associated with the given configuration key. |
boolean |
getBoolean(String key,
boolean defaultValue)
Get a boolean associated with the given configuration key. |
Boolean |
getBoolean(String key,
Boolean defaultValue)
Get a Boolean associated with the given configuration key. |
byte |
getByte(String key)
Get a byte associated with the given configuration key. |
byte |
getByte(String key,
byte defaultValue)
Get a byte associated with the given configuration key. |
Byte |
getByte(String key,
Byte defaultValue)
Get a Byte associated with the given configuration key. |
double |
getDouble(String key)
Get a double associated with the given configuration key. |
double |
getDouble(String key,
double defaultValue)
Get a double associated with the given configuration key. |
Double |
getDouble(String key,
Double defaultValue)
Get a Double associated with the given configuration key. |
float |
getFloat(String key)
Get a float associated with the given configuration key. |
float |
getFloat(String key,
float defaultValue)
Get a float associated with the given configuration key. |
Float |
getFloat(String key,
Float defaultValue)
Get a Float associated with the given configuration key. |
int |
getInt(String key)
Get a int associated with the given configuration key. |
int |
getInt(String key,
int defaultValue)
Get a int associated with the given configuration key. |
Integer |
getInteger(String key,
Integer defaultValue)
Get an Integer associated with the given configuration key. |
Iterator<?> |
getKeys()
Get the list of the keys contained in the configuration. |
Iterator<?> |
getKeys(String prefix)
Get the list of the keys contained in the configuration that match the specified prefix. |
List<?> |
getList(String key)
Get a List of strings associated with the given configuration key. |
List<?> |
getList(String key,
List<?> defaultValue)
Get a List of strings associated with the given configuration key. |
long |
getLong(String key)
Get a long associated with the given configuration key. |
long |
getLong(String key,
long defaultValue)
Get a long associated with the given configuration key. |
Long |
getLong(String key,
Long defaultValue)
Get a Long associated with the given configuration key. |
Properties |
getProperties(String key)
Get a list of Properties associated with the given configuration key. |
Object |
getProperty(String key)
Gets a property from the configuration. |
Configuration |
getScopedConfiguration(ConfigurationScope scope)
Get the underlying Configuration instance of the given ConfigurationScope type. |
short |
getShort(String key)
Get a short associated with the given configuration key. |
short |
getShort(String key,
short defaultValue)
Get a short associated with the given configuration key. |
Short |
getShort(String key,
Short defaultValue)
Get a Short associated with the given configuration key. |
String |
getString(String key)
Get a string associated with the given configuration key. |
String |
getString(String key,
String defaultValue)
Get a string associated with the given configuration key. |
String[] |
getStringArray(String key)
Get an array of strings associated with the given configuration key. |
boolean |
isEmpty()
Check if the configuration is empty. |
void |
setProperty(String key,
Object value)
Set a property, this will replace any previously set values. |
Configuration |
subset(String prefix)
Return a decorator Configuration containing every key from the current Configuration that starts with the specified prefix. |
Method Detail |
---|
Configuration getScopedConfiguration(ConfigurationScope scope)
Configuration
instance of the given ConfigurationScope
type. If no such type is
available, throw IllegalArgumentException
Configuration subset(String prefix)
prefix.number = 1 prefix.string = JBoss prefixed.foo = bar prefix = Forgethe Configuration returned by
subset("prefix")
will contain the properties:
number = 1 string = JBoss = Forge(The key for the value "Forge" is an empty string)
Since the subset is a decorator and not a modified copy of the initial Configuration, any change made to the subset is available to the Configuration, and reciprocally.
prefix
- The prefix used to select the properties.
SubsetConfiguration
boolean isEmpty()
true
if the configuration contains no property, false
otherwise.boolean containsKey(String key)
key
- the key whose presence in this configuration is to be tested
true
if the configuration contains a value for this key, false
otherwisevoid addProperty(String key, Object value)
resource.loader = fileis already present in the configuration and you call
addProperty("resource.loader", "classpath")Then you will end up with a List like the following:
["file", "classpath"]
key
- The key to add the property to.value
- The value to add.void setProperty(String key, Object value)
key
- The key of the property to changevalue
- The new valuevoid clearProperty(String key)
key
- the key to remove along with corresponding value.void clear()
Object getProperty(String key)
Configuration
interface the other get methods (that return specific
data types) will internally make use of this method. On this level variable substitution is not yet performed. The
returned object is an internal representation of the property value for the passed in key. It is owned by the
Configuration
object. So a caller should not modify this object. It cannot be guaranteed that this
object will stay constant over time (i.e. further update operations on the configuration may change its internal
state).
key
- property to retrieve
Iterator<?> getKeys(String prefix)
db.user, db.pwd, db.url, window.xpos, window.ypos
,getKeys("db");
db.user, db.pwd, db.url
.
prefix
- The prefix to test against.
getKeys()
Iterator<?> getKeys()
remove()
method is specific to a concrete
implementation. It may remove the corresponding property from the configuration, but this is not
guaranteed. In any case it is no replacement for calling clearProperty(String)
for this
property. So it is highly recommended to avoid using the iterator's remove()
method.
Properties getProperties(String key)
Properties
associated with the given configuration key. This method expects the given key to
have an arbitrary number of String values, each of which is of the form key=value
. These strings are
splitted at the equals sign, and the key parts will become keys of the returned Properties
object,
the value parts become values.
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).boolean getBoolean(String key)
key
- The configuration key.
ConversionException
- is thrown if the key maps to an object that is not a Boolean.boolean getBoolean(String key, boolean defaultValue)
key
- The configuration key.defaultValue
- The default value.
ConversionException
- is thrown if the key maps to an object that is not a Boolean.Boolean getBoolean(String key, Boolean defaultValue)
Boolean
associated with the given configuration key.
key
- The configuration key.defaultValue
- The default value.
ConversionException
- is thrown if the key maps to an object that is not a Boolean.byte getByte(String key)
key
- The configuration key.
ConversionException
- is thrown if the key maps to an object that is not a Byte.byte getByte(String key, byte defaultValue)
key
- The configuration key.defaultValue
- The default value.
ConversionException
- is thrown if the key maps to an object that is not a Byte.Byte getByte(String key, Byte defaultValue)
Byte
associated with the given configuration key.
key
- The configuration key.defaultValue
- The default value.
ConversionException
- is thrown if the key maps to an object that is not a Byte.double getDouble(String key)
key
- The configuration key.
ConversionException
- is thrown if the key maps to an object that is not a Double.double getDouble(String key, double defaultValue)
key
- The configuration key.defaultValue
- The default value.
ConversionException
- is thrown if the key maps to an object that is not a Double.Double getDouble(String key, Double defaultValue)
Double
associated with the given configuration key.
key
- The configuration key.defaultValue
- The default value.
ConversionException
- is thrown if the key maps to an object that is not a Double.float getFloat(String key)
key
- The configuration key.
ConversionException
- is thrown if the key maps to an object that is not a Float.float getFloat(String key, float defaultValue)
key
- The configuration key.defaultValue
- The default value.
ConversionException
- is thrown if the key maps to an object that is not a Float.Float getFloat(String key, Float defaultValue)
Float
associated with the given configuration key. If the key doesn't map to an existing object, the
default value is returned.
key
- The configuration key.defaultValue
- The default value.
ConversionException
- is thrown if the key maps to an object that is not a Float.int getInt(String key)
key
- The configuration key.
ConversionException
- is thrown if the key maps to an object that is not a Integer.int getInt(String key, int defaultValue)
key
- The configuration key.defaultValue
- The default value.
ConversionException
- is thrown if the key maps to an object that is not a Integer.Integer getInteger(String key, Integer defaultValue)
Integer
associated with the given configuration key. If the key doesn't map to an existing object,
the default value is returned.
key
- The configuration key.defaultValue
- The default value.
ConversionException
- is thrown if the key maps to an object that is not a Integer.long getLong(String key)
key
- The configuration key.
ConversionException
- is thrown if the key maps to an object that is not a Long.long getLong(String key, long defaultValue)
key
- The configuration key.defaultValue
- The default value.
ConversionException
- is thrown if the key maps to an object that is not a Long.Long getLong(String key, Long defaultValue)
Long
associated with the given configuration key. If the key doesn't map to an existing object, the
default value is returned.
key
- The configuration key.defaultValue
- The default value.
ConversionException
- is thrown if the key maps to an object that is not a Long.short getShort(String key)
key
- The configuration key.
ConversionException
- is thrown if the key maps to an object that is not a Short.short getShort(String key, short defaultValue)
key
- The configuration key.defaultValue
- The default value.
ConversionException
- is thrown if the key maps to an object that is not a Short.Short getShort(String key, Short defaultValue)
Short
associated with the given configuration key. If the key doesn't map to an existing object, the
default value is returned.
key
- The configuration key.defaultValue
- The default value.
ConversionException
- is thrown if the key maps to an object that is not a Short.BigDecimal getBigDecimal(String key)
BigDecimal
associated with the given configuration key.
key
- The configuration key.
BigDecimal getBigDecimal(String key, BigDecimal defaultValue)
BigDecimal
associated with the given configuration key. If the key doesn't map to an existing
object, the default value is returned.
key
- The configuration key.defaultValue
- The default value.
BigInteger getBigInteger(String key)
BigInteger
associated with the given configuration key.
key
- The configuration key.
BigInteger getBigInteger(String key, BigInteger defaultValue)
BigInteger
associated with the given configuration key. If the key doesn't map to an existing
object, the default value is returned.
key
- The configuration key.defaultValue
- The default value.
String getString(String key)
key
- The configuration key.
ConversionException
- is thrown if the key maps to an object that is not a String.String getString(String key, String defaultValue)
key
- The configuration key.defaultValue
- The default value.
ConversionException
- is thrown if the key maps to an object that is not a String.String[] getStringArray(String key)
key
- The configuration key.
ConversionException
- is thrown if the key maps to an object that is not a String/List of Strings.List<?> getList(String key)
key
- The configuration key.
ConversionException
- is thrown if the key maps to an object that is not a List.List<?> getList(String key, List<?> defaultValue)
key
- The configuration key.defaultValue
- The default value.
ConversionException
- is thrown if the key maps to an object that is not a List.
|
Forge - Parent 1.0.6-SNAPSHOT | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |