OSDN Git Service

Normalise whitespace in GNU Classpath.
[pf3gnuchains/gcc-fork.git] / libjava / classpath / gnu / java / beans / DummyAppletContext.java
1 /* gnu.java.beans.DummyAppletContext
2    Copyright (C) 2004, 2005 Free Software Foundation, Inc.
3
4 This file is part of GNU Classpath.
5
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)
9 any later version.
10
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.
15
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
19 02110-1301 USA.
20
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
24 combination.
25
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. */
37
38
39 package gnu.java.beans;
40
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;
48 import java.net.URL;
49 import java.util.Collections;
50 import java.util.Enumeration;
51 import java.util.Iterator;
52
53 /** A placeholder <code>AppletContext</code> implementation that does nothing.
54  *
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>
57  *
58  * <p>It has no functionality in order to allow it to be used without any dependencies
59  * (e.g. sound, network access, ...).</p>
60  *
61  * @author Robert Schuster
62  */
63 class DummyAppletContext implements AppletContext
64 {
65   private static final Enumeration EMPTY_ENUMERATION = Collections.enumeration(Collections.EMPTY_SET);
66
67   DummyAppletContext()
68   {
69   }
70
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>.
74    *
75    * @see java.applet.AppletContext#getAudioClip(java.net.URL)
76    *
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.
79    */
80   public AudioClip getAudioClip(URL url)
81   {
82     return Applet.newAudioClip(url);
83   }
84
85   /** Loads the <code>Image</code> instance by delegating to
86    * {@link java.awt.Toolkit.createImage(URL) }.
87    *
88    * @see java.applet.AppletContext#getImage(java.net.URL)
89    * @see java.awt.Toolkit#createImage(java.net.URL)
90    */
91   public Image getImage(URL url)
92   {
93     return Toolkit.getDefaultToolkit().createImage(url);
94   }
95
96   /** Returns <code>null</code> for every argument.
97    *
98    * @see java.applet.AppletContext#getApplet(java.lang.String)
99    */
100   public Applet getApplet(String name)
101   {
102     return null;
103   }
104
105   /** Returns always an empty <code>Enumeration</code>.
106    *
107    * @see java.applet.AppletContext#getApplets()
108    */
109   public Enumeration getApplets()
110   {
111     return EMPTY_ENUMERATION;
112   }
113
114   /** Does nothing.
115    *
116    * @see java.applet.AppletContext#showDocument(java.net.URL)
117    */
118   public void showDocument(URL url)
119   {
120   }
121
122   /** Does nothing.
123    *
124    * @see java.applet.AppletContext#showDocument(java.net.URL, java.lang.String)
125    */
126   public void showDocument(URL url, String target)
127   {
128   }
129
130   /** Does nothing.
131    *
132    * @see java.applet.AppletContext#showStatus(java.lang.String)
133    */
134   public void showStatus(String message)
135   {
136   }
137
138   /** Does nothing.
139    *
140    * @see java.applet.AppletContext#setStream(java.lang.String, java.io.InputStream)
141    */
142   public void setStream(String key, InputStream stream)
143     throws IOException
144   {
145     throw new IOException("Dummy implementation imposes zero InputStream associations.");
146   }
147
148   /** Returns <code>null</code> for every argument.
149    *
150    * @see java.applet.AppletContext#getStream(java.lang.String)
151    */
152   public InputStream getStream(String key)
153   {
154     return null;
155   }
156
157   /** Returns always an empty iterator.
158    *
159    * @see java.applet.AppletContext#getStreamKeys()
160    */
161   public Iterator getStreamKeys()
162   {
163     return Collections.EMPTY_SET.iterator();
164   }
165 }