Parameters class represents a set of key-value
pairs.
The Parameters object provides a mechanism to obtain
values based on a String name. There are convenience
methods that allow you to use defaults if the value does not exist,
as well as obtain the value in any of the same formats that are in
the Configuration interface.
While there are similarities between the Parameters
object and the java.util.Properties object, there are some
important semantic differences. First, Parameters are
read-only. Second, Parameters are easily
derived from Configuration objects. Lastly, the
Parameters object is derived from XML fragments that
look like this:
<parameter name="param-name" value="param-value" />
Note: this class is not thread safe by default. If you require thread safety please synchronize write access to this class to prevent potential data corruption.
| Modifier and Type | Field and Description |
|---|---|
| public static final Parameters | EMPTY_PARAMETERS
Empty Parameters object |
| private Map | |
| private boolean |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| protected final void | |
| public boolean | Returns: true if this parameters instance is equal to the supplied objectthe object to compare this parameters instance with other)Overrides java. |
| public static Parameters | Returns: ThisParameters instance.the Configuration configuration)Create a |
| public static Parameters | Returns: ThisParameters instance.the Configuration configuration, final String the element name for the parameters elementName)Create a |
| public static Parameters | Returns: ThisParameters instance.the Properties properties)Create a |
| public String[] | |
| public String | Returns: the value of parameterthe name of parameter name)Retrieve the |
| public String | Returns: the value of parameterthe name of parameter name, final String the default value, returned if parameter does not exist
or parameter's name is null defaultValue)Retrieve the |
| public boolean | Returns: the valuethe parameter name name)Retrieve the |
| public boolean | Returns: the valuethe parameter name name, final boolean the default value if parameter does not exist or is of wrong type defaultValue)Retrieve the |
| public float | Returns: the valuethe parameter name name)Retrieve the |
| public float | Returns: the valuethe parameter name name, final float the default value if parameter does not exist or is of wrong type defaultValue)Retrieve the |
| public int | Returns: the integer parameter typethe name of parameter name)Retrieve the |
| public int | Returns: the integer parameter typethe name of parameter name, final int value returned if parameter does not exist or is of wrong type defaultValue)Retrieve the |
| public long | Returns: the long parameter typethe name of parameter name)Retrieve the |
| public long | Returns: the long parameter typethe name of parameter name, final long value returned if parameter does not exist or is of wrong type defaultValue)Retrieve the |
| public Iterator | Returns: a iterator of parameter names
Deprecated
Use getNames() instead
Return an Iterator view of all parameter names.
|
| public int | Returns: a hashed value of the instanceOverrides java. |
| public boolean | Returns: true if parameter is a namethe parameter name name)Test if the specified parameter can be retrieved. |
| public void | makeReadOnly()
Make this Parameters read-only so that it will throw a
|
| public Parameters | Returns: ThisParameters instance.the other Parameters other)Merge parameters from another |
| private int | |
| private long | |
| public void | |
| public String | Returns: The previous value of the parameter or null.a name, final String String valuea value)String valueSet the |
| public static Properties | Returns: aProperties instancea params)Parameters instanceCreates a |
| public String |
| EMPTY_PARAMETERS | back to summary |
|---|---|
| public static final Parameters EMPTY_PARAMETERS Empty Parameters object
| |
| m_parameters | back to summary |
|---|---|
| private Map<K, V> m_parameters | |
| m_readOnly | back to summary |
|---|---|
| private boolean m_readOnly | |
| Parameters | back to summary |
|---|---|
| public Parameters() | |
| checkWriteable | back to summary |
|---|---|
| protected final void checkWriteable() throws IllegalStateException Checks is this
| |
| equals | back to summary |
|---|---|
| public boolean equals(Object other) Overrides java. Compare this parameters instance with the supplied object for equality. The equality is mainly driven by the underlying HashMap which forms the basis of the class. I.e. if the underlying HashMaps are equal and the Readonly attributes are equal in the Parameters instances being compared, then this method returns equality.
| |
| fromConfiguration | back to summary |
|---|---|
| public static Parameters fromConfiguration(final Configuration configuration) throws ConfigurationException Create a
Parameters.fromConfiguration(configuration, "parameter");
| |
| fromConfiguration | back to summary |
|---|---|
| public static Parameters fromConfiguration(final Configuration configuration, final String elementName) throws ConfigurationException Create a
| |
| fromProperties | back to summary |
|---|---|
| public static Parameters fromProperties(final Properties properties) Create a
| |
| getNames | back to summary |
|---|---|
| public String[] getNames() Retrieve an array of all parameter names.
| |
| getParameter | back to summary |
|---|---|
| public String getParameter(final String name) throws ParameterException Retrieve the If the specified parameter cannot be found, an exception is thrown.
| |
| getParameter | back to summary |
|---|---|
| public String getParameter(final String name, final String defaultValue) Retrieve the
If the specified parameter cannot be found, | |
| getParameterAsBoolean | back to summary |
|---|---|
| public boolean getParameterAsBoolean(final String name) throws ParameterException Retrieve the If the specified parameter cannot be found, an exception is thrown.
| |
| getParameterAsBoolean | back to summary |
|---|---|
| public boolean getParameterAsBoolean(final String name, final boolean defaultValue) Retrieve the
If the specified parameter cannot be found,
| |
| getParameterAsFloat | back to summary |
|---|---|
| public float getParameterAsFloat(final String name) throws ParameterException Retrieve the If the specified parameter cannot be found, an exception is thrown.
| |
| getParameterAsFloat | back to summary |
|---|---|
| public float getParameterAsFloat(final String name, final float defaultValue) Retrieve the
If the specified parameter cannot be found,
| |
| getParameterAsInteger | back to summary |
|---|---|
| public int getParameterAsInteger(final String name) throws ParameterException Retrieve the 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.
| |
| getParameterAsInteger | back to summary |
|---|---|
| public int getParameterAsInteger(final String name, final int defaultValue) Retrieve the
If the specified parameter cannot be found,
| |
| getParameterAsLong | back to summary |
|---|---|
| public long getParameterAsLong(final String name) throws ParameterException Retrieve the 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.
| |
| getParameterAsLong | back to summary |
|---|---|
| public long getParameterAsLong(final String name, final long defaultValue) Retrieve the
If the specified parameter cannot be found,
| |
| getParameterNames | back to summary |
|---|---|
| public Iterator Deprecated Use getNames() instead Return an
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Returns a hashed value of the Parameters instance. This method returns a semi-unique value for all instances, yet an identical value for instances where equals() returns true.
| |
| isParameter | back to summary |
|---|---|
| public boolean isParameter(final String name) Test if the specified parameter can be retrieved.
| |
| makeReadOnly | back to summary |
|---|---|
| public void makeReadOnly() Make this Parameters read-only so that it will throw a
| |
| merge | back to summary |
|---|---|
| public Parameters merge(final Parameters other) Merge parameters from another
| |
| parseInt | back to summary |
|---|---|
| private int parseInt(final String value) throws NumberFormatException Parses string represenation of the Hexadecimal numbers begin with 0x, Octal numbers begin with 0o and binary numbers begin with 0b, all other values are assumed to be decimal.
| |
| parseLong | back to summary |
|---|---|
| private long parseLong(final String value) throws NumberFormatException Parses string represenation of the Hexadecimal numbers begin with 0x, Octal numbers begin with 0o and binary numbers begin with 0b, all other values are assumed to be decimal.
| |
| removeParameter | back to summary |
|---|---|
| public void removeParameter(final String name) Remove a parameter from the parameters object
| |
| setParameter | back to summary |
|---|---|
| public String setParameter(final String name, final String value) throws IllegalStateException Set the If the specified value is null the parameter is removed.
| |
| toProperties | back to summary |
|---|---|
| public static Properties toProperties(final Parameters params) Creates a
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object.
| |