summaryrefslogtreecommitdiff
path: root/libjava
diff options
context:
space:
mode:
authorbryce <bryce@138bc75d-0d04-0410-961f-82ee72b054a4>2000-07-12 04:52:04 +0000
committerbryce <bryce@138bc75d-0d04-0410-961f-82ee72b054a4>2000-07-12 04:52:04 +0000
commitc35976e341c4554ecd5b8b336d44de832ad2dbf5 (patch)
tree13e77f853dc420bd2d5c2ba1f17193850b06429c /libjava
parent1caefcbd48691a28dd440d07ae34f4d4c4c3355f (diff)
downloadgcc-c35976e341c4554ecd5b8b336d44de832ad2dbf5.tar.gz
2000-07-12 Bryce McKinlay <bryce@albatross.co.nz>
Merged implementation of java.applet from classpath: * java/applet/Applet.java: New file. * java/applet/AppletContext.java: New file. * java/applet/AppletStub.java: New file. * java/applet/AudioClip.java: New file. * Makefile.am: Added new java.applet classes. * Makefile.in: Rebuilt. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@34981 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava')
-rw-r--r--libjava/ChangeLog11
-rw-r--r--libjava/Makefile.am4
-rw-r--r--libjava/Makefile.in6
-rw-r--r--libjava/java/applet/Applet.java296
-rw-r--r--libjava/java/applet/AppletContext.java108
-rw-r--r--libjava/java/applet/AppletStub.java88
-rw-r--r--libjava/java/applet/AudioClip.java53
7 files changed, 566 insertions, 0 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog
index e99ca616fa5..ce60672ce10 100644
--- a/libjava/ChangeLog
+++ b/libjava/ChangeLog
@@ -1,5 +1,16 @@
2000-07-12 Bryce McKinlay <bryce@albatross.co.nz>
+ Merged implementation of java.applet from classpath:
+ * java/applet/Applet.java: New file.
+ * java/applet/AppletContext.java: New file.
+ * java/applet/AppletStub.java: New file.
+ * java/applet/AudioClip.java: New file.
+
+ * Makefile.am: Added new java.applet classes.
+ * Makefile.in: Rebuilt.
+
+2000-07-12 Bryce McKinlay <bryce@albatross.co.nz>
+
AWT Stuff:
* java/util/ResourceBundle.java (getLocale): stub.
* Makefile.am: Added new AWT classes.
diff --git a/libjava/Makefile.am b/libjava/Makefile.am
index e48a35b24a3..f0a1a646896 100644
--- a/libjava/Makefile.am
+++ b/libjava/Makefile.am
@@ -660,6 +660,10 @@ gnu/java/lang/ClassHelper.java \
gnu/java/security/provider/Gnu.java \
gnu/java/security/provider/SHA.java \
gnu/java/security/provider/SHA1PRNG.java \
+java/applet/Applet.java \
+java/applet/AppletStub.java \
+java/applet/AppletContext.java \
+java/applet/AudioClip.java \
java/io/BufferedInputStream.java \
java/io/BufferedOutputStream.java \
java/io/BufferedReader.java \
diff --git a/libjava/Makefile.in b/libjava/Makefile.in
index 3657a60d5d6..def9d6fc963 100644
--- a/libjava/Makefile.in
+++ b/libjava/Makefile.in
@@ -430,6 +430,10 @@ gnu/java/lang/ClassHelper.java \
gnu/java/security/provider/Gnu.java \
gnu/java/security/provider/SHA.java \
gnu/java/security/provider/SHA1PRNG.java \
+java/applet/Applet.java \
+java/applet/AppletStub.java \
+java/applet/AppletContext.java \
+java/applet/AudioClip.java \
java/io/BufferedInputStream.java \
java/io/BufferedOutputStream.java \
java/io/BufferedReader.java \
@@ -1011,6 +1015,8 @@ DEP_FILES = .deps/$(srcdir)/$(CONVERT_DIR)/gen-from-JIS.P \
.deps/gnu/java/security/provider/Gnu.P \
.deps/gnu/java/security/provider/SHA.P \
.deps/gnu/java/security/provider/SHA1PRNG.P .deps/interpret.P \
+.deps/java/applet/Applet.P .deps/java/applet/AppletContext.P \
+.deps/java/applet/AppletStub.P .deps/java/applet/AudioClip.P \
.deps/java/awt/AWTError.P .deps/java/awt/AWTEvent.P \
.deps/java/awt/AWTEventMulticaster.P .deps/java/awt/AWTException.P \
.deps/java/awt/ActiveEvent.P .deps/java/awt/Adjustable.P \
diff --git a/libjava/java/applet/Applet.java b/libjava/java/applet/Applet.java
new file mode 100644
index 00000000000..fe962394bc9
--- /dev/null
+++ b/libjava/java/applet/Applet.java
@@ -0,0 +1,296 @@
+/* Applet.java -- Java base applet class
+ Copyright (C) 1999 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
+
+
+package java.applet;
+
+import java.awt.Dimension;
+import java.awt.Image;
+import java.net.URL;
+import java.util.Locale;
+
+/**
+ * This is the base applet class. An applet is a Java program that
+ * runs inside a web browser or other applet viewer in a restricted
+ * environment.
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
+ */
+public class Applet extends java.awt.Panel implements java.io.Serializable
+{
+ // The applet stub for this applet
+ private AppletStub stub;
+
+ /**
+ * Default constructor for subclasses.
+ */
+ public Applet() {}
+
+ /**
+ * Returns the URL of the document this applet is embedded in.
+ *
+ * @return The URL of the document this applet is embedded in.
+ */
+ public URL getDocumentBase()
+ {
+ return (stub.getDocumentBase ());
+ }
+
+ /**
+ * Returns the URL of the code base for this applet.
+ *
+ * @return The URL of the code base for this applet.
+ */
+ public URL getCodeBase()
+ {
+ return (stub.getCodeBase ());
+ }
+
+ /**
+ * Returns the value of the specified parameter that was specified in
+ * the &lt;APPLET&gt; tag for this applet.
+ *
+ * @param name The parameter name.
+ *
+ * @param value The parameter value, or <code>null</code> if the parameter
+ * does not exist.
+ */
+ public String getParameter(String name)
+ {
+ return (stub.getParameter (name));
+ }
+
+ /**
+ * Returns the applet context for this applet.
+ *
+ * @return The applet context for this applet.
+ */
+ public AppletContext getAppletContext()
+ {
+ return (stub.getAppletContext ());
+ }
+
+ /**
+ * Tests whether or not this applet is currently active.
+ *
+ * @return <code>true</code> if this applet is active, <code>false</code>
+ * otherwise.
+ */
+ public boolean isActive()
+ {
+ return (stub.isActive ());
+ }
+
+ /**
+ * Requests that the applet window for this applet be resized.
+ *
+ * @param width The new width in pixels.
+ * @param height The new height in pixels.
+ */
+ public void resize(int width, int height)
+ {
+ stub.appletResize (width, height);
+ }
+
+ /**
+ * Requests that the applet window for this applet be resized.
+ *
+ * @param dim The <code>Dimension</code> object with the requested
+ * width and height.
+ */
+ public void resize(Dimension dim)
+ {
+ resize (dim.width, dim.height);
+ }
+
+ /**
+ * Returns an audio clip from the specified URL.
+ *
+ * @param url The URL of the audio clip.
+ *
+ * @return The retrieved audio clip.
+ */
+ public AudioClip getAudioClip(URL url)
+ {
+ return (getAppletContext ().getAudioClip (url));
+ }
+
+ /**
+ * Returns an audio clip from the specified URL and name
+ *
+ * @param url The base URL of the audio clip.
+ * @param name The name of the clip relative to the URL.
+ *
+ * @return The retrieved audio clip.
+ */
+ public AudioClip getAudioClip(URL url, String name)
+ {
+ try
+ {
+ return (getAppletContext ().getAudioClip (new URL (url.toExternalForm()
+ + name)));
+ }
+ catch(Exception e)
+ {
+ return (getAudioClip (url));
+ }
+ }
+
+ /**
+ * Loads and plays the audio clip pointed to by the specified URL.
+ *
+ * @param The URL of the audio clip.
+ */
+ public void play (URL url)
+ {
+ getAudioClip (url).play ();
+ }
+
+ /**
+ * Loads and plays the audio clip pointed to by the specified URL.
+ *
+ * @param The base URL of the audio clip.
+ * @param name The name of the audio clip relative to the URL.
+ */
+ public void play (URL url, String name)
+ {
+ getAudioClip (url, name).play ();
+ }
+
+ /**
+ * Returns an image from the specified URL. Note that the image is not
+ * actually retrieved until the applet attempts to display it, so this
+ * method returns immediately.
+ *
+ * @param url The URL of the image.
+ *
+ * @return The retrieved image.
+ */
+ public Image getImage(URL url)
+ {
+ return (getAppletContext ().getImage (url));
+ }
+
+ /**
+ * Returns an image from the specified URL. Note that the image is not
+ * actually retrieved until the applet attempts to display it, so this
+ * method returns immediately.
+ *
+ * @param url The base URL of the image.
+ * @param name The name of the image relative to the URL.
+ *
+ * @return The retrieved image.
+ */
+ public Image getImage(URL url, String name)
+ {
+ try
+ {
+ return (getAppletContext ().getImage (new URL (url.toExternalForm()
+ + name)));
+ }
+ catch(Exception e)
+ {
+ return (getImage (url));
+ }
+ }
+
+ /**
+ * Returns the locale for this applet, if it has been set. If no applet
+ * specific locale has been set, the default locale is returned.
+ *
+ * @return The locale for this applet.
+ */
+ public Locale getLocale()
+ {
+ return (super.getLocale ());
+ }
+
+ /**
+ * Returns a descriptive string with applet defined information. The
+ * implementation in this class returns <code>null</code>. Applets who
+ * wish to return this information should override.
+ *
+ * @return A string describing the applet.
+ */
+ public String getAppletInfo()
+ {
+ return (null);
+ }
+
+ /**
+ * Returns a list of parameters this applet supports. Each element of
+ * the array is a list of three strings with the name of the parameter,
+ * the data type or valid values, and a description. This method is
+ * optional and the default implementation returns <code>null</code>.
+ *
+ * @return The list of parameters supported by this applet.
+ */
+ public String[][] getParameterInfo()
+ {
+ return (null);
+ }
+
+ /**
+ * This method is called when the applet is first loaded. The default
+ * implementation does nothing. Applets that wish to do one time
+ * initialization should override.
+ */
+ public void init() {}
+
+ /**
+ * This method is called when the applet is being unloaded. The default
+ * implementation does nothing. Applets that need to clean up resources
+ * on exit should override.
+ */
+ public void destroy() {}
+
+ /**
+ * This method is called when the applet should start running. This is
+ * normally each time a web page containing it is loaded. The default
+ * implemention does nothing. Subclasses should override.
+ */
+ public void start() {}
+
+ /**
+ * This method is called when the applet should stop running. This is
+ * normally when the next web page is loaded. The default implementation
+ * does nothing.
+ */
+ public void stop() {}
+
+ /**
+ * The browser calls this method to set the applet's stub, which is the
+ * low level interface to the browser.
+ *
+ * @param stub The applet stub for this applet.
+ */
+ public final void setStub (AppletStub stub)
+ {
+ this.stub = stub;
+ }
+
+} // class Applet
+
diff --git a/libjava/java/applet/AppletContext.java b/libjava/java/applet/AppletContext.java
new file mode 100644
index 00000000000..e8c2c935b39
--- /dev/null
+++ b/libjava/java/applet/AppletContext.java
@@ -0,0 +1,108 @@
+/* AppletContext.java -- Access the applet's runtime environment.
+ Copyright (C) 1999 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
+
+
+package java.applet;
+
+import java.awt.Image;
+import java.net.URL;
+import java.util.Enumeration;
+
+/**
+ * This interface allows an applet access to the browser to retrieve
+ * additional data files and display documents. It also allows the
+ * applet to find out other applets in the same document.
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
+ */
+public interface AppletContext
+{
+ /**
+ * Returns an audio clip from the specified URL.
+ *
+ * @param url The URL of the audio clip.
+ *
+ * @return The retrieved audio clip // FIXME: What happens on error?
+ */
+ AudioClip getAudioClip(URL url);
+
+ /**
+ * Returns an image from the specified URL. Note that the image is not
+ * actually retrieved until the applet attempts to display it, so this
+ * method returns immediately.
+ *
+ * @param url The URL of the image.
+ *
+ * @return The retrieved image. // FIXME: What happens on eror?
+ */
+ Image getImage(URL url);
+
+ /**
+ * Returns the applet in the document for this object that has the
+ * specified name.
+ *
+ * @param name The applet name.
+ *
+ * @return The requested applet, or <code>null</code> if an applet with
+ * the requested name cannot be found.
+ */
+ Applet getApplet(String name);
+
+ /**
+ * Returns a list of all the applets in the document for this object.
+ *
+ * @return A list of all the applets in the document for this object.
+ */
+ Enumeration getApplets();
+
+ /**
+ * Displays the web page pointed to by the specified URL in the window
+ * for this object. This page replaces the document that is currently
+ * there.
+ *
+ * @param url The URL of the web page to load.
+ */
+ void showDocument(URL url);
+
+ /**
+ * Displays the web page pointed to be the sepcified URL in the window
+ * with the specified name. The standard names "_top", "_blank",
+ * "_parent", and "_self" are allowed.
+ *
+ * @param url The URL of the web page to load.
+ * @param target The target window.
+ */
+ void showDocument(URL url, String target);
+
+ /**
+ * Displays the specified message in the status window if that window
+ * exists.
+ *
+ * @param message The status message.
+ */
+ void showStatus(String message);
+
+} // interface AppletContext
diff --git a/libjava/java/applet/AppletStub.java b/libjava/java/applet/AppletStub.java
new file mode 100644
index 00000000000..26842647369
--- /dev/null
+++ b/libjava/java/applet/AppletStub.java
@@ -0,0 +1,88 @@
+/* AppletStub.java -- Low level interface to the browser.
+ Copyright (C) 1999 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
+
+package java.applet;
+
+import java.net.URL;
+
+/**
+ * This interface is the low level interface between the applet and the
+ * browser.
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
+ */
+public interface AppletStub
+{
+ /**
+ * Returns the URL of the document this applet is embedded in.
+ *
+ * @return The URL of the document this applet is embedded in.
+ */
+ URL getDocumentBase();
+
+ /**
+ * Returns the URL of the code base for this applet.
+ *
+ * @return The URL of the code base for this applet.
+ */
+ URL getCodeBase();
+
+ /**
+ * Returns the value of the specified parameter that was specified in
+ * the &lt;APPLET&gt; tag for this applet.
+ *
+ * @param name The parameter name.
+ *
+ * @param value The parameter value, or <code>null</code> if the parameter
+ * does not exist.
+ */
+ String getParameter(String name);
+
+ /**
+ * Returns the applet context for this applet.
+ *
+ * @return The applet context for this applet.
+ */
+ AppletContext getAppletContext();
+
+ /**
+ * Tests whether or not this applet is currently active.
+ *
+ * @return <code>true</code> if this applet is active, <code>false</code>
+ * otherwise.
+ */
+ boolean isActive();
+
+ /**
+ * Requests that the applet window for this applet be resized.
+ *
+ * @param width The new width in pixels.
+ * @param height The new height in pixels.
+ */
+ void appletResize(int width, int height);
+
+} // interface AppletStub
+
diff --git a/libjava/java/applet/AudioClip.java b/libjava/java/applet/AudioClip.java
new file mode 100644
index 00000000000..add9748c090
--- /dev/null
+++ b/libjava/java/applet/AudioClip.java
@@ -0,0 +1,53 @@
+/* AudioClip.java -- Play an audio clip.
+ Copyright (C) 1999 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+As a special exception, if you link this library with other files to
+produce an executable, this library does not by itself cause the
+resulting executable to be covered by the GNU General Public License.
+This exception does not however invalidate any other reasons why the
+executable file might be covered by the GNU General Public License. */
+
+
+package java.applet;
+
+/**
+ * This interface provides a simple mechanism for playing audio clips.
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
+ */
+public interface AudioClip
+{
+ /**
+ * Plays the audio clip starting from the beginning.
+ */
+ void play();
+
+ /**
+ * Stops playing this audio clip. There is no mechanism for restarting
+ * at the point where the clip is stopped.
+ */
+ void stop();
+
+ /**
+ * Plays this audio clip in a continuous loop.
+ */
+ void loop();
+
+} // interface AudioClip