jdk/src/share/classes/java/applet/AppletContext.java
author ohair
Tue, 25 May 2010 15:58:33 -0700
changeset 5506 202f599c92aa
parent 2 90ce3da70b43
child 19207 3448b0cb4077
permissions -rw-r--r--
6943119: Rebrand source copyright notices Reviewed-by: darcy, weijun
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     2
 * Copyright (c) 1995, 2006, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package java.applet;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.awt.Image;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.awt.Graphics;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.awt.image.ColorModel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.net.URL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.util.Enumeration;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.io.InputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.io.IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import java.util.Iterator;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * This interface corresponds to an applet's environment: the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * document containing the applet and the other applets in the same
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * document.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * The methods in this interface can be used by an applet to obtain
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * information about its environment.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * @author      Arthur van Hoff
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * @since       JDK1.0
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
public interface AppletContext {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
     * Creates an audio clip.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
     * @param   url   an absolute URL giving the location of the audio clip.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
     * @return  the audio clip at the specified URL.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    AudioClip getAudioClip(URL url);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
     * Returns an <code>Image</code> object that can then be painted on
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
     * the screen. The <code>url</code> argument<code> </code>that is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
     * passed as an argument must specify an absolute URL.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
     * This method always returns immediately, whether or not the image
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
     * exists. When the applet attempts to draw the image on the screen,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
     * the data will be loaded. The graphics primitives that draw the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
     * image will incrementally paint on the screen.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
     * @param   url   an absolute URL giving the location of the image.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
     * @return  the image at the specified URL.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
     * @see     java.awt.Image
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    Image getImage(URL url);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     * Finds and returns the applet in the document represented by this
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     * applet context with the given name. The name can be set in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     * HTML tag by setting the <code>name</code> attribute.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     * @param   name   an applet name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     * @return  the applet with the given name, or <code>null</code> if
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     *          not found.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    Applet getApplet(String name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     * Finds all the applets in the document represented by this applet
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     * context.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     * @return  an enumeration of all applets in the document represented by
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     *          this applet context.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    Enumeration<Applet> getApplets();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     * Requests that the browser or applet viewer show the Web page
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     * indicated by the <code>url</code> argument. The browser or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     * applet viewer determines which window or frame to display the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     * Web page. This method may be ignored by applet contexts that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     * are not browsers.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     * @param   url   an absolute URL giving the location of the document.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    void showDocument(URL url);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     * Requests that the browser or applet viewer show the Web page
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     * indicated by the <code>url</code> argument. The
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     * <code>target</code> argument indicates in which HTML frame the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     * document is to be displayed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     * The target argument is interpreted as follows:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     * <center><table border="3" summary="Target arguments and their descriptions">
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     * <tr><th>Target Argument</th><th>Description</th></tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     * <tr><td><code>"_self"</code>  <td>Show in the window and frame that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     *                                   contain the applet.</tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     * <tr><td><code>"_parent"</code><td>Show in the applet's parent frame. If
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     *                                   the applet's frame has no parent frame,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     *                                   acts the same as "_self".</tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     * <tr><td><code>"_top"</code>   <td>Show in the top-level frame of the applet's
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     *                                   window. If the applet's frame is the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     *                                   top-level frame, acts the same as "_self".</tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     * <tr><td><code>"_blank"</code> <td>Show in a new, unnamed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     *                                   top-level window.</tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     * <tr><td><i>name</i><td>Show in the frame or window named <i>name</i>. If
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     *                        a target named <i>name</i> does not already exist, a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     *                        new top-level window with the specified name is created,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     *                        and the document is shown there.</tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     * </table> </center>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     * An applet viewer or browser is free to ignore <code>showDocument</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     * @param   url   an absolute URL giving the location of the document.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     * @param   target   a <code>String</code> indicating where to display
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     *                   the page.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
    public void showDocument(URL url, String target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     * Requests that the argument string be displayed in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
     * "status window". Many browsers and applet viewers
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     * provide such a window, where the application can inform users of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     * its current state.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     * @param   status   a string to display in the status window.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
    void showStatus(String status);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     * Associates the specified stream with the specified key in this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     * applet context. If the applet context previously contained a mapping
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     * for this key, the old value is replaced.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     * For security reasons, mapping of streams and keys exists for each
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     * codebase. In other words, applet from one codebase cannot access
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     * the streams created by an applet from a different codebase
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     * @param key key with which the specified value is to be associated.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     * @param stream stream to be associated with the specified key. If this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     *               parameter is <code>null</code>, the specified key is removed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     *               in this applet context.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     * @throws <code>IOException</code> if the stream size exceeds a certain
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     *         size limit. Size limit is decided by the implementor of this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     *         interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
    public void setStream(String key, InputStream stream)throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
     * Returns the stream to which specified key is associated within this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     * applet context. Returns <tt>null</tt> if the applet context contains
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     * no stream for this key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
     * For security reasons, mapping of streams and keys exists for each
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
     * codebase. In other words, applet from one codebase cannot access
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
     * the streams created by an applet from a different codebase
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
     * @return the stream to which this applet context maps the key
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
     * @param key key whose associated stream is to be returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
    public InputStream getStream(String key);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
     * Finds all the keys of the streams in this applet context.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     * For security reasons, mapping of streams and keys exists for each
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     * codebase. In other words, applet from one codebase cannot access
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     * the streams created by an applet from a different codebase
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     * @return  an Iterator of all the names of the streams in this applet
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     *          context.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
    public Iterator<String> getStreamKeys();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
}