public abstract class Property extends Object
For example:
class MyProperties extends Properties {
public final IntegerProperty DebugLevel =
new IntegerProperty(this, "com.acme.debugLevel", 10);
}
MyProperties props = new MyProperties();
System.out.println(props.DebugLevel.get()); // prints "10", the default
props.DebugLevel.set(20);
System.out.println(props.DebugLevel.get()); // prints "20"
| Modifier and Type | Field and Description |
|---|---|
protected Properties |
properties |
| Modifier | Constructor and Description |
|---|---|
protected |
Property(Properties properties,
String path,
String defaultValue)
Creates a Property and associates it with an underlying properties
object.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addTrigger(Trigger trigger)
Adds a trigger to this property.
|
boolean |
booleanValue()
Returns the boolean value of this property.
|
String |
getDefaultValue()
Returns the default value of this property.
|
protected String |
getInternal(String defaultValue,
boolean required)
Retrieves the value of a property, using a given default value, and
optionally failing if there is no value.
|
String |
getPath()
Returns the name of this property.
|
String |
getString()
Returns the value of this property as a string.
|
boolean |
isSet()
Returns whether this property has a value assigned.
|
void |
onChange(String oldValue,
String value)
Called when a property's value has just changed.
|
void |
removeTrigger(Trigger trigger)
Removes a trigger from this property.
|
String |
setString(String value)
Sets a property directly as a string.
|
String |
stringValue()
Returns the value of the property as a string, or null if the property is
not set.
|
static boolean |
toBoolean(String value)
Converts a string to a boolean.
|
protected final Properties properties
protected Property(Properties properties, String path, String defaultValue)
properties - Properties object which holds values for this property.path - Name by which this property is serialized to a properties
file, for example "com.acme.trace.Verbosity".defaultValue - Default value, null if there is no default.public String getPath()
public String getDefaultValue()
protected String getInternal(String defaultValue, boolean required)
public void addTrigger(Trigger trigger)
public void removeTrigger(Trigger trigger)
public void onChange(String oldValue, String value)
If one of the triggers on the property throws a Trigger.VetoRT exception, this method passes
it on.
oldValue - Previous value of the propertyvalue - New value of the propertyTrigger.VetoRT - if one of the triggers
threw a VetoRTpublic String setString(String value)
public boolean isSet()
public String getString()
public boolean booleanValue()
public static boolean toBoolean(String value)
Note that Boolean.parseBoolean(String) is similar, but only
exists from JDK 1.5 onwards, and only accepts 'true'.
public String stringValue()
Copyright © 2012–2015 Julian Hyde. All rights reserved.