Last Updated: 3/4/97
Class NFParam
Class NFParam
public class NFParam
Final Variables
|
Type |
|
Name |
|
Description |
|
int |
|
COLOR |
|
|
|
int |
|
DATE |
|
|
|
int |
|
FILE |
|
|
|
int |
|
IMAGE |
|
|
|
int |
|
JDBC |
|
|
|
int |
|
NUMBER |
|
|
|
int |
|
PARAM |
|
|
|
int |
|
STRING |
|
|
|
int |
|
SYMBOL |
|
|
|
int |
|
TUPLE |
|
|
|
int |
|
VECTOR |
|
|
Constructors
Methods
- addObserver (Observer observer)
- changed (String param)
- defineColor (String param)
- defineColor (String param, Color color)
- defineDate (String param)
- defineDate (String param, Object obj)
- defineImage (String param)
- defineImage (String param, URL url)
- defineJDBC (String param)
- defineNumber (String param)
- defineNumber (String param, Number val)
- defineString (String param)
- defineString (String param, String val)
- defineSymbol (String param, Hashtable symtable)
- defineSymbol (String param, Hashtable symtable, Object val)
- defineTuple (String param, Vector defs)
- defineVector (String param, NFParamDef item)
- exists (String param)
- fileDone (URL url, Object info, int rowCount) throws Exception
- fileInit (URL url, Object info) throws Exception
- fileRow (URL url, Object info, int rowNum, Vector row) throws Exception
- get (String param) throws Exception
- getChildKeys(String parentName) throws Exception
- getColor(String colorName)
- getFileURL (String filename) throws Exception
- getKeys()
- getSymbolKeys(String symbolName) throws Exception
- getType(String param) throws Exception
- loadParams () throws Exception
- loadParams (String expr) throws Exception
- loadParams (String host, int port, String args) throws Exception
- loadParams (URL url) throws Exception
- remove (String param)
- setApp (Applet app)
- setChanged(String param)
- start()
- stop()
- toString (NFParamDef def, Object val)
- toString (String param) throws Exception
- toString (String param, Object val) throws Exception
- update ()
- valueToKey(String param, Object val) throws Exception
NFParam ()
-
Create a new parameter parser, with no associated applet.
-
NFParam (Applet app)
-
Create a new parameter parser.
-
void addObserver (Observer observer)
-
Add the given observer to the list of observers for this
object. Whenever an "Update" command is parsed, all observers
will be notified via their update() method. The specific
parameter sent to the observer will be "LoadParams"
-
boolean changed (String param)
-
Returns true if the parameter has been changed since
"get" was last called.
-
NFParamDef defineColor (String param)
-
Define a Color parameter.
The default value is WHITE.
-
NFParamDef defineColor (String param,
Color color)
-
Define a Color parameter with the given default color.
-
NFParamDef defineDate (String param)
-
Define a Date parameter.
-
NFParamDef defineDate (String param,
Object obj)
-
Define a Date parameter, with the given default object
which may be any of the following types:
-
NFDate
NFTimeUnit
Number
-
NFParamDef defineImage (String param)
-
Define a Image parameter with the given image URL.
-
NFParamDef defineImage (String param,
URL url)
-
Define an Image parameter with the given image URL.
-
NFParamDef defineJDBC (String param)
-
Define an Jdbc parameter.
-
NFParamDef defineNumber (String param)
-
Define a Number parameter, with a null initial value.
-
NFParamDef defineNumber (String param,
Number val)
-
Define a Number parameter, with a given initial value.
-
NFParamDef defineString (String param)
-
Define a String parameter, with a null initial value.
-
NFParamDef defineString (String param,
String val)
-
Define a String parameter, with a given initial value.
-
NFParamDef defineSymbol (String param,
Hashtable symtable)
-
Define a Symbol parameter, with the given SYMTABLE
containing all valid keywords and their associated
values. The initial value is set to null.
-
NFParamDef defineSymbol (String param,
Hashtable symtable,
Object val)
-
Define a Symbol parameter, with the given SYMTABLE
containing all valid keywords and their associated
values. Use VAL as the initial value.
-
NFParamDef defineTuple (String param,
Vector defs)
-
This method defines the parameter as a tuple (one or more
elements). The <defs> vector should contain a NFParamDef object
for each of the elements in the tuple. For example, the
following code:
-
Vector tuple = new Vector();
-
tuple.addElement (defineString ("Fred1"));
tuple.addElement (defineNumber ("Fred2"));
tuple.addElement (defineSymbol ("Fred3",
new Hashtable()));
-
defineTuple ("Fred", tuple);
-
defines a three-element tuple for the "Fred" parameter, in which
the first element is a String, the second is a Number and the
third is a Symbol, with an empty symbol table.
-
When parsed, the tuple elements may be separated by whitespace
or commas. Leading and trailing parenthesis are optional, except
when a tuple is contained within a vector, then they are mandatory.
-
void defineVector (String param,
NFParamDef item)
-
Define a vector of values for the given parameter. When this
parameter is parsed, one or more values can be defined separated
by commas. The definition for each item is defined by the <item>
parameter.
-
For example, the following code:
-
Vector tuple = new Vector();
-
tuple.addElement (defineString ("Fred1"));
tuple.addElement (defineNumber ("Fred2"));
-
defineVector ("Fred", defineTuple ("FredItem", tuple));
-
defines a vector for the "Fred" parameter, in which each element
is a two-item tuple, containing a String and a Number.
-
The following code:
-
defineVector ("Sally", defineString ("SallyItem"));
-
defines a vector of String items named "Sally".
boolean exists (String param)
-
Returns true if the parameter has been defined.
void fileDone (URL url,
Object info,
int rowCount) throws Exception
-
This method is called after all rows have been processed
in a data file referenced by the FILE keyword.
-
void fileInit (URL url,
Object info) throws Exception
-
This method is called when a data file has been opened
as the result of the FILE keyword being specified. It is
called prior to any fileRow() calls for each file processed.
-
void fileRow (URL url,
Object info,
int rowNum,
Vector row) throws Exception
-
This method is called for each row of data parsed from a
file referenced by the FILE keyword. The rowNum parameter
starts at 1.
-
Object get (String param) throws Exception
-
Returns the value of the given parameter.
-
An exception is thrown if the parameter is not defined.
A null value is returned if the value has not be set.
-
Vector getChildKeys(String parentName) throws Exception
-
Return a list of all the parameters defined within a TUPLE or
VECTOR.
-
Color getColor(String colorName)
-
Returns a color for the given colorname.
-
final static URL getFileURL (String filename) throws Exception
-
This method has been obsoleted. See NFUtil.getFileURL()
-
Enumeration getKeys()
-
Returns a list of all the keys in the parameter hashtable
-
Enumeration getSymbolKeys(String symbolName) throws Exception
-
Returns the possible values for the given symbol.
-
int getType(String param) throws Exception
-
Returns the type of parameter
-
boolean loadParams () throws Exception
-
Parse all parameters defined within the <applet> tag of
the invoking HTML file. If a parameter is defined in the
<applet> but it is not defined within this parser, it is
ignored.
-
If any of the following special parameters are defined in the
<applet> tag, they will be processed AFTER all of the named
parameters defined in the HTML.
-
name=NFParamURL value="URL"
The given URL is accessed and all values are loaded.
This can be used to override or set values across a
collection of applets, using a standard file located
anywhere on the network. Any relative path name
specified for the URL is processed relative to the
DocumentBase.
-
name=NFParamScript value="script of parameter definitions"
The given string is parsed and all values are loaded.
Note, if an undefined parameter is referenced in the
script, then an exception is generated. All script
parameters are loaded AFTER any URL is processed.
-
name=NFParamServer value="hostname:port/arguments"
A connection is made to the given host and port, which
is assumed to be a daemon that generates parameter
statements. The statements are processed by a separate
thread. The "Update" command can be used within the
stream of parameters generated to cause all observers to
be notified. Normally, such a notification would cause
the display to be updated. Upon notification, the
string "LoadParams" will be passed to the observers.
Everything following the "/" in the parameter string
will be passed to the parameter server upon connection,
terminated with a newline character. That allows the
server to determine the specific data required for this
connection. Server connections are made AFTER both URLs
and scripts have been processed.
-
boolean loadParams (String expr) throws Exception
-
Loads all parameters defined by the given parameter expression.
This can be used to dynamically alter any number of parameters
per call. NOTE: The update() method should be called to notify
all observers of this NFParam object when a group of parameters
have been re-defined, in order to have those new parameters take
effect.
-
void loadParams (String host,
int port,
String args) throws Exception
-
Load all parameters defined asychronously by an NFParamServer
described by the given parameters. The given <args> string will
be sent to the NFParamServer when initially connected. From
that point, the NFParamServer can generate any number of
parameter expressions, which will be parsed by a background
thread. Whenever an "Update" command is sent, any observers of
the NFParam object will be notified, which generally means that
the display will be updated, using the new parameter definitions
received since the last "Update".
-
NOTE: Netscape 2.0 prevents a connection to an NFParamServer if
on any machine, if the HTML document that invokes the applet is
accessed as a local disk file, as opposed to an HTTP server
response.
-
NOTE2: Parameters will only be read from the server once the
calling applet has called the NFParam object's "start" method.
-
boolean loadParams (URL url) throws Exception
-
Process the given URL and load all parameters defined by it.
-
void remove (String param)
-
Removes the given parameter from the parameter table
-
void setApp (Applet app)
-
Set the app for the parameter parser.
-
void setChanged(String param)
-
"tickles" the given parameter to indicate that clients should
reread the parameter.
void start()
-
This method is called to start separate threads for each
parameter server connection currently specified.
-
void stop()
-
This method is called to stop all current parameter server
threads. The threads may be restarted by calling the start()
method.
-
String toString (NFParamDef def,
Object val)
-
Returns a string representing the given value,
assuming the given definition.
-
String toString (String param) throws Exception
-
Returns a string representing the current value of
the given parameter.
-
String toString (String param,
Object val) throws Exception
-
Returns a string representing the current value of
the given parameter.
-
void update ()
-
This method should be called whenever a batch of parameters
have been changed in order to notify all of the observers
for the current NFParam object. Generally, this results in
the display being redrawn, using the new parameter values.
-
Object valueToKey(String param,
Object val) throws Exception
-
Maps the given object back to its name within the symbol table
indicated by "param".
-