|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.Dictionary
java.util.Hashtable
wt.util.WTContext
This class holds static state partitioned by applet or application instance. It is a specialized Hashtable for accessing static state via thread groups which correspond to applet or application instances.
This class is useful when there is a need for semi-global static state partitioned by applet or application. Using Java static fields is insufficient for this purpose since a class loaded from the local class path will share static state among applets from all codebases, and even classes loaded from a remote codebase may share static state between multiple applets from that codebase.
During applet initialization or application startup, a call to WTContext.init
associates the calling thread group to a WTContext
object and stores associated
application arguments or the applet instance as part of the context. Later, static access is
provided by looking up the applicable WTContext
object according to the current
thread's thread group.
This class implements the AppletStub and AppletContext interfaces to provide uniform access to these methods in the context of both applications and applets. It also enables applets to be treated as reusable components by allowing a parent applet or application context to be used as the stub for a new child applet instance.
This class includes applet start
, stop
, and destroy
methods which can be used to invoke the corresponding methods on all registered listeners.
applets should use these methods so that any child applets or frames that are registered
as listeners can respond to these methods accordingly.
Since untrusted applets cannot set a default locale, this class also has convenience methods
for setting and retrieving a Locale
object associated with a WTContext
object. Applets that wish to use a non-default locale should call setLocale
with
the desired Locale
object, and any code that wishes to use this non-default
locale can call getLocale
to retrieve the locale that applies to their context.
Likewise, similar methods are available to associate a timezone with a context.
This class also has convenience methods for loading class files and opening class resource files
using the applicable applet class loader and URL connections. These methods should be used
when classes which may have been loaded from the local classpath need to dynamically load
additional classes or open resource files which may not reside in the local class path. For
example, if core classes are deployed in the local class path, but an applet class is loaded
from a Web server, any calls to Class.forName
in the locally loaded classes will
not find classes or files associated with the applet that do not also exist in the local
class path.
Some Windchill classes perform static class initialization based on local properties obtained
from the WTProperties class. Therefore, the WTContext.init
method will implicitly
call WTProperties.getLocalProperties
to guarantee that the local properties will be
available. If not, an ExceptionInInitializerError
is thrown to abort application
or applet startup. This is a safety measure since it is unlikely that static class
initialization errors will be handled gracefully later on.
Example application main:
Example applet init:public static void main (String args) { // Initialize WTContext with command line arguments WTContext.init(args); // Do application stuff ... }
If context sensitive operations are performed from a thread group that does not map to an initialized context, it may be necessary to temporarily force mapping of the current thread to the desired context's thread group. Thepublic void init () { // Initialize WTContext for this applet WTContext.init(this); // Do applet init stuff ... } public void destroy () { // Destroy WTContext for this applet WTContext.getContext(this).destroy(this); }
setContext
and setContextGroup
methods exist
for this purpose.
In Microsoft's Internet Explorer browser, Java's AWT event dispatching may take place in a thread
group that is shared by multiple applet contexts. The following example illustrates explicitly
setting context in a actionPerformed
method:
If not explicitly set, context lookup will fail over to any context corresponding to a child thread group of the current group. If none is found, a new empty context is implicitly created. This failover behavior is intended for fault tolerance in single-user applications or web browsers. It can be explicitly controlled in multi-user applications using thepublic void actionPerformed (ActionEvent e) { try { // Set context to parent applet while processing WTContext.setContext(applet); // Do action stuff ... } finally { WTContext.setContext((applet)null); } }
setLookupTolerance
method.
NOTE:
For performance of context lookup, nested context's are not supported. Stand alone
applications usually have a single context, and applets should have one context per applet
thread group created by the browser. If an application wants to manage multiple contexts
for different thread groups, the application initialization methods should be called with a
null argument array rather than calling the application initialization method with command
line arguments. This is because the application initialization method creates a context
that applies to the highest parent thread group reachable when it is called with the command
line arguments. If an application starts out with a single context, but later wishes to transform
into a container of multiple contexts, the initial context should be destroyed to break this high level
thread group association.
Supported API: true
Extendable false
WTProperties
,
Serialized FormNested Class Summary |
Nested classes inherited from class java.util.Hashtable |
|
Field Summary | |
private Applet |
applet
|
private static ThreadLocal |
appletForThread
|
private Vector |
appletListeners
|
private static Map |
appletToContextMap
|
private String[] |
args
|
private PropertyChangeSupport |
changeSupport
|
private static Vector |
contexts
|
private Locale |
defaultLocale
|
private static boolean |
defaultLocalResourcesOnly
|
private static TimeZone |
defaultTimezone
|
private static Vector |
globalAppletListeners
|
private ThreadGroup |
group
|
private static Hashtable |
groupMap
|
private static boolean |
HttpClientParseHTTPWorkAround
|
private static Object |
imageCache
|
private static boolean |
lenientLookup
|
private Locale |
locale
|
private boolean |
localResourcesOnly
|
private Object |
myImages
|
private Frame |
parentFrame
|
private int |
persistStreamMaxSize
|
private static WTContext |
previous
|
private ThreadGroup |
root
|
private static HashMap |
streamStore
|
private TimeZone |
timezone
|
private static boolean |
traceback
|
private static boolean |
verbose
|
private static boolean |
warning
|
Fields inherited from class java.util.Hashtable |
|
Constructor Summary | |
private |
WTContext(ThreadGroup group)
|
Method Summary | |
void |
addAppletListener(Applet listener)
Add a Applet to the AppletListener list. |
void |
addAppletListener(AppletListener listener)
Add a AppletListener to the listener list. |
static void |
addGlobalAppletListener(AppletListener listener)
Add a global AppletListener to the listener list. |
void |
addPropertyChangeListener(PropertyChangeListener listener)
Add a PropertyChangeListener to the listener list. |
void |
appletResize(int width,
int height)
Called when the applet wants to be resized. |
static ThreadGroup |
currentThreadGroup()
Get the current thread group of the calling thread. |
void |
destroy()
Destroy this WTContext object. |
void |
destroy(Applet applet)
Destroy this WTContext only if the given Applet object is
the parent Applet for this context. |
private void |
destroy(Vector listeners)
|
static WTContext |
findContext(Component component)
Find the WTContext object currently associated with the given component's
top-most parent applet. |
static WTContext |
findContext(ThreadGroup group)
Find the WTContext object currently associated with the given thread
group. |
Applet |
getApplet()
Get the applet corresponding to this context. |
Applet |
getApplet(String name)
Finds and returns the applet in the document represented by this applet context with the given name. |
AppletContext |
getAppletContext()
Gets a handler to the applet's context. |
Enumeration |
getApplets()
Finds all the applets in the document represented by this applet context. |
String[] |
getArgs()
Get the argument array for this context. |
AudioClip |
getAudioClip(String name)
Creates an audio clip from a resource file. |
AudioClip |
getAudioClip(URL url)
Creates an audio clip. |
private static InputStream |
getBufferedResourceStream(InputStream input_stream)
|
ClassLoader |
getClassLoader()
Returns the Class loader of this context's top-most applet. |
URL |
getCodeBase()
Gets the base URL. |
static WTContext |
getContext()
Get the WTContext object associated with the current thread
group. |
static WTContext |
getContext(Component component)
Get the WTContext object currently associated with the given component's
top-most parent applet. |
static WTContext |
getContext(ThreadGroup group)
Get the WTContext object currently associated with the given thread
group. |
static ThreadGroup |
getContextGroup()
Return WTContext thread group associated with the current
thread. |
URL |
getDocumentBase()
Gets the document URL. |
Image |
getImage(String name)
Get an image from a resource file. |
Image |
getImage(URL url)
Returns an Image object that can then be painted on
the screen. |
Locale |
getLocale()
Get locale for this context. |
String |
getParameter(String name)
Returns the value of the named parameter in the HTML tag. |
private static Applet |
getParentApplet(Component component)
|
Frame |
getParentFrame()
Get the parent frame for this context. |
URL |
getResource(String name)
Find a resource with a given a name. |
URL |
getResource(URL codebase,
String name)
Find a resource with a given a name. |
InputStream |
getResourceAsStream(Class cls,
String name)
Get an InputStream for a given resource name after applying a naming
convention based on the supplied class name: if the resource name starts with "/", it
is used as is. |
InputStream |
getResourceAsStream(String name)
Get an InputStream for a given resource name. |
InputStream |
getResourceAsStream(String name,
URL[] url)
Get an InputStream for a given resource name. |
InputStream |
getResourceAsStream(URL codebase,
String name)
Get an InputStream for a given resource name by opening a URL connection
relative to the given codebase. |
URL |
getServerResource(String name)
Find a server resource with a given name. |
InputStream |
getServerResourceAsStream(String name)
Get an InputStream for a given server resource name by opening a
URL connection relative to this context's codebase. |
InputStream |
getStream(String key)
Returns the stream to which specified key is associated within this context. |
Iterator |
getStreamKeys()
Finds all the keys of the streams in this context. |
private HashMap |
getStreamStore()
|
Clipboard |
getSystemClipboard()
Get the system clipboard. |
InputStream |
getSystemResourceAsStream(String name)
Get an InputStream for a given system resource name. |
ThreadGroup |
getThreadGroup()
Get the thread group corresponding to this context. |
TimeZone |
getTimeZone()
Get time zone for this context. |
private Image |
imageFromResourceStream(InputStream input_stream)
|
private static WTContext |
init(Applet applet,
String[] args,
boolean local_resources_only)
|
private static WTContext |
init(Applet applet,
String[] args,
boolean local_resources_only,
boolean globalContext)
|
static void |
init(Component component)
Initialize WTContext for an applet or applet component. |
static void |
init(String[] args)
Initialize WTContext for an application. |
static void |
init(String[] args,
boolean local_resources_only)
Initialize WTContext for a server application. |
static void |
init(String[] args,
boolean local_resources_only,
boolean globalContext)
|
void |
interrupt()
Interrupt all active threads in this context's thread group and its subgroups. |
private Object |
invoke(Object obj,
String name,
Class[] sig,
Object[] args)
|
boolean |
isActive()
Determines if the applet is active. |
Class |
loadClass(String name)
Returns the Class object associated with the class with the given string name. |
private static RuntimeException |
newWTContextNestingException(ThreadGroup group)
|
private static void |
printWarning(ThreadGroup group,
WTContext found)
|
Object |
put(Object key,
Object value)
Override Hashtable.put to add property change support. |
Object |
remove(Object key)
Override Hashtable.remove to add property change support. |
void |
removeAppletListener(Applet listener)
Remove a Applet from the AppletListener list. |
void |
removeAppletListener(AppletListener listener)
Remove a AppletListener from the listener list. |
private static void |
removeContext(WTContext context)
|
static void |
removeGlobalAppletListener(AppletListener listener)
Remove a global AppletListener from the listener list. |
void |
removePropertyChangeListener(PropertyChangeListener listener)
Remove a PropertyChangeListener from the listener list. |
static void |
setContext(Component component)
Temporarily set the WTContext object associated with the current
thread to the WTContext object associated with the given component's
top-most parent applet. |
static void |
setContextGroup(ThreadGroup group)
Temporarily set the WTContext object associated with the current
thread to the one associated with the given thread group. |
static void |
setDefaultTimeZone(TimeZone timezone)
Set default time zone. |
static void |
setLenientLookup(boolean lenient)
Set whether context lookup should be lenient with respect to context initialization. |
void |
setLocale(Locale locale)
Set locale for this context. |
void |
setParentFrame(Frame parent_frame)
Set the parent frame for this context. |
void |
setStream(String key,
InputStream stream)
Associates the specified stream with the specified key in this context. |
void |
setTimeZone(TimeZone timezone)
Set time zone for this context. |
static void |
setVerbose(boolean verbose)
Set verbose mode for debugging. |
void |
showDocument(URL url)
Replaces the Web page currently being viewed with the given URL. |
void |
showDocument(URL url,
String target)
Requests that the browser or applet viewer show the Web page indicated by the url argument. |
void |
showStatus(String status)
Requests that the argument string be displayed in the "status window". |
void |
start()
Report a Applet.start call to any registered listeners. |
void |
start(Applet applet)
Report a Applet.start call to any registered listeners only if the
given Applet object is the parent Applet for this context. |
private void |
start(Vector listeners)
|
void |
stop()
Report a Applet.stop call to any registered listeners. |
void |
stop(Applet applet)
Report a Applet.stop call to any registered listeners only if the
given Applet object is the parent Applet for this context. |
void |
stop(Vector listeners)
|
boolean |
useLocalResourcesOnly()
Return whether local resources should be used as server resources for this context. |
Methods inherited from class java.util.Hashtable |
clear, clone, contains, containsKey, containsValue, elements, entrySet, equals, get, hashCode, isEmpty, keys, keySet, putAll, rehash, size, toString, values |
Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
private static boolean verbose
private static boolean warning
private static boolean traceback
private static final ThreadLocal appletForThread
private static final Map appletToContextMap
private static Vector contexts
private static Hashtable groupMap
private static volatile WTContext previous
private static boolean defaultLocalResourcesOnly
private static boolean HttpClientParseHTTPWorkAround
private static Object imageCache
private static TimeZone defaultTimezone
private static Vector globalAppletListeners
private static boolean lenientLookup
private ThreadGroup group
private ThreadGroup root
private Applet applet
private String[] args
private boolean localResourcesOnly
private Frame parentFrame
private Object myImages
private PropertyChangeSupport changeSupport
private Vector appletListeners
private Locale locale
private Locale defaultLocale
private TimeZone timezone
private int persistStreamMaxSize
private static HashMap streamStore
Constructor Detail |
private WTContext(ThreadGroup group)
Method Detail |
public static void init(String[] args)
WTContext
for an application.
Associates a context having the given argument array with the top-most parent thread
group of the current thread group.
args
- the args array passed to the application's main
method.public static void init(String[] args, boolean local_resources_only)
WTContext
for a server application.
Associates a context having the given argument array with the top-most parent thread
group of the current thread group. If local_resources_only
is true, this is a server application for which server resources are
available as local (class path) resources. Server resources for a context
are otherwise accessed using URLs relative to the server codebase as determined
by the wt.util.WTProperties
class.
args
- the args array passed to the applicaion's main
method.local_resources_only
- use local resources as server resourcesWTProperties
public static void init(String[] args, boolean local_resources_only, boolean globalContext)
public static void init(Component component)
WTContext
for an applet or applet component.
This associates the given component's top-most parent Applet with the current
thread group. A corresponding call to destroy
should be called when
the applet is destroyed to guarantee timely garbage collection of
the Applet object.
If a context already exist for the current thread group and there is already
an applet associated with that context, this call is ignored.
Supported API: true
component
- the Applet
or Component
objectdestroy()
private static Applet getParentApplet(Component component)
private static WTContext init(Applet applet, String[] args, boolean local_resources_only)
private static WTContext init(Applet applet, String[] args, boolean local_resources_only, boolean globalContext)
public void destroy()
WTContext
object. This should be called to guarantee timely
garbage collection of objects referenced by the WTContext
object. If not
called, the objects will remain referenced until a new WTContext object is created, at
which time the WTContext
class will automatically destroy contexts
associated with destroyed thread groups.
Any registered AppletListener
objects will be informed about of this
destroy
call.
Applets should call the version of this method that accepts an Applet
argument to guarantee that this context is only destroyed if the Applet
object is the parent Applet
for this context.
Supported API: true
init(java.lang.String[])
,
addAppletListener(wt.util.AppletListener)
private void destroy(Vector listeners)
private static void removeContext(WTContext context)
public void destroy(Applet applet)
WTContext
only if the given Applet
object is
the parent Applet
for this context.
init(java.lang.String[])
public static WTContext getContext()
WTContext
object associated with the current thread
group. If no association has been created by an explicit call to
init
or setContext
, then an empty context is created.
WTContext
objectinit(java.lang.String[])
public static WTContext getContext(ThreadGroup group)
WTContext
object currently associated with the given thread
group. If no context exists for the given thread group, an empty context is created.
WTContext
objectinit(java.lang.String[])
private static RuntimeException newWTContextNestingException(ThreadGroup group)
public static WTContext findContext(ThreadGroup group)
WTContext
object currently associated with the given thread
group.
group
- the thread group
WTContext
object or null if noneinit(java.lang.String[])
private static void printWarning(ThreadGroup group, WTContext found)
public static WTContext getContext(Component component)
WTContext
object currently associated with the given component's
top-most parent applet. If the given component does not have a parent applet or
if no context is currently associated with the applet, the current thread group's context
is returned.
component
- the Component
object
WTContext
objectinit(java.lang.String[])
public static WTContext findContext(Component component)
WTContext
object currently associated with the given component's
top-most parent applet. If the given component does not have a parent applet or
if no context is currently associated with the applet, null is returned.
component
- the Component
object
WTContext
object or null if noneinit(java.lang.String[])
public static void setContext(Component component)
WTContext
object associated with the current
thread to the WTContext
object associated with the given component's
top-most parent applet. If the given component does not have a parent applet or if
no context is currently associated with the applet, the call is ignored.
This method is typically called within the AWT event dispatching thread which
may be executing in a thread group that is a parent of multiple applet thread
groups (e.g. IE4.0). It should be used in a try/finally block to reset the association
to null when processing for the given component is complete.
Supported API: true
component
- the Component
objectinit(java.lang.String[])
public static void setContextGroup(ThreadGroup group)
WTContext
object associated with the current
thread to the one associated with the given thread group.
This method can be used by an application which explicitly manages thread groups
with different contexts.
It should be used in a try/finally block to reset the association
to the previous value or null when processing is complete.
Supported API: true
group
- the ThreadGroup
object
init(java.lang.String[])
,
getContextGroup()
public static ThreadGroup getContextGroup()
WTContext
thread group associated with the current
thread. Returns null if no explicit association has been set using
setContextGroup
.
setContextGroup(java.lang.ThreadGroup)
public String[] getArgs()
init
was called
for this context. If no argument array was specified, or it was null, an empty
array is returned. This allows the return to be treated just like the argument
array passed to an application's main
method, which is never null.
init(java.lang.String[])
public Applet getApplet()
init(java.lang.String[])
public Frame getParentFrame()
setParentFrame
. If no parent frame has
been explicitly set for this context, the parent frame of the applet associated with
this context is returned. If no applet is associated with this context, or it is not
currently contained in a frame, null is returned.
init(java.lang.String[])
public void setParentFrame(Frame parent_frame)
init(java.lang.String[])
public ThreadGroup getThreadGroup()
init(java.lang.String[])
public static ThreadGroup currentThreadGroup()
setContext
or setContextGroup
.
Otherwise, if a security manager is present, it is called to get the thread group into which
any new thread being constructed in this thread would be assigned. By default, it returns the
thread group of the current thread, but this could be overriden by specific security
manager to return the appropriate thread group if called from within a system thread.
If no security manager is present, the current thread's thread group is returned.
public static void setVerbose(boolean verbose)
WTContext
class.
verbose
- the verbose settingpublic void interrupt()
Note: a bug in JDK 1.1 prevents applications from terminating properly if their
main thread is interrupted, even after the run
method has returned.
Therefore, all threads named "main" are also skipped.
Supported API: true
public boolean useLocalResourcesOnly()
init
method.public static void setLenientLookup(boolean lenient)
lenient
- public void addPropertyChangeListener(PropertyChangeListener listener)
PropertyChangeListener
to the listener list.
Property change events will be fired to all registered listeners whenever a
value in this hashtable is added, changed, or removed.
listener
- the PropertyChangeListener
to be addedpublic void removePropertyChangeListener(PropertyChangeListener listener)
PropertyChangeListener
from the listener list.
listener
- the PropertyChangeListener
to be removedpublic Object put(Object key, Object value)
Hashtable.put
to add property change support.
put
in interface Map
key
- the hashtable keyvalue
- the value
Hashtable
public Object remove(Object key)
Hashtable.remove
to add property change support.
remove
in interface Map
key
- the key that needs to be removed
Hashtable
public void addAppletListener(AppletListener listener)
AppletListener
to the listener list.
listener
- the AppletListener
to be addedpublic void addAppletListener(Applet listener)
Applet
to the AppletListener
list.
This method allows child applets to be listeners without declaring that they
implement the AppletListener
interface.
listener
- the Applet
to be addedpublic void removeAppletListener(AppletListener listener)
AppletListener
from the listener list.
listener
- The AppletListener
to be removedpublic void removeAppletListener(Applet listener)
Applet
from the AppletListener
list.
listener
- The Applet
to be removedpublic static void addGlobalAppletListener(AppletListener listener)
AppletListener
to the listener list.
Global listeners will receive AppletListener
calls for all contexts.
Application code may issue a WTContext.stop()
to signal a panic
shutdown. This method allows adding a single listener within applications that may
have multiple multi contexts active simultaneously.
listener
- the AppletListener
to be addedpublic static void removeGlobalAppletListener(AppletListener listener)
AppletListener
from the listener list.
listener
- The AppletListener
to be removedpublic void start()
Applet.start
call to any registered listeners.
private void start(Vector listeners)
public void start(Applet applet)
Applet.start
call to any registered listeners only if the
given Applet
object is the parent Applet
for this context.
init(java.lang.String[])
public void stop()
Applet.stop
call to any registered listeners.
public void stop(Vector listeners)
public void stop(Applet applet)
Applet.stop
call to any registered listeners only if the
given Applet
object is the parent Applet
for this context.
init(java.lang.String[])
public boolean isActive()
start
method is called. It becomes
inactive immediately after its stop
method is called.
isActive
in interface AppletStub
true
if the applet is active;
false
otherwise.public URL getDocumentBase()
getDocumentBase
in interface AppletStub
URL
of the document containing the applet.public URL getCodeBase()
getCodeBase
in interface AppletStub
URL
of the applet.public String getParameter(String name)
<applet code="Clock" width=50 height=50>
<param name=Color value="blue">
</applet>
then a call to getParameter("Color")
returns the
value "blue"
.
Supported API: true
getParameter
in interface AppletStub
name
- a parameter name.
public AppletContext getAppletContext()
getAppletContext
in interface AppletStub
public void appletResize(int width, int height)
appletResize
in interface AppletStub
width
- the new requested width for the applet.height
- the new requested height for the applet.public AudioClip getAudioClip(URL url)
getAudioClip
in interface AppletContext
url
- an absolute URL giving the location of the audio clip.
public AudioClip getAudioClip(String name)
name
- the name of the resource (full path, may include leading "/")
public Image getImage(URL url)
Image
object that can then be painted on
the screen. The url
argument
that is
passed as an argument must specify an absolute URL.
This method always returns immediately, whether or not the image
exists. When the applet attempts to draw the image on the screen,
the data will be loaded. The graphics primitives that draw the
image will incrementally paint on the screen.
Supported API: true
getImage
in interface AppletContext
url
- an absolute URL giving the location of the image.
Image
public Image getImage(String name)
getImage
method is called.
For system resources, the resource is loaded into a byte array and
converted to an image from there. This is due to problems Netscape
and Microsoft VMs have dealing with system resource URLs.
name
- the name of the resource (full path, may include leading "/")
Image
private Image imageFromResourceStream(InputStream input_stream) throws IOException
IOException
public Applet getApplet(String name)
name
attribute.
getApplet
in interface AppletContext
name
- an applet name.
null
if
not found.public Enumeration getApplets()
getApplets
in interface AppletContext
public void showDocument(URL url)
showDocument
method.
If this context is an application and can execute commands, an attempt
is made to launch a browser to view the page. On Windows platforms
this is done using rundll32.exe to open the URL in the user's default
browser. On unix, this is done by trying to execute netscape. To
allow the commands to be configured, a property named wt.context.showDocument.
showDocument
in interface AppletContext
url
- an absolute URL giving the location of the document.public void showDocument(URL url, String target)
url
argument. The
target
argument indicates where to display the frame.
The target argument is interpreted as follows:
"_self" | show in the current frame |
"_parent" | show in the parent frame |
"_top" | show in the topmost frame |
"_blank" | show in a new unnamed top-level window |
name | show in a new top-level window named name |
An applet viewer or browser is free to ignore showDocument
.
Supported API: true
showDocument
in interface AppletContext
url
- an absolute URL giving the location of the document.target
- a String
indicating where to display
the page.public void showStatus(String status)
showStatus
in interface AppletContext
status
- a string to display in the status window.private HashMap getStreamStore()
private Object invoke(Object obj, String name, Class[] sig, Object[] args) throws InvocationTargetException
InvocationTargetException
public void setStream(String key, InputStream stream) throws IOException
setStream
in interface AppletContext
key
- key with which the specified value is to be
associated.stream
- stream to be associated with the specified key.
If this parameter is null, the specified key is removed in this context.
IOException
- if the stream size exceeds a size limit. For
applets this is determined by applet's implementation; for applications,
this is 65536 bytes.public InputStream getStream(String key)
getStream
in interface AppletContext
key
- key with which the specified value is to be
associated.
public Iterator getStreamKeys()
getStreamKeys
in interface AppletContext
public void setLocale(Locale locale)
Locale.getDefault
. If this context corresponds to an applet, the applet's
locale is set so it can affect the getLocale
method of components contained in
the applet.
locale
- the Locale
objectpublic Locale getLocale()
setLocale
, the locale defined by a
parameter named wt.context.locale
is returned. If this parameter is not set,
then the default locale returned by the context's applet or by Locale.getDefault
is returned.
Locale
objectpublic void setTimeZone(TimeZone timezone)
timezone
- the TimeZone
objectpublic static void setDefaultTimeZone(TimeZone timezone)
TimeZone.getDefault
.
timezone
- the TimeZone
objectpublic TimeZone getTimeZone()
setTimeZone
, the
default time zone is returned.
TimeZone
objectpublic ClassLoader getClassLoader()
public Class loadClass(String name) throws ClassNotFoundException
ClassNotFoundException
- if context's class loader can't find the class filepublic InputStream getSystemResourceAsStream(String name)
InputStream
for a given system resource name. This is similar to
ClassLoader.getSystemResourceAsStream
but attempts to work around
Netscape security exceptions. Returns null if no resource by this name is found.
The returned InputStream
is buffered if necessary for reading efficiency.
name
- the name of the resource (full path, may include leading "/")
InputStream
for the resource, or null if not foundpublic InputStream getResourceAsStream(String name)
InputStream
for a given resource name. If the WTContext
class was loaded from the local class path, this method first attempts to open
the resource as a local system resource. If not found, or unable to access local
resources due to security restrictions, this method delegates to the class loader
of this context's top-most applet. If that class loader is unable to open the
resource, a URL connection is attempted relative to this context's codebase. Null
is returned if no resource by this name is found. The returned InputStream
is buffered if necessary for reading efficiency.
name
- the name of the resource (full path, may include leading "/")
InputStream
for the resource, or null if not foundpublic InputStream getResourceAsStream(String name, URL[] url)
InputStream
for a given resource name. If the WTContext
class was loaded from the local class path, this method first attempts to open
the resource as a local system resource. If not found, or unable to access local
resources due to security restrictions, this method delegates to the class loader
of this context's top-most applet. If that class loader is unable to open the
resource, a URL connection is attempted relative to this context's codebase. Null
is returned if no resource by this name is found. The returned InputStream
is buffered if necessary for reading efficiency.
name
- the name of the resource (full path, may include leading "/")url
- a single element URL array to receive the URL corresponding to the stream
InputStream
for the resource, or null if not foundpublic InputStream getResourceAsStream(Class cls, String name)
InputStream
for a given resource name after applying a naming
convention based on the supplied class name: if the resource name starts with "/", it
is used as is. Otherwise, the name of the class's package is prepended, after converting
"." to "/". This method first attempts to open the resource as a local system resource.
If not found, or unable to access local resources due to security restrictions, this
method delegates to the class loader of this context's top-most applet. If that class
loader is unable to open the resource, a URL connection is attempted relative to this
context's codebase. Null is returned if no resource by this name is found. The
returned InputStream
is buffered if necessary for reading efficiency.
cls
- the class to fully qualify relative resource namesname
- the name of the resource (full path, may include leading "/")
InputStream
for the resource, or null if not foundpublic InputStream getResourceAsStream(URL codebase, String name) throws IOException
InputStream
for a given resource name by opening a URL connection
relative to the given codebase. This method could be static except for the need to
use this context's Netscape security privileges. The returned InputStream
is buffered if necessary for reading efficiency.
codebase
- the codebase URLname
- the name of the resource (full path, may include leading "/")
InputStream
for the resource, or null if not found
IOException
public URL getResource(String name)
name
- the name of the resource (full path, may include leading "/")
URL
for the resourcepublic URL getResource(URL codebase, String name)
codebase
- the codebase URLname
- the name of the resource (full path, may include leading "/")
URL
for the resourcepublic InputStream getServerResourceAsStream(String name)
InputStream
for a given server resource name by opening a
URL connection relative to this context's codebase. This is similar to
getResourceAsStream
but won't find resources in the local class path.
The returned InputStream
is buffered if necessary for reading efficiency.
name
- the name of the resource (full path, may include leading "/")
InputStream
for the resource, or null if not foundpublic URL getServerResource(String name)
getResource
but doesn't return URLs to local class path resources.
name
- the name of the resource (full path, may include leading "/")
URL
for the resourceprivate static InputStream getBufferedResourceStream(InputStream input_stream)
public Clipboard getSystemClipboard()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |