public class ParameterStore
extends java.lang.Object
Storage for parameters, providing a common interface for retriving them. Properties will be
provided after construction and can be accessed via getIntValue(String),
getIntValue(String, int), getLongValue(String),
getLongValue(String, long), getDoubleValue(String),
getDoubleValue(String, double), getStringValue(String) and
getStringValue(String, String).
| Modifier and Type | Class and Description |
|---|---|
static class |
ParameterStore.ParameterException
Exception type that indicates an error with one of the parameters.
|
| Constructor and Description |
|---|
ParameterStore()
Construct a
ParameterStore with the parameters to be provided later from
initialize(Properties). |
ParameterStore(java.util.Properties properties)
Constructs a new
ParameterStore with the parameters used for backing, or null
if it is desired to set the parameters later using initialize(Properties). |
| Modifier and Type | Method and Description |
|---|---|
boolean |
getBoolValue(java.lang.String key)
Returns a boolean value parameter for the given key.
|
boolean |
getBoolValue(java.lang.String key,
boolean defaultVal)
Returns a boolean value parameter for the given key.
|
double |
getDoubleValue(java.lang.String key)
Returns a double value parameter for the given key.
|
double |
getDoubleValue(java.lang.String key,
double defaultVal)
Returns a double value parameter for the given key.
|
int |
getIntValue(java.lang.String key)
Returns an int value parameter for the given key.
|
int |
getIntValue(java.lang.String key,
int defaultVal)
Returns an int value parameter for the given key.
|
long |
getLongValue(java.lang.String key)
Returns a long value parameter for the given key.
|
long |
getLongValue(java.lang.String key,
long defaultVal)
Returns a long value parameter for the given key.
|
java.util.Map<java.lang.String,java.lang.String> |
getPossibleParameters()
This is an optional function to override.
|
java.lang.String |
getStringValue(java.lang.String key)
Returns a string value parameter for the given key.
|
java.lang.String |
getStringValue(java.lang.String key,
java.lang.String defaultVal)
Returns a String value parameter for the given key.
|
static java.util.Properties |
parseProperties(java.lang.String[] args,
int offset,
int length)
Parse the parameters from an array of String arguments.
|
public ParameterStore()
ParameterStore with the parameters to be provided later from
initialize(Properties).public ParameterStore(java.util.Properties properties)
ParameterStore with the parameters used for backing, or null
if it is desired to set the parameters later using initialize(Properties).properties - Properties to load parameters frompublic static java.util.Properties parseProperties(java.lang.String[] args,
int offset,
int length)
key=value. Any '=' signs in the keys or values are unexpected and
may cause issues.args - Array of arguments to parse throughoffset - Offset into array to start parsing fromlength - Number of elements which should be inspectedpublic java.util.Map<java.lang.String,java.lang.String> getPossibleParameters()
ScriptRunner. This provides documentation for what parameters are used by this
builder. If someone fails to provide a parameter this will be displayed to the CLI so that
it makes it easier to know what was missing. This is triggered by throwing
ParameterStore.ParameterException.
This map is structured such that the key represents the parameter key. The value is an
optional description to describe what the key represents.public boolean getBoolValue(java.lang.String key)
ParameterStore.ParameterException will be thrown. If the parameter may or may not exist use
getBoolValue(String, boolean). If unable to parse the boolean for the key a
ParameterStore.ParameterException. It is expected that the string value to represent the
boolean will be either "true" or "false".key - Key to lookup the boolean value frompublic int getIntValue(java.lang.String key)
ParameterStore.ParameterException will be thrown. If the parameter may or may not exist use
getIntValue(String, int). If unable to parse the integer for the key a
ParameterStore.ParameterException will be thrown with a NumberFormatException being the
cause.key - Key to lookup the integer value frompublic long getLongValue(java.lang.String key)
ParameterStore.ParameterException will be thrown. If the parameter may or may not exist use
getLongValue(String, long). If unable to parse the long for the key a
ParameterStore.ParameterException will be thrown with a NumberFormatException being the
cause.key - Key to lookup the long value frompublic double getDoubleValue(java.lang.String key)
ParameterStore.ParameterException will be thrown. If the parameter may or may not exist use
getDoubleValue(String, double). If unable to parse the double for the key a
ParameterStore.ParameterException will be thrown with a NumberFormatException being the
cause.key - Key to lookup the long value frompublic java.lang.String getStringValue(java.lang.String key)
ParameterStore.ParameterException will be thrown. If the parameter may or may not exist use
getStringValue(String, String).key - Key to lookup the String value frompublic boolean getBoolValue(java.lang.String key,
boolean defaultVal)
ParameterStore.ParameterException. It is expected that the string value to represent the
boolean will be either "true" or "false".key - Key to lookup the boolean value fromdefaultVal - Value to be returned if there is no value for the keypublic int getIntValue(java.lang.String key,
int defaultVal)
ParameterStore.ParameterException will be thrown with a NumberFormatException being the
cause.key - Key to lookup the integer value fromdefaultVal - Value to be returned if there is no value for the keypublic long getLongValue(java.lang.String key,
long defaultVal)
ParameterStore.ParameterException will be thrown with a NumberFormatException being the
cause.key - Key to lookup the long value fromdefaultVal - Value to be returned if there is no value for the keypublic double getDoubleValue(java.lang.String key,
double defaultVal)
ParameterStore.ParameterException will be thrown with a NumberFormatException being the
cause.key - Key to lookup the double value fromdefaultVal - Value to be returned if there is no value for the keypublic java.lang.String getStringValue(java.lang.String key,
java.lang.String defaultVal)
key - Key to lookup the string value fromdefaultVal - Value to be returned if there is no value for the key