|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface Environment
Provides a mechanism for passing parameters/preferences/properties from diverse runtime environments, including applets (via the param tag), applications (via a properties file), and sooner or later, servlets.
Cooperative programming: Any class that implements this
interface needs to include the following line of code at the top of
its initialization, in order to make the services provided by this
Environment interface globally accessible.
Environment.the.set(this);
The nested class The serves to keep a global reference
to the actual instance of the singleton class that implements Environment.
(Don't have more than 1 instance that does!)
The raison d'etre of this interface is first to allow
programs to utilize services in a uniform way, whether they are
applets or applications. The raison d'etre of the nested class
is to overcome the existence of a single java.applet.Applet
instance in the runtime environment which provides services that
conceptually, one expects to get from a static, like
java.lang.System. This is a simple mechanism that
actually does something quite complex, and for complex reasons.
Services are then available globally through syntax such as:
Environment.the.get().parameter("bgcolor");
| Nested Class Summary | |
|---|---|
static class |
Environment.The
Holds a reference to the singleton global instance of Environment, and simple methods for getting and setting
this reference. |
| Field Summary | |
|---|---|
static int |
APPLICATION
|
static int |
IE
|
static int |
NS
|
static int |
PLUGIN
|
static Environment.The |
the
Each running entity (be it an applet or an application), should have one and only one instance of an Environment. |
| Method Summary | |
|---|---|
int |
browser()
Find out which browser we're running in. |
ParsedURL |
codeBase()
Change type from URL to ParsedURL. |
ParsedURL |
docBase()
Change type from URL to ParsedURL. |
void |
exit(int code)
Called at the end of an invocation. |
java.lang.String |
lookupStringPreference(java.lang.String name)
Get a parameter or property, based on a key. |
void |
navigate(ParsedURL purl,
java.lang.String frame)
Open a document in a web browser. |
int |
runtimeEnv()
Find out which java runtime we're operating in. |
void |
status(java.lang.String msg)
Show msg in the browser's status bar. |
| Field Detail |
|---|
static final Environment.The the
static final int APPLICATION
static final int IE
static final int NS
static final int PLUGIN
| Method Detail |
|---|
int runtimeEnv()
int browser()
void status(java.lang.String msg)
msg in the browser's status bar.
Short form, with for (@link java.cm.applet.Applet#showStatus).
Also more robust: avoids breaking when msg is null.
java.lang.String lookupStringPreference(java.lang.String name)
name - The name of the key.ParsedURL codeBase()
ParsedURL docBase()
void exit(int code)
code - -- 0 for normal. other values are application specific.
void navigate(ParsedURL purl,
java.lang.String frame)
purl - The address of the web document.frame - Frame to open it in within the web page. This may or may not be used.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||