001    /* AppletContext.java -- access the applet's runtime environment
002       Copyright (C) 1999, 2002, 2004 Free Software Foundation, Inc.
003    
004    This file is part of GNU Classpath.
005    
006    GNU Classpath is free software; you can redistribute it and/or modify
007    it under the terms of the GNU General Public License as published by
008    the Free Software Foundation; either version 2, or (at your option)
009    any later version.
010    
011    GNU Classpath is distributed in the hope that it will be useful, but
012    WITHOUT ANY WARRANTY; without even the implied warranty of
013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014    General Public License for more details.
015    
016    You should have received a copy of the GNU General Public License
017    along with GNU Classpath; see the file COPYING.  If not, write to the
018    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
019    02110-1301 USA.
020    
021    Linking this library statically or dynamically with other modules is
022    making a combined work based on this library.  Thus, the terms and
023    conditions of the GNU General Public License cover the whole
024    combination.
025    
026    As a special exception, the copyright holders of this library give you
027    permission to link this library with independent modules to produce an
028    executable, regardless of the license terms of these independent
029    modules, and to copy and distribute the resulting executable under
030    terms of your choice, provided that you also meet, for each linked
031    independent module, the terms and conditions of the license of that
032    module.  An independent module is a module which is not derived from
033    or based on this library.  If you modify this library, you may extend
034    this exception to your version of the library, but you are not
035    obligated to do so.  If you do not wish to do so, delete this
036    exception statement from your version. */
037    
038    
039    package java.applet;
040    
041    import java.awt.Image;
042    import java.io.IOException;
043    import java.io.InputStream;
044    import java.net.URL;
045    import java.util.Enumeration;
046    import java.util.Iterator;
047    
048    /**
049     * This interface allows an applet access to the browser to retrieve
050     * additional data files and display documents.  It also allows the
051     * applet to find out other applets in the same document.
052     *
053     * @author Aaron M. Renn (arenn@urbanophile.com)
054     * @since 1.0
055     * @status updated to 1.5
056     */
057    public interface AppletContext
058    {
059      /**
060       * Returns an audio clip from the specified URL.
061       *
062       * @param url the URL of the audio clip
063       * @return the retrieved audio clip
064       * @throws NullPointerException if url is null
065       */
066      AudioClip getAudioClip(URL url);
067    
068      /**
069       * Returns an image from the specified URL.  Note that the image is not
070       * actually retrieved until the applet attempts to display it, so this
071       * method returns immediately.
072       *
073       * @param url the absolute URL of the image
074       * @return the retrieved image
075       * @throws NullPointerException if url is null
076       */
077      Image getImage(URL url);
078    
079      /**
080       * Returns the applet in the document for this object that has the
081       * specified name.
082       *
083       * @param name the applet name
084       * @return the requested applet, or <code>null</code> if not found
085       */
086      Applet getApplet(String name);
087    
088      /**
089       * Returns a list of all the applets in the document for this object.
090       *
091       * @return a list of all the applets
092       */
093      Enumeration<Applet> getApplets();
094    
095      /**
096       * Displays the web page pointed to by the specified URL in the window
097       * for this object.  This page replaces the document that is currently
098       * there.
099       *
100       * @param url the URL of the web page to load; unspecified on an error
101       */
102      void showDocument(URL url);
103    
104      /**
105       * Displays the web page pointed to be the sepcified URL in the window
106       * with the specified name.  The standard names "_top", "_blank",
107       * "_parent", and "_self" are allowed. An applet viewer may disregard
108       * this request.
109       *
110       * @param url the URL of the web page to load
111       * @param target the target window
112       */
113      void showDocument(URL url, String target);
114    
115      /**
116       * Displays the specified message in the status window if that window
117       * exists.
118       *
119       * @param message the status message, may be null
120       */
121      void showStatus(String message);
122    
123      /**
124       * Associate a stream to a key for this applet context, possibly replacing
125       * the old value. Stream associations are local to the applet context, for
126       * security purposes.
127       *
128       * @param key the key to associate with
129       * @param stream the stream value to tie to the key, or null to remove
130       * @throws IOException if the stream is too large
131       * @since 1.4
132       */
133      void setStream(String key, InputStream stream) throws IOException;
134    
135      /**
136       * Return the stream associated with a given key in this applet context, or
137       * null if nothing is associated. Stream associations are local to the
138       * applet context, for security purposes.
139       *
140       * @param key the key to look up
141       * @return the associated stream, or null
142       * @since 1.4
143       */
144      InputStream getStream(String key);
145    
146      /**
147       * Iterate over all keys that have associated streams. Stream associated
148       * are local to the applet context, for security purposes.
149       *
150       * @return an iterator over the association keys
151       * @since 1.4
152       */
153      Iterator<String> getStreamKeys();
154    } // interface AppletContext