public class BootProperties extends Properties
Properties
class that knows how to pull
properties settings out of the command line and also provides a friendlier
interface to the values of the properties settings themselves.defaults
Constructor and Description |
---|
BootProperties()
Creates an empty property collection with no default values.
|
BootProperties(Properties defaults)
Creates an empty property collection with the specified defaults.
|
Modifier and Type | Method and Description |
---|---|
boolean |
boolProperty(String property,
boolean defaultValue)
Get the value of a property as a boolean.
|
double |
doubleProperty(String property,
double defaultValue)
Get the value of a property as a double.
|
int |
intProperty(String property,
int defaultValue)
Get the value of a property as an integer.
|
String[] |
scanArgs(String[] inArgs)
Read properties files and parse property settings from the command line.
|
boolean |
testProperty(String property)
Test the setting of a boolean property.
|
boolean |
testProperty(String property,
String possibleValue)
Test if the value of a property is a particular string.
|
getProperty, getProperty, list, list, load, load, loadFromXML, propertyNames, save, setProperty, store, store, storeToXML, storeToXML, stringPropertyNames
public BootProperties()
public BootProperties(Properties defaults)
defaults
- A set of properties to use as a default initializer.public boolean boolProperty(String property, boolean defaultValue)
property
- The name of the property to test.defaultValue
- The default value in the event of absence or error.IllegalArgumentException
- if the property has a value that is
neither of the strings "true" nor "false".public double doubleProperty(String property, double defaultValue)
property
- The name of the property of interest.defaultValue
- The default value in the event of absence or error.public int intProperty(String property, int defaultValue)
property
- The name of the property of interest.defaultValue
- The default value in the event of absence or error.public String[] scanArgs(String[] inArgs) throws IOException
key=val
The property named key is given the value val.-nodefaults
Suppress reading ~/.propsrc for further property definitions.-properties filename
File filename is read for further property definitions.anythingelse
The argument is added to the returned arguments array.
inArgs
- The raw, unprocessed command line arguments array.IOException
- when a file from which it is supposed to read
further properties does not exist or cannot be read. However, if any
of the default properties files do not exist, their
non-existence is silently ignored rather than causing an exception.
On the other hand, if they do exist but simply aren't
readable, an exception is thrown as for any other properties file.public boolean testProperty(String property)
property
- The name of the property to test.IllegalArgumentException
- if the property has a value that is
neither of the strings "true" nor "false".public boolean testProperty(String property, String possibleValue)
property
- The name of the property to test.possibleValue
- String value to test if it is equal to.Copyright © 2017. All rights reserved.