|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.apache.avalon.framework.parameters.Parameters
The Parameters represents a set of key-value pairs. Each value stored in Parameters has a key. This class is similar to java.util.Properties with convenience methods to access property values by type.
Constructor Summary | |
Parameters()
|
Method Summary | |
protected void |
checkWriteable()
|
static Parameters |
fromConfiguration(Configuration configuration)
Create a Parameters object from a Configuration
object. |
static Parameters |
fromProperties(java.util.Properties properties)
Create a Parameters object from a Properties
object. |
java.lang.String[] |
getNames()
Retrieve an array of all parameter names. |
java.lang.String |
getParameter(java.lang.String name)
Retrieve the String value of the specified parameter. |
java.lang.String |
getParameter(java.lang.String name,
java.lang.String defaultValue)
Retrieve the String value of the specified parameter. |
boolean |
getParameterAsBoolean(java.lang.String name)
Retrieve the boolean value of the specified parameter. |
boolean |
getParameterAsBoolean(java.lang.String name,
boolean defaultValue)
Retrieve the boolean value of the specified parameter. |
float |
getParameterAsFloat(java.lang.String name)
Retrieve the float value of the specified parameter. |
float |
getParameterAsFloat(java.lang.String name,
float defaultValue)
Retrieve the float value of the specified parameter. |
int |
getParameterAsInteger(java.lang.String name)
Retrieve the int value of the specified parameter. |
int |
getParameterAsInteger(java.lang.String name,
int defaultValue)
Retrieve the int value of the specified parameter. |
long |
getParameterAsLong(java.lang.String name)
Retrieve the long value of the specified parameter. |
long |
getParameterAsLong(java.lang.String name,
long defaultValue)
Retrieve the long value of the specified parameter. |
java.util.Iterator |
getParameterNames()
Deprecated. Use getNames() instead |
boolean |
isParameter(java.lang.String name)
Test if the specified parameter can be retrieved. |
void |
makeReadOnly()
|
Parameters |
merge(Parameters other)
Merge parameters from another Parameters instance
into this. |
java.lang.String |
setParameter(java.lang.String name,
java.lang.String value)
Set the String value of a specified parameter. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public Parameters()
Method Detail |
public java.lang.String setParameter(java.lang.String name, java.lang.String value)
String
value of a specified parameter.
If the specified value is null the parameter is removed.public java.util.Iterator getParameterNames()
Enumeration
view of all parameter names.public java.lang.String[] getNames()
public boolean isParameter(java.lang.String name)
name
- the parameter namepublic java.lang.String getParameter(java.lang.String name) throws ParameterException
String
value of the specified parameter.
If the specified parameter cannot be found, an exception is thrown.name
- the name of parameterParameterException
- public java.lang.String getParameter(java.lang.String name, java.lang.String defaultValue)
String
value of the specified parameter.
If the specified parameter cannot be found, defaultValue
is returned.name
- the name of parameterdefaultValue
- the default value, returned if parameter does not existpublic int getParameterAsInteger(java.lang.String name) throws ParameterException
int
value of the specified parameter.
If the specified parameter cannot be found, an exception is thrown.
Hexadecimal numbers begin with 0x, Octal numbers begin with 0o and binary
numbers begin with 0b, all other values are assumed to be decimal.name
- the name of parameterParameterException
- public int getParameterAsInteger(java.lang.String name, int defaultValue)
int
value of the specified parameter.
If the specified parameter cannot be found, defaultValue
is returned.
Hexadecimal numbers begin with 0x, Octal numbers begin with 0o and binary
numbers begin with 0b, all other values are assumed to be decimal.name
- the name of parameterdefaultValue
- value returned if parameter does not exist or is of wrong typepublic long getParameterAsLong(java.lang.String name) throws ParameterException
long
value of the specified parameter.
If the specified parameter cannot be found, an exception is thrown.
Hexadecimal numbers begin with 0x, Octal numbers begin with 0o and binary
numbers begin with 0b, all other values are assumed to be decimal.name
- the name of parameterParameterException
- public long getParameterAsLong(java.lang.String name, long defaultValue)
long
value of the specified parameter.
If the specified parameter cannot be found, defaultValue
is returned.
Hexadecimal numbers begin with 0x, Octal numbers begin with 0o and binary
numbers begin with 0b, all other values are assumed to be decimal.name
- the name of parameterdefaultValue
- value returned if parameter does not exist or is of wrong typepublic float getParameterAsFloat(java.lang.String name) throws ParameterException
float
value of the specified parameter.
If the specified parameter cannot be found, an exception is thrown.name
- the parameter nameParameterException
- public float getParameterAsFloat(java.lang.String name, float defaultValue)
float
value of the specified parameter.
If the specified parameter cannot be found, defaultValue
is returned.name
- the parameter namedefaultValue
- the default value if parameter does not exist or is of wrong typepublic boolean getParameterAsBoolean(java.lang.String name) throws ParameterException
boolean
value of the specified parameter.
If the specified parameter cannot be found, an exception is thrown.name
- the parameter nameParemterException
- public boolean getParameterAsBoolean(java.lang.String name, boolean defaultValue)
boolean
value of the specified parameter.
If the specified parameter cannot be found, defaultValue
is returned.name
- the parameter namedefaultValue
- the default value if parameter does not exist or is of wrong typepublic Parameters merge(Parameters other)
Parameters
instance
into this.other
- the other ParametersParameters
instance.public void makeReadOnly()
protected final void checkWriteable() throws java.lang.IllegalStateException
public static Parameters fromConfiguration(Configuration configuration) throws ConfigurationException
Parameters
object from a Configuration
object.configuration
- the ConfigurationParameters
instance.public static Parameters fromProperties(java.util.Properties properties)
Parameters
object from a Properties
object.properties
- the PropertiesParameters
instance.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |