1 /* gnu.java.beans.DummyAppletContext
2 Copyright (C) 2004, 2005 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library. Thus, the terms and
23 conditions of the GNU General Public License cover the whole
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module. An independent module is a module which is not derived from
33 or based on this library. If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so. If you do not wish to do so, delete this
36 exception statement from your version. */
39 package gnu.java.beans;
41 import java.applet.Applet;
42 import java.applet.AppletContext;
43 import java.applet.AudioClip;
44 import java.awt.Image;
45 import java.awt.Toolkit;
46 import java.io.IOException;
47 import java.io.InputStream;
49 import java.util.Collections;
50 import java.util.Enumeration;
51 import java.util.Iterator;
53 /** A placeholder <code>AppletContext</code> implementation that does nothing.
55 * <p>This is the default implementation for GNU Classpath and is used for <code>Applet</code>
56 * beans being created with {@link java.beans.Beans.instantiate}.</p>
58 * <p>It has no functionality in order to allow it to be used without any dependencies
59 * (e.g. sound, network access, ...).</p>
61 * @author Robert Schuster
63 class DummyAppletContext implements AppletContext
65 private static final Enumeration EMPTY_ENUMERATION = Collections.enumeration(Collections.EMPTY_SET);
71 /** Implementation is VM neutral and returns a dummy {@link AudioClip} instance
72 * for every URL that returns a non-<code>null</code> object on
73 * <code>URL.openConnection()</code>.
75 * @see java.applet.AppletContext#getAudioClip(java.net.URL)
77 * FIXME: When Java Sound API (javax.sound) is included in Classpath or URL is able to handle
78 * sampled sound this should be adjusted.
80 public AudioClip getAudioClip(URL url)
82 return Applet.newAudioClip(url);
85 /** Loads the <code>Image</code> instance by delegating to
86 * {@link java.awt.Toolkit.createImage(URL) }.
88 * @see java.applet.AppletContext#getImage(java.net.URL)
89 * @see java.awt.Toolkit#createImage(java.net.URL)
91 public Image getImage(URL url)
93 return Toolkit.getDefaultToolkit().createImage(url);
96 /** Returns <code>null</code> for every argument.
98 * @see java.applet.AppletContext#getApplet(java.lang.String)
100 public Applet getApplet(String name)
105 /** Returns always an empty <code>Enumeration</code>.
107 * @see java.applet.AppletContext#getApplets()
109 public Enumeration getApplets()
111 return EMPTY_ENUMERATION;
116 * @see java.applet.AppletContext#showDocument(java.net.URL)
118 public void showDocument(URL url)
124 * @see java.applet.AppletContext#showDocument(java.net.URL, java.lang.String)
126 public void showDocument(URL url, String target)
132 * @see java.applet.AppletContext#showStatus(java.lang.String)
134 public void showStatus(String message)
140 * @see java.applet.AppletContext#setStream(java.lang.String, java.io.InputStream)
142 public void setStream(String key, InputStream stream)
145 throw new IOException("Dummy implementation imposes zero InputStream associations.");
148 /** Returns <code>null</code> for every argument.
150 * @see java.applet.AppletContext#getStream(java.lang.String)
152 public InputStream getStream(String key)
157 /** Returns always an empty iterator.
159 * @see java.applet.AppletContext#getStreamKeys()
161 public Iterator getStreamKeys()
163 return Collections.EMPTY_SET.iterator();