public class GrinderProperties extends Properties
Properties to add type safe accessors.
Has an optional associated file.Grinder.ScriptContext.getProperties(),
Serialized Form| Modifier and Type | Class and Description |
|---|---|
static class |
GrinderProperties.PersistenceException
Exception indicating a problem in persisting properties.
|
| Modifier and Type | Field and Description |
|---|---|
static String |
CONSOLE_HOST
Key to use for the console host property.
|
static String |
CONSOLE_PORT
Key to use for the console host property.
|
static File |
DEFAULT_PROPERTIES
Default file name for properties.
|
static File |
DEFAULT_SCRIPT
Default script file name.
|
static String |
LOG_DIRECTORY
Key to use for the log directory property.
|
static String |
SCRIPT
Key to use for the script property.
|
defaults| Constructor and Description |
|---|
GrinderProperties()
Construct an empty GrinderProperties with no associated file.
|
GrinderProperties(File file)
Construct a GrinderProperties, reading initial values from the
specified file.
|
| Modifier and Type | Method and Description |
|---|---|
File |
getAssociatedFile()
Get the associated file.
|
boolean |
getBoolean(String propertyName,
boolean defaultValue)
Get the value of the property with the given name, return the
value as a
boolean. |
double |
getDouble(String propertyName,
double defaultValue)
Get the value of the property with the given name, return the
value as a
double. |
File |
getFile(String propertyName,
File defaultValue)
Get the value of the property with the given name, return the value as a
File. |
int |
getInt(String propertyName,
int defaultValue)
Get the value of the property with the given name, return the
value as an
int. |
long |
getLong(String propertyName,
long defaultValue)
Get the value of the property with the given name, return the
value as a
long. |
GrinderProperties |
getPropertySubset(String prefix)
Return a new GrinderProperties that contains the subset of our
Properties which begin with the specified prefix.
|
short |
getShort(String propertyName,
short defaultValue)
Get the value of the property with the given name, return the
value as a
short. |
File |
resolveRelativeFile(File file)
Returns a
File representing the combined path of our associated
property file directory and the passed file. |
void |
save()
Save our properties to our file.
|
void |
saveSingleProperty(String name)
Save a single property to our file.
|
void |
setAssociatedFile(File file)
Set the associated file.
|
void |
setBoolean(String propertyName,
boolean value)
Set the property with the given name to a
boolean
value. |
void |
setDouble(String propertyName,
double value)
Set the property with the given name to a
double
value. |
void |
setErrorWriter(PrintWriter writer)
Set a writer to report warnings to.
|
void |
setFile(String propertyName,
File value)
Set the property with the given name to a
File
value. |
void |
setInt(String propertyName,
int value)
Set the property with the given name to an
int
value. |
void |
setLong(String propertyName,
long value)
Set the property with the given name to a
long
value. |
void |
setShort(String propertyName,
short value)
Set the property with the given name to a
short
value. |
getProperty, getProperty, list, list, load, load, loadFromXML, propertyNames, save, setProperty, store, store, storeToXML, storeToXML, stringPropertyNamespublic static final String SCRIPT
public static final String LOG_DIRECTORY
public static final String CONSOLE_HOST
public static final String CONSOLE_PORT
public static final File DEFAULT_PROPERTIES
public static final File DEFAULT_SCRIPT
public GrinderProperties()
public GrinderProperties(File file) throws GrinderProperties.PersistenceException
grinder."are also added to allow values to be
overridden on the command line.file - The file to read the properties from.GrinderProperties.PersistenceException - If an error occurs reading from
the file.DEFAULT_PROPERTIESpublic final File getAssociatedFile()
null if none.public final void setAssociatedFile(File file)
file - The associated file, or null if none.public final void save()
throws GrinderProperties.PersistenceException
GrinderProperties.PersistenceException - If there is no file associated
with this GrinderProperties or an I/O exception occurs..public final void saveSingleProperty(String name) throws GrinderProperties.PersistenceException
name - Property name.GrinderProperties.PersistenceException - If there is no file associated with this
GrinderProperties or an I/O exception occurs.public final void setErrorWriter(PrintWriter writer)
writer - The writer.public final GrinderProperties getPropertySubset(String prefix)
prefix - The prefix.public final int getInt(String propertyName, int defaultValue)
int.propertyName - The property name.defaultValue - The value to return if a property with the
given name does not exist or is not an integer.public final void setInt(String propertyName, int value)
int
value.propertyName - The property name.value - The value to set.public final long getLong(String propertyName, long defaultValue)
long.propertyName - The property name.defaultValue - The value to return if a property with the
given name does not exist or is not a long.public final void setLong(String propertyName, long value)
long
value.propertyName - The property name.value - The value to set.public final short getShort(String propertyName, short defaultValue)
short.propertyName - The property name.defaultValue - The value to return if a property with the
given name does not exist or is not a short.public final void setShort(String propertyName, short value)
short
value.propertyName - The property name.value - The value to set.public final double getDouble(String propertyName, double defaultValue)
double.propertyName - The property name.defaultValue - The value to return if a property with the
given name does not exist or is not a double.public final void setDouble(String propertyName, double value)
double
value.propertyName - The property name.value - The value to set.public final boolean getBoolean(String propertyName, boolean defaultValue)
boolean.propertyName - The property name.defaultValue - The value to return if a property with the
given name does not exist.public final void setBoolean(String propertyName, boolean value)
boolean
value.propertyName - The property name.value - The value to set.public final File getFile(String propertyName, File defaultValue)
File.propertyName - The property name.defaultValue - The value to return if a property with the given name does not
exist.public final File resolveRelativeFile(File file)
File representing the combined path of our associated
property file directory and the passed file.
If file is absolute, or this GrinderProperties
has no associated property file, return file.
file - The file.file resolved relative to the directory
of our associated properties file, or file.Copyright © 2000-2014. All Rights Reserved.