|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectbyucc.jhdl.apps.util.Properties
This class provides a central location for storing and retrieving global properties for CVT-related applications and components. The static methods of this class provide a simplified interface for creating and retrieving property values. Properties are identified by a string. Components should take care to make new property identifiers unique; the simplest way to do that would be to prepend the fully-qualified class name of the component that creates the property (e.g. byucc.jhdl.apps.Viewers.Schematic.SchematicCanvas:printing-fit-to-page). Various types of property values are supported: String, boolean, number (integer or double), multiple choice string.
This class is convenient for sharing property information
between components. For example, the command line interpreter
could be used to set properties that would then affect the way GUI
components behave. For such cases of property sharing, it may be
useful to have one class responsible for determining the name of
the property and have that name stored in a public static
final String
field.
Field Summary | |
static java.lang.String |
CLI_GET
The CLI command for getting property values |
static java.lang.String |
CLI_SET
The CLI command for setting properties |
static int |
TYPE_BOOLEAN
Used to indicate a property is a boolean type |
static int |
TYPE_DOUBLE
Used to indicate a property is a double type |
static int |
TYPE_INTEGER
Used to indicate a property is a integer type |
static int |
TYPE_MULTIPLE_CHOICE
Used to indicate a property is a multiple choice type |
static int |
TYPE_STRING
Used to indicate a property is a String type |
static int |
TYPE_UNDEFINED
Used to indicate a property type is undefined |
Method Summary | |
static CLInterpreter |
getInterpreter()
|
static java.lang.String[] |
getMultipleChoiceOptions(java.lang.String property)
Returns the possible choices for a multiple choice property. |
static java.lang.String |
getProperty(java.lang.String identifier)
Returns a string representation of the value of the property associated with the given identifier |
static java.lang.String |
getProperty(java.lang.String identifier,
java.lang.String defaultValue)
Returns a string representation of the value of the property associated with the given identifier, if the property is not set, then the property is set to given defaultValue value and that value is returned |
static boolean |
getPropertyBoolean(java.lang.String identifier)
No matter what, this method attempts to parse the value of the property identified as if it is a boolean |
static boolean |
getPropertyBoolean(java.lang.String identifier,
boolean defaultValue)
No matter what, this method attempts to parse the value of the property identified as if it is a boolean. |
static boolean |
getPropertyBoolean(java.lang.String identifier,
java.lang.String defaultValue)
No matter what, this method attempts to parse the value of the property identified as if it is a boolean. |
static double |
getPropertyDouble(java.lang.String identifier)
No matter what, this method attempts to parse the value of the property identified as if it is a double. |
static double |
getPropertyDouble(java.lang.String identifier,
double defaultValue)
No matter what, this method attempts to parse the value of the property identified as if it is a double. |
static double |
getPropertyDouble(java.lang.String identifier,
java.lang.String defaultValue)
No matter what, this method attempts to parse the value of the property identified as if it is a double. |
static int |
getPropertyInteger(java.lang.String identifier)
No matter what, this method attempts to parse the value of the property identified as if it is an integer |
static int |
getPropertyInteger(java.lang.String identifier,
int defaultValue)
No matter what, this method attempts to parse the value of the property identified as if it is an integer |
static int |
getPropertyInteger(java.lang.String identifier,
java.lang.String defaultValue)
No matter what, this method attempts to parse the value of the property identified as if it is an integer |
static java.lang.String |
getPropertyMultipleChoice(java.lang.String identifier)
Returns the selected value of a multiple choice list property. |
static java.lang.String |
getPropertyMultipleChoice(java.lang.String identifier,
java.lang.String defaultValue)
Returns the selected value of a multiple choice list property. |
static java.lang.String |
getPropertyMultipleChoice(java.lang.String identifier,
java.lang.String defaultValue,
java.lang.String[] defaultOptions)
Returns the selected value of a multiple choice list property. |
static int |
getPropertyType(java.lang.String identifier)
Returns the type of the property associated with the given identifier |
static void |
printProperties(CLInterpreter interp)
Displays the currently set properties on the output component of the given interpreter. |
static boolean |
propertyExists(java.lang.String identifier)
|
static void |
setInterpreter(CLInterpreter theInterpreter)
Use this method to set up the CLI commands for Properties |
static void |
setProperty(java.lang.String identifier,
java.lang.String value)
Sets the property for the given identifier to the given value. |
static void |
setPropertyBoolean(java.lang.String identifier,
boolean value)
Sets the property for the given identifier to the given value. |
static void |
setPropertyBoolean(java.lang.String identifier,
java.lang.String value)
Sets the property for the given identifier to the given value. |
static void |
setPropertyDouble(java.lang.String identifier,
double value)
Sets the property for the given identifier to the given value. |
static void |
setPropertyDouble(java.lang.String identifier,
java.lang.String value)
Sets the property for the given identifier to the given value. |
static void |
setPropertyInteger(java.lang.String identifier,
int value)
Sets the property for the given identifier to the given value. |
static void |
setPropertyInteger(java.lang.String identifier,
java.lang.String value)
Sets the property for the given identifier to the given value. |
static void |
setPropertyMultipleChoice(java.lang.String identifier,
java.lang.String value)
Sets the property for the given identifier to the given value. |
static void |
setPropertyMultipleChoice(java.lang.String identifier,
java.lang.String[] options)
This method creates (or overwrites) a multiple choice property with the given options. |
static void |
setPropertyMultipleChoice(java.lang.String identifier,
java.lang.String[] options,
java.lang.String value)
This method creates (or overwrites) a multiple choice property with the given options. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int TYPE_STRING
public static final int TYPE_BOOLEAN
public static final int TYPE_INTEGER
public static final int TYPE_DOUBLE
public static final int TYPE_MULTIPLE_CHOICE
public static final int TYPE_UNDEFINED
public static java.lang.String CLI_SET
public static java.lang.String CLI_GET
Method Detail |
public static boolean propertyExists(java.lang.String identifier)
public static CLInterpreter getInterpreter()
public static java.lang.String[] getMultipleChoiceOptions(java.lang.String property)
public static java.lang.String getProperty(java.lang.String identifier)
identifier
- the name of the property
public static java.lang.String getProperty(java.lang.String identifier, java.lang.String defaultValue)
identifier
- the name of the propertydefaultValue
- the value to fall back on if the property hasn't
been set yet
public static boolean getPropertyBoolean(java.lang.String identifier)
identifier
- the name of the property to look up
public static boolean getPropertyBoolean(java.lang.String identifier, boolean defaultValue)
identifier
- the name of the property to look updefaultValue
- value to fall back on if the property isn't set
public static boolean getPropertyBoolean(java.lang.String identifier, java.lang.String defaultValue)
identifier
- the name of the property to look updefaultValue
- value to fall back on if the property isn't set
public static double getPropertyDouble(java.lang.String identifier)
identifier
- the name of the property to look up
java.lang.NumberFormatException
- if the value is not actually a
doublepublic static double getPropertyDouble(java.lang.String identifier, double defaultValue)
identifier
- the name of the property to look updefaultValue
- the value to fall back on if the property
isn't set.
java.lang.NumberFormatException
- if the current value is not
actually a double.public static double getPropertyDouble(java.lang.String identifier, java.lang.String defaultValue)
identifier
- the name of the property to look updefaultValue
- the value to fall back on if the property
isn't set.
java.lang.NumberFormatException
- if the current value is not
actually a double.public static int getPropertyInteger(java.lang.String identifier)
identifier
- the name of the property to look up
java.lang.NumberFormatException
- if the value is not actually an
integerpublic static int getPropertyInteger(java.lang.String identifier, int defaultValue)
identifier
- the name of the property to look up.defaultValue
- value to fall back on if the property isn't
set.
java.lang.NumberFormatException
- if the current value is not
actually an integer.public static int getPropertyInteger(java.lang.String identifier, java.lang.String defaultValue)
identifier
- the name of the property to look up.defaultValue
- value to fall back on if the property isn't
set.
java.lang.NumberFormatException
- if the current value is not
actually an integer.public static java.lang.String getPropertyMultipleChoice(java.lang.String identifier)
identifier
- the name of the property to look up.
public static java.lang.String getPropertyMultipleChoice(java.lang.String identifier, java.lang.String defaultValue)
identifier
- the name of the property to look up.defaultValue
- the value to fall back on if and only if the
property hasn't been set yet. The property will be set to
defaultValue if that is the case, and defaultValue will be the
only available option listed in the property.
public static java.lang.String getPropertyMultipleChoice(java.lang.String identifier, java.lang.String defaultValue, java.lang.String[] defaultOptions)
identifier
- the name of the property to look up.defaultValue
- the value to fall back on if and only if the
property hasn't been set yet. The property selection will be set
to defaultValue if that is the case.defaultOptions
- if, and only if, the property hasn't been
set yet, then these options will be the set of options for the
property.
public static int getPropertyType(java.lang.String identifier)
identifier
- the name of the property
public static void printProperties(CLInterpreter interp)
interp
- the interpreter that will print the propertiespublic static void setInterpreter(CLInterpreter theInterpreter)
public static void setProperty(java.lang.String identifier, java.lang.String value)
identifier
- the name of the property to setvalue
- the value to set the property topublic static void setPropertyBoolean(java.lang.String identifier, boolean value)
identifier
- the name of the property to setvalue
- the value to set the property topublic static void setPropertyBoolean(java.lang.String identifier, java.lang.String value)
identifier
- the name of the property to setvalue
- the value to set the property to. In order for it
to be correctly interpreted as TRUE, it should be one of
"true", "on", or "1".public static void setPropertyDouble(java.lang.String identifier, double value)
identifier
- the name of the property to setvalue
- the value to set the property topublic static void setPropertyDouble(java.lang.String identifier, java.lang.String value)
identifier
- the name of the property to setvalue
- the value to set the property to
java.lang.NumberFormatException
- if the value is not a valid
double stringpublic static void setPropertyInteger(java.lang.String identifier, int value)
identifier
- the name of the property to set.value
- the value to set the property topublic static void setPropertyInteger(java.lang.String identifier, java.lang.String value)
identifier
- the name of the property to set.value
- the value to set the property to; can be
prefixed with 0x, 0d, 0o, or 0b for hexadecimal, decimal, octal,
or binary numbers respectively.
java.lang.NumberFormatException
- if the value is not a valid
integer stringpublic static void setPropertyMultipleChoice(java.lang.String identifier, java.lang.String value)
The selection is set to the given value. If that value is not already in the list of options, it is added to the end of the list.
identifier
- the name of the property to setvalue
- the value to set the property topublic static void setPropertyMultipleChoice(java.lang.String identifier, java.lang.String[] options)
identifier
- the name of the new (or overwritten) propertyoptions
- the possible options for the propertypublic static void setPropertyMultipleChoice(java.lang.String identifier, java.lang.String[] options, java.lang.String value)
identifier
- the name of the new (or overwritten) propertyoptions
- the possible options for the property. It is up
to the user to determine the order and uniqueness of the
entries. Note that LIST_DELIMETER ('@') is not allowed to appear
in the options.value
- the current selection for the property. NOTE: no
effort is made to ensure that the given value is one of the
options listed in the given array of String; therefore, this may
be a way of setting the multiple choice property to a value that
is not a default choice.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |