|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--java.util.Dictionary
|
+--java.util.Hashtable
|
+--java.util.Properties
|
+--org.omegahat.Environment.Utils.TrimmedProperties
|
+--org.omegahat.Environment.Interpreter.Options
A collection of property name-value pairs
containing String values
that provide access to some evaluator-related properties
and a general table into which arbitrary options can be added
and retrieved by other objects.
This class processes the different property values by removing leading and trailing white space when the values are set. This simplifies using the property values in many situations.
In addition to retrieving values from its own table, this class optionally allows callers to retrieve values from this or the system properties.
While it is possible, this class should probably not be considered as a location for setting values that other objects can read later in the evaluation of expressions or tasks. A more explicit communication mechanism should be considered as it is relatively easy to use the databases of an evaluator, or extend classes to provide hooks for the information. This is easier than in languages such as S, R, Matlab, etc. due to the seamless boundary between native (Java) and interpreted objects.
| Inner classes inherited from class java.util.Map |
java.util.Map.Entry |
| Field Summary | |
static int |
CONTINUE
|
static int |
CONTINUE_PROMPT
Symbolic constant identiying the continuation prompt which is used when we encounter incomplete, but valid input. |
java.lang.String |
DebugProperty
The name of the property that controls whether general debugging information is shown or not. |
static java.lang.String |
DefaultPrompt
The default prompt setting that is copied into instance-specific field of each object of this class. |
static int |
NORMAL
|
protected boolean |
parsePrompt
|
protected boolean |
parserDebug
Flag indicating whether we want debugging information regarding the parser displayed or not. |
java.lang.String |
ParserDebugProperty
The name of the property controlling whether parsing debugging information is shown. |
static int |
PROMPT
Symbolic constant identifying the normal prompt. |
| Fields inherited from class org.omegahat.Environment.Utils.TrimmedProperties |
booleanStrings, stripQuotes |
| Fields inherited from class java.util.Properties |
defaults |
| Constructor Summary | |
Options()
Initialize from the standard options list locating the file containing the properties either from the system property OMEGA_CONFIG_FILE
value or
by reading the contents of the class resource
OmegaOptions. |
|
Options(java.io.File file)
Read the properties and values from the specified File. |
|
Options(java.io.InputStream stream)
Read the property name and value pairs from the specified input stream. |
|
Options(java.lang.String text)
Read the contents of the property table from the specified string as a file and if that is not accessible, interpret the text as a collection of property name and value pairs. |
|
| Method Summary | |
java.lang.String |
getProperty(java.lang.String name)
Get the value of the specified property looking in this table first and then in the system properties table. |
java.lang.String |
getProperty(java.lang.String name,
boolean systemFirst)
Retrieve the value of the property with the given name by looking in this table or the system properties, the order of the lookup being controlled by the systemFirst argument. |
java.lang.String |
getProperty(java.lang.String name,
java.lang.String dflt,
boolean systemFirst)
Get the value of the property identified by the specified name by looking in this table or the system properties and returing the dflt value if
no value is found. |
void |
load(java.io.InputStream in)
Read the property name-value pairs from the specified input stream and process the results removing leading and trailing white space. |
boolean |
parserDebug()
|
boolean |
parserDebug(boolean val)
|
int |
processProperties()
Hook called to examine the values of the properties, setting fields, etc. |
java.lang.String |
prompt()
Retrieve the default value for the normal prompt. |
java.lang.String |
prompt(int which)
Retrieve the prompt, either the normal or continuation prompt, indicated by the symbolic constant passed as the value for which |
| Methods inherited from class org.omegahat.Environment.Utils.TrimmedProperties |
asBoolean, isBoolean, load, merge, merge, parse, processElement, processElements, stringList, stringList, stripQuotes, stripQuotes, trim |
| Methods inherited from class java.util.Properties |
getProperty, list, list, propertyNames, save, setProperty, store |
| Methods inherited from class java.util.Hashtable |
clear, clone, contains, containsKey, containsValue, elements, entrySet, equals, get, hashCode, isEmpty, keys, keySet, put, putAll, rehash, remove, size, toString, values |
| Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
public static int NORMAL
public static int CONTINUE
public java.lang.String DebugProperty
public java.lang.String ParserDebugProperty
public static final int PROMPT
public static final int CONTINUE_PROMPT
public static java.lang.String DefaultPrompt
protected boolean parserDebug
protected boolean parsePrompt
| Constructor Detail |
public Options()
OMEGA_CONFIG_FILE
value or
by reading the contents of the class resource
OmegaOptions.public Options(java.io.File file)
File.file - the file containing the property name
and values.public Options(java.lang.String text)
text - the name of a file or the text
containing the property name and value pairs.public Options(java.io.InputStream stream)
stream - the stream containing the property table.| Method Detail |
public void load(java.io.InputStream in)
load in class TrimmedPropertiespublic int processProperties()
public java.lang.String prompt()
String
which could be an expression which evaluates
to a String to be used
as the actual prompt value.public java.lang.String prompt(int which)
whichwhich - value indicating which prompt to return,
the normal or continuation prompt.NORMAL,
CONTINUE_PROMPTpublic boolean parserDebug(boolean val)
public boolean parserDebug()
public java.lang.String getProperty(java.lang.String name)
getProperty in class java.util.Properties
public java.lang.String getProperty(java.lang.String name,
boolean systemFirst)
systemFirst argument.systemFirst - control whether we look in this
table or the system properties before looking in the other.
public java.lang.String getProperty(java.lang.String name,
java.lang.String dflt,
boolean systemFirst)
dflt value if
no value is found.
Which table is examined first - the system or this -
is controlled by the argument systemFirst.name - name of the property being querieddflt - value to be used if no property is defined with the given name.systemFirst - flag indicating whether to look
in the system properties or this table first.
true indicates the system properties should be
queried before this table.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||