aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libjava/ChangeLog21
-rw-r--r--libjava/Makefile.am10
-rw-r--r--libjava/Makefile.in21
-rw-r--r--libjava/java/awt/PrintGraphics.java59
-rw-r--r--libjava/java/awt/PrintJob.java128
-rw-r--r--libjava/java/awt/Toolkit.java1048
-rw-r--r--libjava/java/awt/datatransfer/Clipboard.java135
-rw-r--r--libjava/java/awt/datatransfer/ClipboardOwner.java60
-rw-r--r--libjava/java/awt/datatransfer/DataFlavor.java982
-rw-r--r--libjava/java/awt/datatransfer/FlavorMap.java82
-rw-r--r--libjava/java/awt/datatransfer/MimeTypeParseException.java70
-rw-r--r--libjava/java/awt/datatransfer/StringSelection.java159
-rw-r--r--libjava/java/awt/datatransfer/SystemFlavorMap.java180
-rw-r--r--libjava/java/awt/datatransfer/Transferable.java92
-rw-r--r--libjava/java/awt/datatransfer/UnsupportedFlavorException.java62
15 files changed, 2858 insertions, 251 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog
index 3db9ddc..e4aa692 100644
--- a/libjava/ChangeLog
+++ b/libjava/ChangeLog
@@ -2,6 +2,27 @@
* Makefile.in: Rebuilt.
* Makefile.am (awt_java_source_files): Added new files.
+ * java/awt/Toolkit.java: Merged with Classpath.
+ * java/awt/PrintGraphics.java: New file from Classpath.
+ * java/awt/PrintJob.java: New file from Classpath.
+ * java/awt/datatransfer/Clipboard.java: New file from Classpath.
+ * java/awt/datatransfer/ClipboardOwner.java: New file from
+ Classpath.
+ * java/awt/datatransfer/DataFlavor.java: New file from Classpath.
+ * java/awt/datatransfer/FlavorMap.java: New file from Classpath.
+ * java/awt/datatransfer/MimeTypeParseException.java: New file from
+ Classpath.
+ * java/awt/datatransfer/StringSelection.java: New file from
+ Classpath.
+ * java/awt/datatransfer/SystemFlavorMap.java: New file from
+ Classpath.
+ * java/awt/datatransfer/Transferable.java: New file from
+ Classpath.
+ * java/awt/datatransfer/UnsupportedFlavorException.java: New file
+ from Classpath.
+
+ * Makefile.in: Rebuilt.
+ * Makefile.am (awt_java_source_files): Added new files.
* java/awt/image/AreaAveragingScaleFilter.java: New file from
Classpath.
* java/awt/image/CropImageFilter.java: New file from Classpath.
diff --git a/libjava/Makefile.am b/libjava/Makefile.am
index e93dd94..3d71f33 100644
--- a/libjava/Makefile.am
+++ b/libjava/Makefile.am
@@ -661,6 +661,8 @@ java/awt/Panel.java \
java/awt/Point.java \
java/awt/Polygon.java \
java/awt/PopupMenu.java \
+java/awt/PrintGraphics.java \
+java/awt/PrintJob.java \
java/awt/Rectangle.java \
java/awt/RenderingHints.java \
java/awt/ScrollPane.java \
@@ -677,6 +679,14 @@ java/awt/color/ColorSpace.java \
java/awt/color/ICC_ColorSpace.java \
java/awt/color/ICC_Profile.java \
java/awt/datatransfer/Clipboard.java \
+java/awt/datatransfer/ClipboardOwner.java \
+java/awt/datatransfer/DataFlavor.java \
+java/awt/datatransfer/FlavorMap.java \
+java/awt/datatransfer/MimeTypeParseException.java \
+java/awt/datatransfer/StringSelection.java \
+java/awt/datatransfer/SystemFlavorMap.java \
+java/awt/datatransfer/Transferable.java \
+java/awt/datatransfer/UnsupportedFlavorException.java \
java/awt/event/AWTEventListener.java \
java/awt/event/ActionEvent.java \
java/awt/event/ActionListener.java \
diff --git a/libjava/Makefile.in b/libjava/Makefile.in
index f575753..66494d9 100644
--- a/libjava/Makefile.in
+++ b/libjava/Makefile.in
@@ -412,6 +412,8 @@ java/awt/Panel.java \
java/awt/Point.java \
java/awt/Polygon.java \
java/awt/PopupMenu.java \
+java/awt/PrintGraphics.java \
+java/awt/PrintJob.java \
java/awt/Rectangle.java \
java/awt/RenderingHints.java \
java/awt/ScrollPane.java \
@@ -428,6 +430,14 @@ java/awt/color/ColorSpace.java \
java/awt/color/ICC_ColorSpace.java \
java/awt/color/ICC_Profile.java \
java/awt/datatransfer/Clipboard.java \
+java/awt/datatransfer/ClipboardOwner.java \
+java/awt/datatransfer/DataFlavor.java \
+java/awt/datatransfer/FlavorMap.java \
+java/awt/datatransfer/MimeTypeParseException.java \
+java/awt/datatransfer/StringSelection.java \
+java/awt/datatransfer/SystemFlavorMap.java \
+java/awt/datatransfer/Transferable.java \
+java/awt/datatransfer/UnsupportedFlavorException.java \
java/awt/event/AWTEventListener.java \
java/awt/event/ActionEvent.java \
java/awt/event/ActionListener.java \
@@ -2028,7 +2038,8 @@ DEP_FILES = .deps/$(srcdir)/$(CONVERT_DIR)/gen-from-JIS.P \
.deps/java/awt/MenuItem.P .deps/java/awt/MenuShortcut.P \
.deps/java/awt/Paint.P .deps/java/awt/PaintContext.P \
.deps/java/awt/Panel.P .deps/java/awt/Point.P .deps/java/awt/Polygon.P \
-.deps/java/awt/PopupMenu.P .deps/java/awt/Rectangle.P \
+.deps/java/awt/PopupMenu.P .deps/java/awt/PrintGraphics.P \
+.deps/java/awt/PrintJob.P .deps/java/awt/Rectangle.P \
.deps/java/awt/RenderingHints.P .deps/java/awt/ScrollPane.P \
.deps/java/awt/Scrollbar.P .deps/java/awt/Shape.P \
.deps/java/awt/SystemColor.P .deps/java/awt/TextArea.P \
@@ -2038,6 +2049,14 @@ DEP_FILES = .deps/$(srcdir)/$(CONVERT_DIR)/gen-from-JIS.P \
.deps/java/awt/color/ICC_ColorSpace.P \
.deps/java/awt/color/ICC_Profile.P \
.deps/java/awt/datatransfer/Clipboard.P \
+.deps/java/awt/datatransfer/ClipboardOwner.P \
+.deps/java/awt/datatransfer/DataFlavor.P \
+.deps/java/awt/datatransfer/FlavorMap.P \
+.deps/java/awt/datatransfer/MimeTypeParseException.P \
+.deps/java/awt/datatransfer/StringSelection.P \
+.deps/java/awt/datatransfer/SystemFlavorMap.P \
+.deps/java/awt/datatransfer/Transferable.P \
+.deps/java/awt/datatransfer/UnsupportedFlavorException.P \
.deps/java/awt/event/AWTEventListener.P \
.deps/java/awt/event/ActionEvent.P \
.deps/java/awt/event/ActionListener.P \
diff --git a/libjava/java/awt/PrintGraphics.java b/libjava/java/awt/PrintGraphics.java
new file mode 100644
index 0000000..3d1ee63
--- /dev/null
+++ b/libjava/java/awt/PrintGraphics.java
@@ -0,0 +1,59 @@
+/* PrintGraphics.java -- A print graphics context.
+ 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.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.awt;
+
+/**
+ * This interface allows the originating print job to be obtained.
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
+ */
+public interface PrintGraphics
+{
+
+/**
+ * Returns the <code>PrintJob</code> that this object is being
+ * managed by.
+ *
+ * @return The print job for this object.
+ */
+public abstract PrintJob
+getPrintJob();
+
+} // interface PrintGraphics
+
diff --git a/libjava/java/awt/PrintJob.java b/libjava/java/awt/PrintJob.java
new file mode 100644
index 0000000..4e6ae29
--- /dev/null
+++ b/libjava/java/awt/PrintJob.java
@@ -0,0 +1,128 @@
+/* PrintJob.java -- A print job 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.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.awt;
+
+/**
+ * This abstract class represents a print job.
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
+ */
+public abstract class PrintJob
+{
+
+/*
+ * Constructors
+ */
+
+/**
+ * This method initializes a new instance of <code>PrintJob</code>.
+ */
+public
+PrintJob()
+{
+}
+
+/*************************************************************************/
+
+/*
+ * Instance Methods
+ */
+
+/**
+ * Returns a graphics context suitable for rendering the next page.
+ *
+ * @return A graphics context for printing the next page.
+ */
+public abstract Graphics
+getGraphics();
+
+/*************************************************************************/
+
+/**
+ * Returns the dimension of the page in pixels. The resolution will be
+ * chosen to be similar to the on screen image.
+ *
+ * @return The page dimensions.
+ */
+public abstract Dimension
+getPageDimension();
+
+/*************************************************************************/
+
+/**
+ * Returns the resolution of the page in pixels per inch.
+ *
+ * @return The resolution of the page in pixels per inch.
+ */
+public abstract int
+getPageResolution();
+
+/*************************************************************************/
+
+/**
+ * Tests whether or not the last page will be printed first.
+ *
+ * @return <code>true</code> if the last page prints first, <code>false</code>
+ * otherwise.
+ */
+public abstract boolean
+lastPageFirst();
+
+/*************************************************************************/
+
+/**
+ * Informs the print job that printing is complete.
+ */
+public abstract void
+end();
+
+/*************************************************************************/
+
+/**
+ * This method explicitly ends the print job in the event the job
+ * becomes un-referenced without the application having done so.
+ */
+public void
+finalize()
+{
+ end();
+}
+
+} // class PrintJob
+
diff --git a/libjava/java/awt/Toolkit.java b/libjava/java/awt/Toolkit.java
index 85a38f2..4c59138 100644
--- a/libjava/java/awt/Toolkit.java
+++ b/libjava/java/awt/Toolkit.java
@@ -1,263 +1,825 @@
-/* Copyright (C) 1999, 2000 Free Software Foundation
+/* Toolkit.java -- AWT Toolkit superclass
+ Copyright (C) 1999, 2000, 2001, 2002 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.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
- This file is part of libjava.
-
-This software is copyrighted work licensed under the terms of the
-Libjava License. Please consult the file "LIBJAVA_LICENSE" for
-details. */
package java.awt;
-import java.awt.peer.*;
+
import java.awt.event.*;
-import java.net.URL;
-import java.beans.*;
+import java.awt.peer.*;
import java.awt.image.*;
import java.awt.datatransfer.Clipboard;
-import java.util.Hashtable;
-import gnu.java.awt.GLightweightPeer;
-
-/* A very incomplete placeholder. */
+import java.util.Properties;
+import java.net.URL;
+import java.beans.*;
+/**
+ * The AWT system uses a set of native peer objects to implement its
+ * widgets. These peers are provided by a peer toolkit, that is accessed
+ * via a subclass of this superclass. The system toolkit is retrieved
+ * by the static methods <code>getDefaultToolkit</code>. This method
+ * determines the system toolkit by examining the system property
+ * <code>awt.toolkit</code>. That property is set to the name of the
+ * <code>Toolkit</code> subclass for the specified peer set. If the
+ * <code>awt.toolkit</code> property is not set, then the default
+ * toolkit <code>gnu.java.awt.peer.gtk.GtkToolkit</code> is used. This
+ * toolkit creates its peers using the GTK+ toolkit.
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
+ */
public abstract class Toolkit
{
- static Toolkit defaultToolkit;
- PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
- Hashtable desktopProperties = new Hashtable();
-
- public static Toolkit getDefaultToolkit()
- {
- if (defaultToolkit != null)
- return defaultToolkit;
-
- Class toolkit_class;
- String tk_class_name = System.getProperty("awt.toolkit");
- if (tk_class_name == null)
- tk_class_name = "gnu.awt.gtk.GtkToolkit";
-
- try
+
+/*
+ * Static Variables
+ */
+
+// The default toolkit name.
+private static String default_toolkit_name =
+ "gnu.java.awt.peer.gtk.GtkToolkit";
+
+// The toolkit in use. Once we load it, we don't ever change it
+// if the awt.toolkit propert is set.
+private static Toolkit toolkit;
+
+// The toolkit properties
+private static Properties props = new Properties();
+
+private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
+
+private Properties desktopProperties = new Properties();
+
+/*************************************************************************/
+
+/*
+ * Static Methods
+ */
+
+/**
+ * Returns an instance of the default toolkit. The default toolkit is
+ * the subclass of <code>Toolkit</code> specified in the system property
+ * <code>awt.toolkit</code>, or <code>gnu.java.awt.peer.gtk.GtkToolkit</code>
+ * if the property is not set.
+ *
+ * @return An instance of the system default toolkit.
+ *
+ * @error AWTError If the toolkit cannot be loaded.
+ */
+public static Toolkit
+getDefaultToolkit()
+{
+ if (toolkit != null)
+ return(toolkit);
+
+ String toolkit_name = System.getProperty("awt.toolkit",
+ default_toolkit_name);
+
+ try
{
- toolkit_class = Class.forName(tk_class_name);
- defaultToolkit = (Toolkit) toolkit_class.newInstance();
+ Class cls = Class.forName(toolkit_name);
+ Object obj = cls.newInstance();
+
+ if (!(obj instanceof Toolkit))
+ throw new AWTError(toolkit_name + " is not a subclass of " +
+ "java.awt.Toolkit");
+
+ toolkit = (Toolkit)obj;
+ return(toolkit);
}
- catch (Exception x)
+ catch(Exception e)
{
- throw new AWTError("Toolkit class " + tk_class_name +
- " could not be initialized:\n " + x);
+ throw new AWTError("Cannot load AWT toolkit: " + e.getMessage());
}
+}
- return defaultToolkit;
- }
-
- protected abstract ButtonPeer createButton(Button target);
- protected abstract TextFieldPeer createTextField(TextField target);
- protected abstract LabelPeer createLabel(Label target);
- protected abstract ListPeer createList(List target);
- protected abstract CheckboxPeer createCheckbox(Checkbox target);
- protected abstract ScrollbarPeer createScrollbar(Scrollbar target);
- protected abstract ScrollPanePeer createScrollPane(ScrollPane target);
- protected abstract TextAreaPeer createTextArea(TextArea target);
- protected abstract ChoicePeer createChoice(Choice target);
- protected abstract FramePeer createFrame(Frame target);
- protected abstract CanvasPeer createCanvas(Canvas target);
- protected abstract PanelPeer createPanel(Panel target);
- protected abstract WindowPeer createWindow(Window target);
- protected abstract DialogPeer createDialog(Dialog target);
- protected abstract MenuBarPeer createMenuBar(MenuBar target);
- protected abstract MenuPeer createMenu(Menu target);
- protected abstract PopupMenuPeer createPopupMenu(PopupMenu target);
- protected abstract MenuItemPeer createMenuItem(MenuItem target);
- protected abstract FileDialogPeer createFileDialog(FileDialog target);
- protected abstract CheckboxMenuItemPeer
- createCheckboxMenuItem(CheckboxMenuItem target);
-
- protected LightweightPeer createComponent(Component target)
- {
- return GLightweightPeer.INSTANCE;
- }
-
- /* @deprecated Use GraphicsEnvironment.getAllFonts() */
- protected abstract java.awt.peer.FontPeer getFontPeer(String name, int style);
-
- /*
- public abstract DragSourceContextPeer
- createDragSourceContextPeer(DragGestureEvent dge)
- throws InvalidDnDOperationException;
+/*************************************************************************/
+
+/**
+ * Returns the value of the property with the specified name, or the
+ * default value if the property does not exist.
+ *
+ * @param key The name of the property to retrieve.
+ * @param defThe default value of the property.
*/
-
- protected void loadSystemColors(int[] systemColors)
- {
- // FIXME
- }
-
- public abstract Dimension getScreenSize();
- public abstract int getScreenResolution();
- public abstract ColorModel getColorModel();
- /* @deprecated Use GraphicsEnvironment.getAvailableFontFamilyNames() */
- public abstract String[] getFontList();
- public abstract FontMetrics getFontMetrics(Font font);
- public abstract void sync();
- public abstract Image getImage(String filename);
- public abstract Image getImage(URL url);
- public abstract Image createImage(String filename);
- public abstract Image createImage(URL url);
- public abstract boolean prepareImage(Image image, int width, int height,
- ImageObserver observer);
- public abstract int checkImage(Image image, int width, int height,
- ImageObserver observer);
- public abstract Image createImage(ImageProducer producer);
-
- public Image createImage(byte[] imagedata)
- {
- return createImage (imagedata, 0, imagedata.length);
- }
-
- public abstract Image createImage(byte[] imagedata, int imageoffset,
- int imagelength);
- /*
- public abstract PrintJob getPrintJob(Frame frame, String jobtitle,
- Properties props);
- public PrintJob getPrintJob(Frame frame, String jobtitle,
- JobAttributes jobAttributes,
- PageAttributes pageAttributes)
- {
-
- }
+public static String
+getProperty(String key, String def)
+{
+ return(props.getProperty(key, def));
+}
+
+/*************************************************************************/
+
+/**
+ * Returns the native container object of the specified component. This
+ * method is necessary because the parent component might be a lightweight
+ * component.
+ *
+ * @param component The component to fetch the native container for.
+ *
+ * @return The native container object for this component.
*/
-
- public abstract void beep();
- public abstract Clipboard getSystemClipboard();
-
- public int getMenuShortcutKeyMask()
- {
- return InputEvent.CTRL_MASK;
- }
-
- public boolean getLockingKeyState(int keyCode)
- {
- if (keyCode != KeyEvent.VK_CAPS_LOCK
- && keyCode != KeyEvent.VK_NUM_LOCK
- && keyCode != KeyEvent.VK_SCROLL_LOCK)
- throw new IllegalArgumentException();
-
- throw new UnsupportedOperationException();
- }
-
- public void setLockingKeyState(int keyCode, boolean on)
- {
- if (keyCode != KeyEvent.VK_CAPS_LOCK
- && keyCode != KeyEvent.VK_NUM_LOCK
- && keyCode != KeyEvent.VK_SCROLL_LOCK)
- throw new IllegalArgumentException();
-
- throw new UnsupportedOperationException();
- }
-
- protected static Container getNativeContainer(Component c)
- {
- while (c != null)
- {
- if (!c.isLightweight ())
- return (Container) c;
+protected static Container
+getNativeContainer(Component component)
+{
+ component = component.getParent();
- c = c.getParent();
+ for(;;)
+ {
+ if (component == null)
+ return(null);
+
+ if (!(component instanceof Container))
+ {
+ component = component.getParent();
+ continue;
+ }
+
+ if (component.getPeer() instanceof LightweightPeer)
+ {
+ component = component.getParent();
+ continue;
+ }
+
+ return((Container)component);
}
- return null;
- }
-
- public Cursor createCustomCursor(Image cursor, Point hotSpot, String name)
- throws IndexOutOfBoundsException
- {
- // Presumably the only reason this isn't abstract is for backwards
- // compatibility? FIXME?
- return null;
- }
-
- public Dimension getBestCursorSize(int preferredWidth, int preferredHeight)
- {
- return new Dimension (0,0);
- }
-
- public int getMaximumCursorColors()
- {
- return 0;
- }
-
- public static String getProperty(String key, String defaultValue)
- {
- // FIXME
- return defaultValue;
- }
-
- public final EventQueue getSystemEventQueue()
- {
- return getSystemEventQueueImpl();
- }
-
- protected abstract EventQueue getSystemEventQueueImpl();
-
- /*
- public DragGestureRecognizer
- createDragGestureRecognizer(Class abstractRecognizerClass, DragSource ds,
- Component c, int srcActions,
- DragGestureListener dgl)
- {
- // err... FIXME
- return null;
- }
- */
-
- public final Object getDesktopProperty(String propertyName)
- {
- return desktopProperties.get(propertyName);
- }
-
- protected final void setDesktopProperty(String name, Object newValue)
- {
- Object oldValue = getDesktopProperty(name);
- desktopProperties.put(name, newValue);
- changeSupport.firePropertyChange(name, oldValue, newValue);
- }
-
- protected Object lazilyLoadDesktopProperty(String name)
- {
- // FIXME - what is this??
- return null;
- }
-
- protected void initializeDesktopProperties()
- {
- // Overridden by toolkit implementation?
- }
-
- public void addPropertyChangeListener(String name,
- PropertyChangeListener pcl)
- {
- changeSupport.addPropertyChangeListener(name, pcl);
- }
-
- public void removePropertyChangeListener(String name,
- PropertyChangeListener pcl)
- {
- changeSupport.removePropertyChangeListener(name, pcl);
- }
-
- public void addAWTEventListener(AWTEventListener listener, long eventMask)
- {
- // SecurityManager s = System.getSecurityManager();
- // if (s != null)
- // s.checkPermission(AWTPermission("listenToAllAWTEvents"));
-
- // FIXME
- }
-
- public void removeAWTEventListener(AWTEventListener listener)
- {
- // FIXME
- }
-
- /*
- public abstract Map mapInputMethodHighlight(InputMethodHighlight highlight)
- {
- }
+}
+
+/*************************************************************************/
+
+/*
+ * Constructors
+ */
+
+/**
+ * Default constructor for subclasses.
+ */
+public
+Toolkit()
+{
+}
+
+/*************************************************************************/
+
+/*
+ * Instance Methods
+ */
+
+/**
+ * Creates a peer object for the specified <code>Button</code>.
+ *
+ * @param target The <code>Button</code> to create the peer for.
+ *
+ * @return The peer for the specified <code>Button</code> object.
+ */
+protected abstract ButtonPeer
+createButton(Button target);
+
+/*************************************************************************/
+
+/**
+ * Creates a peer object for the specified <code>TextField</code>.
+ *
+ * @param target The <code>TextField</code> to create the peer for.
+ *
+ * @return The peer for the specified <code>TextField</code> object.
+ */
+protected abstract TextFieldPeer
+createTextField(TextField target);
+
+/*************************************************************************/
+
+/**
+ * Creates a peer object for the specified <code>Label</code>.
+ *
+ * @param target The <code>Label</code> to create the peer for.
+ *
+ * @return The peer for the specified <code>Label</code> object.
+ */
+protected abstract LabelPeer
+createLabel(Label target);
+
+/*************************************************************************/
+
+/**
+ * Creates a peer object for the specified <code>List</code>.
+ *
+ * @param target The <code>List</code> to create the peer for.
+ *
+ * @return The peer for the specified <code>List</code> object.
+ */
+protected abstract ListPeer
+createList(List target);
+
+/*************************************************************************/
+
+/**
+ * Creates a peer object for the specified <code>Checkbox</code>.
+ *
+ * @param target The <code>Checkbox</code> to create the peer for.
+ *
+ * @return The peer for the specified <code>Checkbox</code> object.
+ */
+protected abstract CheckboxPeer
+createCheckbox(Checkbox target);
+
+/*************************************************************************/
+
+/**
+ * Creates a peer object for the specified <code>Scrollbar</code>.
+ *
+ * @param target The <code>Scrollbar</code> to create the peer for.
+ *
+ * @return The peer for the specified <code>Scrollbar</code> object.
+ */
+protected abstract ScrollbarPeer
+createScrollbar(Scrollbar target);
+
+/*************************************************************************/
+
+/**
+ * Creates a peer object for the specified <code>ScrollPane</code>.
+ *
+ * @param target The <code>ScrollPane</code> to create the peer for.
+ *
+ * @return The peer for the specified <code>ScrollPane</code> object.
+ */
+protected abstract ScrollPanePeer
+createScrollPane(ScrollPane target);
+
+/*************************************************************************/
+
+/**
+ * Creates a peer object for the specified <code>TextArea</code>.
+ *
+ * @param target The <code>TextArea</code> to create the peer for.
+ *
+ * @return The peer for the specified <code>TextArea</code> object.
+ */
+protected abstract TextAreaPeer
+createTextArea(TextArea target);
+
+/*************************************************************************/
+
+/**
+ * Creates a peer object for the specified <code>Choice</code>.
+ *
+ * @param target The <code>Choice</code> to create the peer for.
+ *
+ * @return The peer for the specified <code>Choice</code> object.
+ */
+protected abstract ChoicePeer
+createChoice(Choice target);
+
+/*************************************************************************/
+
+/**
+ * Creates a peer object for the specified <code>Frame</code>.
+ *
+ * @param target The <code>Frame</code> to create the peer for.
+ *
+ * @return The peer for the specified <code>Frame</code> object.
+ */
+protected abstract FramePeer
+createFrame(Frame target);
+
+/*************************************************************************/
+
+/**
+ * Creates a peer object for the specified <code>Canvas</code>.
+ *
+ * @param target The <code>Canvas</code> to create the peer for.
+ *
+ * @return The peer for the specified <code>Canvas</code> object.
+ */
+protected abstract CanvasPeer
+createCanvas(Canvas target);
+
+/*************************************************************************/
+
+/**
+ * Creates a peer object for the specified <code>Panel</code>.
+ *
+ * @param target The <code>Panel</code> to create the peer for.
+ *
+ * @return The peer for the specified <code>Panel</code> object.
+ */
+protected abstract PanelPeer
+createPanel(Panel target);
+
+/*************************************************************************/
+
+/**
+ * Creates a peer object for the specified <code>Window</code>.
+ *
+ * @param target The <code>Window</code> to create the peer for.
+ *
+ * @return The peer for the specified <code>Window</code> object.
+ */
+protected abstract WindowPeer
+createWindow(Window target);
+
+/*************************************************************************/
+
+/**
+ * Creates a peer object for the specified <code>Dialog</code>.
+ *
+ * @param target The dialog to create the peer for
+ *
+ * @return The peer for the specified font name.
+ */
+protected abstract DialogPeer
+createDialog(Dialog target);
+
+/*************************************************************************/
+
+/**
+ * Creates a peer object for the specified <code>MenuBar</code>.
+ *
+ * @param target The <code>MenuBar</code> to create the peer for.
+ *
+ * @return The peer for the specified <code>MenuBar</code> object.
+ */
+protected abstract MenuBarPeer
+createMenuBar(MenuBar target);
+
+/*************************************************************************/
+
+/**
+ * Creates a peer object for the specified <code>Menu</code>.
+ *
+ * @param target The <code>Menu</code> to create the peer for.
+ *
+ * @return The peer for the specified <code>Menu</code> object.
+ */
+protected abstract MenuPeer
+createMenu(Menu target);
+
+/*************************************************************************/
+
+/**
+ * Creates a peer object for the specified <code>PopupMenu</code>.
+ *
+ * @param target The <code>PopupMenu</code> to create the peer for.
+ *
+ * @return The peer for the specified <code>PopupMenu</code> object.
+ */
+protected abstract PopupMenuPeer
+createPopupMenu(PopupMenu target);
+
+/*************************************************************************/
+
+/**
+ * Creates a peer object for the specified <code>MenuItem</code>.
+ *
+ * @param target The <code>MenuItem</code> to create the peer for.
+ *
+ * @return The peer for the specified <code>MenuItem</code> object.
+ */
+protected abstract MenuItemPeer
+createMenuItem(MenuItem target);
+
+/*************************************************************************/
+
+/**
+ * Creates a peer object for the specified <code>FileDialog</code>.
+ *
+ * @param target The <code>FileDialog</code> to create the peer for.
+ *
+ * @return The peer for the specified <code>FileDialog</code> object.
+ */
+protected abstract FileDialogPeer
+createFileDialog(FileDialog target);
+
+/*************************************************************************/
+
+/**
+ * Creates a peer object for the specified <code>CheckboxMenuItem</code>.
+ *
+ * @param target The <code>CheckboxMenuItem</code> to create the peer for.
+ *
+ * @return The peer for the specified <code>CheckboxMenuItem</code> object.
+ */
+protected abstract CheckboxMenuItemPeer
+createCheckboxMenuItem(CheckboxMenuItem target);
+
+/*************************************************************************/
+
+/**
+ * Creates a peer object for the specified <code>Component</code>. The
+ * peer returned by this method is not a native windowing system peer
+ * with its own native window. Instead, this method allows the component
+ * to draw on its parent window as a "lightweight" widget.
+ *
+ * XXX: FIXME
+ *
+ * @param target The <code>Component</code> to create the peer for.
+ *
+ * @return The peer for the specified <code>Component</code> object.
*/
+protected LightweightPeer
+createComponent(Component target)
+{
+ return null;
+}
+
+/*************************************************************************/
+
+/**
+ * Creates a peer object for the specified font name.
+ *
+ * @param name The font to create the peer for.
+ * @param style The font style to create the peer for.
+ *
+ * @return The peer for the specified font name.
+ */
+protected abstract FontPeer
+getFontPeer(String name, int style);
+
+/*************************************************************************/
+
+/**
+ * Copies the current system colors into the specified array. This is
+ * the interface used by the <code>SystemColors</code> class.
+ *
+ * @param colors The array to copy the system colors into.
+ */
+protected void
+loadSystemColors(int systemColors[])
+{
}
+
+/*************************************************************************/
+
+/**
+ * Returns the dimensions of the screen in pixels.
+ *
+ * @return The dimensions of the screen in pixels.
+ */
+public abstract Dimension
+getScreenSize();
+
+/*************************************************************************/
+
+/**
+ * Returns the screen resolution in dots per square inch.
+ *
+ * @return The screen resolution in dots per square inch.
+ */
+public abstract int
+getScreenResolution();
+
+/*************************************************************************/
+
+/**
+ * Returns the color model of the screen.
+ *
+ * @return The color model of the screen.
+ */
+public abstract ColorModel
+getColorModel();
+
+/*************************************************************************/
+
+/**
+ * Returns the names of the available fonts.
+ *
+ * @return The names of the available fonts.
+ */
+public abstract String[]
+getFontList();
+
+/*************************************************************************/
+
+/**
+ * Return the font metrics for the specified font
+ *
+ * @param name The name of the font to return metrics for.
+ *
+ * @return The requested font metrics.
+ */
+public abstract FontMetrics
+getFontMetrics(Font name);
+
+/*************************************************************************/
+
+/**
+ * Flushes any buffered data to the screen so that it is in sync with
+ * what the AWT system has drawn to it.
+ */
+public abstract void
+sync();
+
+/*************************************************************************/
+
+/**
+ * Returns an image from the specified file, which must be in a
+ * recognized format. Supported formats vary from toolkit to toolkit.
+ *
+ * @return name The name of the file to read the image from.
+ */
+public abstract Image
+getImage(String name);
+
+/*************************************************************************/
+
+/**
+ * Returns an image from the specified URL, which must be in a
+ * recognized format. Supported formats vary from toolkit to toolkit.
+ *
+ * @return url The URl to read the image from.
+ */
+public abstract Image
+getImage(URL url);
+
+/*************************************************************************/
+
+/**
+ * Readies an image to be rendered on the screen. The width and height
+ * values can be set to the default sizes for the image by passing -1
+ * in those parameters.
+ *
+ * @param image The image to prepare for rendering.
+ * @param width The width of the image.
+ * @param height The height of the image.
+ * @param observer The observer to receive events about the preparation
+ * process.
+ *
+ * @return <code>true</code> if the image is already prepared for rendering,
+ * <code>false</code> otherwise.
+ */
+public abstract boolean
+prepareImage(Image image, int width, int height, ImageObserver observer);
+
+/*************************************************************************/
+
+/**
+ * Checks the status of specified image as it is being readied for
+ * rendering.
+ *
+ * @param image The image to prepare for rendering.
+ * @param width The width of the image.
+ * @param height The height of the image.
+ * @param observer The observer to receive events about the preparation
+ * process.
+ *
+ * @return A union of the bitmasks from
+ * <code>java.awt.image.ImageObserver</code> that indicates the current
+ * state of the imaging readying process.
+ */
+public abstract int
+checkImage(Image image, int width, int height, ImageObserver observer);
+
+/*************************************************************************/
+
+/**
+ * Creates an image using the specified <code>ImageProducer</code>
+ *
+ * @param producer The <code>ImageProducer</code> to create the image from.
+ *
+ * @return The created image.
+ */
+public abstract Image
+createImage(ImageProducer producer);
+
+/*************************************************************************/
+
+/**
+ * Creates an image from the specified portion of the byte array passed.
+ * The array must be in a recognized format. Supported formats vary from
+ * toolkit to toolkit.
+ *
+ * @param data The raw image data.
+ * @param offset The offset into the data where the image data starts.
+ * @param len The length of the image data.
+ *
+ * @return The created image.
+ */
+public abstract Image
+createImage(byte[] data, int offset, int len);
+
+/*************************************************************************/
+
+/**
+ * Creates an image from the specified byte array. The array must be in
+ * a recognized format. Supported formats vary from toolkit to toolkit.
+ *
+ * @param data The raw image data.
+ *
+ * @return The created image.
+ */
+public Image
+createImage(byte[] data)
+{
+ return(createImage(data, 0, data.length));
+}
+
+public abstract Image
+createImage(String filename);
+
+public abstract Image
+createImage(URL url);
+
+
+/*************************************************************************/
+
+/**
+ * Returns a instance of <code>PrintJob</code> for the specified
+ * arguments.
+ *
+ * @param frame The window initiating the print job.
+ * @param title The print job title.
+ * @param props The print job properties.
+ *
+ * @return The requested print job, or <code>null</code> if the job
+ * was cancelled.
+ */
+public abstract PrintJob
+getPrintJob(Frame frame, String title, Properties props);
+
+/*************************************************************************/
+
+/**
+ * Returns the system clipboard.
+ *
+ * @return THe system clipboard.
+ */
+public abstract Clipboard
+getSystemClipboard();
+
+/*************************************************************************/
+
+/**
+ * Returns the accelerator key mask for menu shortcuts. The default is
+ * <code>Event.CTRL_MASK</code>. A toolkit must override this method
+ * to change the default.
+ *
+ * @return The key mask for the menu accelerator key.
+ */
+public int
+getMenuShortcutKeyMask()
+{
+ return Event.CTRL_MASK;
+}
+
+public boolean
+getLockingKeyState(int keyCode)
+{
+ if (keyCode != KeyEvent.VK_CAPS_LOCK
+ && keyCode != KeyEvent.VK_NUM_LOCK
+ && keyCode != KeyEvent.VK_SCROLL_LOCK)
+ throw new IllegalArgumentException();
+
+ throw new UnsupportedOperationException();
+}
+
+public void
+setLockingKeyState(int keyCode, boolean on)
+{
+ if (keyCode != KeyEvent.VK_CAPS_LOCK
+ && keyCode != KeyEvent.VK_NUM_LOCK
+ && keyCode != KeyEvent.VK_SCROLL_LOCK)
+ throw new IllegalArgumentException();
+
+ throw new UnsupportedOperationException();
+}
+
+/*************************************************************************/
+
+/**
+ * Returns the event queue for the applet. Despite the word "System"
+ * in the name of this method, there is no guarantee that the same queue
+ * is shared system wide.
+ *
+ * @return The event queue for this applet (or application)
+ */
+public final EventQueue
+getSystemEventQueue()
+{
+ return(getSystemEventQueueImpl());
+}
+
+/*************************************************************************/
+
+/**
+ * // FIXME: What does this do?
+ */
+protected abstract EventQueue
+getSystemEventQueueImpl();
+
+/*************************************************************************/
+
+/**
+ * Causes a "beep" tone to be generated.
+ */
+public abstract void
+beep();
+
+public Cursor
+createCustomCursor(Image cursor, Point hotSpot, String name)
+ throws IndexOutOfBoundsException
+{
+ // Presumably the only reason this isn't abstract is for backwards
+ // compatibility? FIXME?
+ return null;
+}
+
+public Dimension
+getBestCursorSize(int preferredWidth, int preferredHeight)
+{
+ return new Dimension (0,0);
+}
+
+public int
+getMaximumCursorColors()
+{
+ return 0;
+}
+
+public final Object
+getDesktopProperty(String propertyName)
+{
+ return desktopProperties.get(propertyName);
+}
+
+protected final void
+setDesktopProperty(String name, Object newValue)
+{
+ Object oldValue = getDesktopProperty(name);
+ desktopProperties.put(name, newValue);
+ changeSupport.firePropertyChange(name, oldValue, newValue);
+}
+protected Object
+lazilyLoadDesktopProperty(String name)
+{
+ // FIXME - what is this??
+ return null;
+}
+
+protected void
+initializeDesktopProperties()
+{
+ // Overridden by toolkit implementation?
+}
+
+public void
+addPropertyChangeListener(String name, PropertyChangeListener pcl)
+{
+ changeSupport.addPropertyChangeListener(name, pcl);
+}
+
+public void
+removePropertyChangeListener(String name, PropertyChangeListener pcl)
+{
+ changeSupport.removePropertyChangeListener(name, pcl);
+}
+
+public void
+addAWTEventListener(AWTEventListener listener, long eventMask)
+{
+ // SecurityManager s = System.getSecurityManager();
+ // if (s != null)
+ // s.checkPermission(AWTPermission("listenToAllAWTEvents"));
+
+ // FIXME
+}
+
+public void
+removeAWTEventListener(AWTEventListener listener)
+{
+ // FIXME
+}
+
+} // class Toolkit
diff --git a/libjava/java/awt/datatransfer/Clipboard.java b/libjava/java/awt/datatransfer/Clipboard.java
index 634a8d5..6ef9e70 100644
--- a/libjava/java/awt/datatransfer/Clipboard.java
+++ b/libjava/java/awt/datatransfer/Clipboard.java
@@ -1,15 +1,136 @@
-/* Copyright (C) 2000 Free Software Foundation
+/* Clipboard.java -- Class for transferring data via cut and paste.
+ Copyright (C) 1999, 2001 Free Software Foundation, Inc.
- This file is part of libgcj.
+This file is part of GNU Classpath.
-This software is copyrighted work licensed under the terms of the
-Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
-details. */
+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.
-package java.awt.datatransfer;
+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.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
-/* A very incomplete placeholder. */
+package java.awt.datatransfer;
+
+/**
+ * This class allows data to be transferred using a cut and paste type
+ * mechanism.
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
+ */
public class Clipboard
{
+
+/*
+ * Instance Variables
+ */
+
+/**
+ * The data being transferred.
+ */
+protected Transferable contents;
+
+/**
+ * The owner of this clipboard.
+ */
+protected ClipboardOwner owner;
+
+// The clipboard name
+private String name;
+
+/*************************************************************************/
+
+/*
+ * Constructors
+ */
+
+/**
+ * Initializes a new instance of <code>Clipboard</code> with the
+ * specified name.
+ *
+ * @param name The clipboard name.
+ */
+public
+Clipboard(String name)
+{
+ this.name = name;
}
+
+/*************************************************************************/
+
+/*
+ * Instance Methods
+ */
+
+/**
+ * Returns the name of the clipboard.
+ */
+public String
+getName()
+{
+ return(name);
+}
+
+/*************************************************************************/
+
+/**
+ * Returns the contents of the clipboard.
+ *
+ * @param requestor The object requesting the contents.
+ */
+public synchronized Transferable
+getContents(Object requestor)
+{
+ return(contents);
+}
+
+/*************************************************************************/
+
+/**
+ * Sets the content and owner of this clipboard.
+ * If the given owner is different from the current owner
+ * then lostOwnership is called on the current owner.
+ * XXX - is this called with the old or new contents.
+ *
+ * @param contents The new clipboard contents.
+ * @param owner The new clipboard owner
+ */
+public synchronized void
+setContents(Transferable contents, ClipboardOwner owner)
+{
+ if (this.owner != owner)
+ if (this.owner != null)
+ this.owner.lostOwnership(this, contents);
+
+ this.owner = owner;
+ this.contents = contents;
+}
+
+} // class Clipboard
+
diff --git a/libjava/java/awt/datatransfer/ClipboardOwner.java b/libjava/java/awt/datatransfer/ClipboardOwner.java
new file mode 100644
index 0000000..3127e02
--- /dev/null
+++ b/libjava/java/awt/datatransfer/ClipboardOwner.java
@@ -0,0 +1,60 @@
+/* ClipboardOwner.java -- Interface for clipboard providers
+ 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.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.awt.datatransfer;
+
+/**
+ * This interface is for classes that will own a clipboard object.
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
+ */
+public interface ClipboardOwner
+{
+
+/**
+ * This method is called to notify this object that it no longer
+ * has ownership of the specified <code>Clipboard</code>.
+ *
+ * @param clipboard The clipboard for which ownership was lost.
+ * @param contents The contents of the clipboard which are no longer owned.
+ */
+public abstract void
+lostOwnership(Clipboard clipboard, Transferable contents);
+
+} // interface ClipboardOwner
+
diff --git a/libjava/java/awt/datatransfer/DataFlavor.java b/libjava/java/awt/datatransfer/DataFlavor.java
new file mode 100644
index 0000000..3c6b272
--- /dev/null
+++ b/libjava/java/awt/datatransfer/DataFlavor.java
@@ -0,0 +1,982 @@
+/* DataFlavor.java -- A type of data to transfer via the clipboard.
+ Copyright (C) 1999, 2001 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.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.awt.datatransfer;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.IOException;
+import java.io.ObjectOutput;
+import java.io.ObjectInput;
+import java.io.Reader;
+import java.io.StringReader;
+import java.io.UnsupportedEncodingException;
+
+/**
+ * This class represents a particular data format used for transferring
+ * data via the clipboard.
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
+ */
+public class DataFlavor implements java.io.Externalizable, Cloneable
+{
+
+// FIXME: Serialization: Need to write methods for.
+
+/*
+ * Static Variables
+ */
+
+/**
+ * This is the data flavor used for tranferring plain text. The MIME
+ * type is "text/plain; charset=unicode". The representation class
+ * is <code>java.io.InputStream</code>.
+ *
+ * @deprecated The charset unicode is platform specific and InputStream
+ * deals with bytes not chars. Use <code>getRederForText()</code>.
+ */
+public static final DataFlavor plainTextFlavor;
+
+/**
+ * This is the data flavor used for transferring Java strings. The
+ * MIME type is "application/x-java-serialized-object" and the
+ * representation class is <code>java.lang.String</code>.
+ */
+public static final DataFlavor stringFlavor;
+
+/**
+ * This is a data flavor used for transferring lists of files. The
+ * representation type is a <code>java.util.List</code>, with each element of
+ * the list being a <code>java.io.File</code>.
+ */
+public static final DataFlavor javaFileListFlavor;
+
+/**
+ * This is the MIME type used for transferring a serialized object.
+ * The representation class is the type of object be deserialized.
+ */
+public static final String javaSerializedObjectMimeType =
+ "application/x-java-serialized-object";
+
+/**
+ * This is the MIME type used to transfer a Java object reference within
+ * the same JVM. The representation class is the class of the object
+ * being transferred.
+ */
+public static final String javaJVMLocalObjectMimeType =
+ "application/x-java-jvm-local-object";
+
+/**
+ * This is the MIME type used to transfer a link to a remote object.
+ * The representation class is the type of object being linked to.
+ */
+public static final String javaRemoteObjectMimeType =
+ "application/x-java-remote-object";
+
+static
+{
+ plainTextFlavor
+ = new DataFlavor(java.io.InputStream.class,
+ "text/plain; charset=unicode",
+ "plain unicode text");
+
+ stringFlavor
+ = new DataFlavor(java.lang.String.class,
+ "Java Unicode String");
+
+ javaFileListFlavor
+ = new DataFlavor(java.util.List.class,
+ "Java File List");
+
+ // javaFileListFlavor.mimeType = "application/x-java-file-list";
+}
+
+/*************************************************************************/
+
+/*
+ * Instance Variables
+ */
+
+// The MIME type for this flavor
+private final String mimeType;
+
+// The representation class for this flavor
+private final Class representationClass;
+
+// The human readable name of this flavor
+private String humanPresentableName;
+
+/*************************************************************************/
+
+/*
+ * Static Methods
+ */
+
+/**
+ * This method attempts to load the named class. The following class
+ * loaders are searched in order: the bootstrap class loader, the
+ * system class loader, the context class loader (if it exists), and
+ * the specified fallback class loader.
+ *
+ * @param className The name of the class to load.
+ * @param classLoader The class loader to use if all others fail, which
+ * may be <code>null</code>.
+ *
+ * @exception ClassNotFoundException If the class cannot be loaded.
+ */
+protected static final Class
+tryToLoadClass(String className, ClassLoader classLoader)
+ throws ClassNotFoundException
+{
+ try
+ {
+ return(Class.forName(className));
+ }
+ catch(Exception e) { ; }
+ // Commented out for Java 1.1
+ /*
+ try
+ {
+ return(className.getClass().getClassLoader().findClass(className));
+ }
+ catch(Exception e) { ; }
+
+ try
+ {
+ return(ClassLoader.getSystemClassLoader().findClass(className));
+ }
+ catch(Exception e) { ; }
+ */
+
+ // FIXME: What is the context class loader?
+ /*
+ try
+ {
+ }
+ catch(Exception e) { ; }
+ */
+
+ if (classLoader != null)
+ return(classLoader.loadClass(className));
+ else
+ throw new ClassNotFoundException(className);
+}
+
+/*************************************************************************/
+
+/*
+ * Constructors
+ */
+
+/**
+ * Empty public constructor needed for externalization.
+ * Should not be used for normal instantiation.
+ */
+public
+DataFlavor()
+{
+ mimeType = null;
+ representationClass = null;
+ humanPresentableName = null;
+}
+
+/*************************************************************************/
+
+/**
+ * Private constructor.
+ */
+private
+DataFlavor(Class representationClass,
+ String mimeType,
+ String humanPresentableName)
+{
+ this.representationClass = representationClass;
+ this.mimeType = mimeType;
+ if (humanPresentableName != null)
+ this.humanPresentableName = humanPresentableName;
+ else
+ this.humanPresentableName = mimeType;
+}
+
+/*************************************************************************/
+
+/**
+ * Initializes a new instance of <code>DataFlavor</code>. The class
+ * and human readable name are specified, the MIME type will be
+ * "application/x-java-serialized-object". If the human readable name
+ * is not specified (<code>null</code>) then the human readable name
+ * will be the same as the MIME type.
+ *
+ * @param representationClass The representation class for this object.
+ * @param humanPresentableName The display name of the object.
+ */
+public
+DataFlavor(Class representationClass, String humanPresentableName)
+{
+ this(representationClass,
+ "application/x-java-serialized-object"
+ + "; class="
+ + representationClass.getName(),
+ humanPresentableName);
+}
+
+/*************************************************************************/
+
+/**
+ * Initializes a new instance of <code>DataFlavor</code> with the
+ * specified MIME type and description. If the MIME type has a
+ * "class=<rep class>" parameter then the representation class will
+ * be the class name specified. Otherwise the class defaults to
+ * <code>java.io.InputStream</code>. If the human readable name
+ * is not specified (<code>null</code>) then the human readable name
+ * will be the same as the MIME type.
+ *
+ * @param mimeType The MIME type for this flavor.
+ * @param humanPresentableName The display name of this flavor.
+ * @param classLoader The class loader for finding classes if the default
+ * class loaders do not work.
+ *
+ * @exception IllegalArgumentException If the representation class
+ * specified cannot be loaded.
+ */
+public
+DataFlavor(String mimeType, String humanPresentableName,
+ ClassLoader classLoader) throws ClassNotFoundException
+{
+ this(getRepresentationClassFromMime(mimeType, classLoader),
+ mimeType, humanPresentableName);
+}
+
+private static Class
+getRepresentationClassFromMime(String mimeString, ClassLoader classLoader)
+{
+ String classname = getParameter("class", mimeString);
+ if (classname != null)
+ {
+ try
+ {
+ return tryToLoadClass(classname, classLoader);
+ }
+ catch(Exception e)
+ {
+ throw new IllegalArgumentException("classname: " + e.getMessage());
+ }
+ }
+ else
+ {
+ return java.io.InputStream.class;
+ }
+}
+
+/*************************************************************************/
+
+/**
+ * Initializes a new instance of <code>DataFlavor</code> with the
+ * specified MIME type and description. If the MIME type has a
+ * "class=<rep class>" parameter then the representation class will
+ * be the class name specified. Otherwise the class defaults to
+ * <code>java.io.InputStream</code>. If the human readable name
+ * is not specified (<code>null</code>) then the human readable name
+ * will be the same as the MIME type. This is the same as calling
+ * <code>new DataFlavor(mimeType, humanPresentableName, null)</code>.
+ *
+ * @param mimeType The MIME type for this flavor.
+ * @param humanPresentableName The display name of this flavor.
+ * @param classLoader The class loader for finding classes.
+ *
+ * @exception IllegalArgumentException If the representation class
+ * specified cannot be loaded.
+ */
+public
+DataFlavor(String mimeType, String humanPresentableName)
+ throws ClassNotFoundException
+{
+ this(mimeType, humanPresentableName, null);
+}
+
+/*************************************************************************/
+
+/**
+ * Initializes a new instance of <code>DataFlavor</code> with the specified
+ * MIME type. This type can have a "class=" parameter to specify the
+ * representation class, and then the class must exist or an exception will
+ * be thrown. If there is no "class=" parameter then the representation class
+ * will be <code>java.io.InputStream</code>. This is the same as calling
+ * <code>new DataFlavor(mimeType, null)</code>.
+ *
+ * @param mimeType The MIME type for this flavor.
+ *
+ * @exception IllegalArgumentException If a class is not specified in
+ * the MIME type.
+ * @exception ClassNotFoundException If the class cannot be loaded.
+ */
+public
+DataFlavor(String mimeType) throws ClassNotFoundException
+{
+ this(mimeType, null);
+}
+
+/*************************************************************************/
+
+/**
+ * Returns the MIME type of this flavor.
+ *
+ * @return The MIME type for this flavor.
+ */
+public String
+getMimeType()
+{
+ return(mimeType);
+}
+
+/*************************************************************************/
+
+/**
+ * Returns the representation class for this flavor.
+ *
+ * @return The representation class for this flavor.
+ */
+public Class
+getRepresentationClass()
+{
+ return(representationClass);
+}
+
+/*************************************************************************/
+
+/**
+ * Returns the human presentable name for this flavor.
+ *
+ * @return The human presentable name for this flavor.
+ */
+public String
+getHumanPresentableName()
+{
+ return(humanPresentableName);
+}
+
+/*************************************************************************/
+
+/**
+ * Returns the primary MIME type for this flavor.
+ *
+ * @return The primary MIME type for this flavor.
+ */
+public String
+getPrimaryType()
+{
+ int idx = mimeType.indexOf("/");
+ if (idx == -1)
+ return(mimeType);
+
+ return(mimeType.substring(0, idx));
+}
+
+/*************************************************************************/
+
+/**
+ * Returns the MIME subtype for this flavor.
+ *
+ * @return The MIME subtype for this flavor.
+ */
+public String
+getSubType()
+{
+ int idx = mimeType.indexOf("/");
+ if (idx == -1)
+ return("");
+
+ String subtype = mimeType.substring(idx + 1);
+
+ idx = subtype.indexOf(" ");
+ if (idx == -1)
+ return(subtype);
+ else
+ return(subtype.substring(0, idx));
+}
+
+/*************************************************************************/
+
+/**
+ * Returns the value of the named MIME type parameter, or <code>null</code>
+ * if the parameter does not exist. Given the parameter name and the mime
+ * string.
+ *
+ * @param paramName The name of the parameter.
+ * @param mimeString The mime string from where the name should be found.
+ *
+ * @return The value of the parameter or null.
+ */
+private static String
+getParameter(String paramName, String mimeString)
+{
+ int idx = mimeString.indexOf(paramName + "=");
+ if (idx == -1)
+ return(null);
+
+ String value = mimeString.substring(idx + paramName.length() + 2);
+
+ idx = value.indexOf(" ");
+ if (idx == -1)
+ return(value);
+ else
+ return(value.substring(0, idx));
+}
+
+/*************************************************************************/
+/**
+ * Returns the value of the named MIME type parameter, or <code>null</code>
+ * if the parameter does not exist.
+ *
+ * @param paramName The name of the paramter.
+ *
+ * @return The value of the parameter.
+ */
+public String
+getParameter(String paramName)
+{
+ return getParameter(paramName, mimeType);
+}
+
+/*************************************************************************/
+
+/**
+ * Sets the human presentable name to the specified value.
+ *
+ * @param humanPresentableName The new display name.
+ */
+public void
+setHumanPresentableName(String humanPresentableName)
+{
+ this.humanPresentableName = humanPresentableName;
+}
+
+/*************************************************************************/
+
+/**
+ * Tests the MIME type of this object for equality against the specified
+ * MIME type.
+ *
+ * @param mimeType The MIME type to test against.
+ *
+ * @return <code>true</code> if the MIME type is equal to this object's
+ * MIME type, <code>false</code> otherwise.
+ */
+public boolean
+isMimeTypeEqual(String mimeType)
+{
+ // FIXME: Need to handle default attributes and parameters
+
+ return(this.mimeType.equals(mimeType));
+}
+
+/*************************************************************************/
+
+/**
+ * Tests the MIME type of this object for equality against the specified
+ * data flavor's MIME type
+ *
+ * @param flavor The flavor to test against.
+ *
+ * @return <code>true</code> if the flavor's MIME type is equal to this
+ * object's MIME type, <code>false</code> otherwise.
+ */
+public boolean
+isMimeTypeEqual(DataFlavor flavor)
+{
+ return(isMimeTypeEqual(flavor.getMimeType()));
+}
+
+/*************************************************************************/
+
+/**
+ * Tests whether or not this flavor represents a serialized object.
+ *
+ * @return <code>true</code> if this flavor represents a serialized
+ * object, <code>false</code> otherwise.
+ */
+public boolean
+isMimeTypeSerializedObject()
+{
+ return(mimeType.startsWith(javaSerializedObjectMimeType));
+}
+
+/*************************************************************************/
+
+/**
+ * Tests whether or not this flavor has a representation class of
+ * <code>java.io.InputStream</code>.
+ *
+ * @param <code>true</code> if the representation class of this flavor
+ * is <code>java.io.InputStream</code>, <code>false</code> otherwise.
+ */
+public boolean
+isRepresentationClassInputStream()
+{
+ return(representationClass.getName().equals("java.io.InputStream"));
+}
+
+/*************************************************************************/
+
+/**
+ * Tests whether the representation class for this flavor is
+ * serializable.
+ *
+ * @param <code>true</code> if the representation class is serializable,
+ * <code>false</code> otherwise.
+ */
+public boolean
+isRepresentationClassSerializable()
+{
+ Class[] interfaces = representationClass.getInterfaces();
+
+ int i = 0;
+ while (i < interfaces.length)
+ {
+ if (interfaces[i].getName().equals("java.io.Serializable"))
+ return(true);
+ ++i;
+ }
+
+ return(false);
+}
+
+/*************************************************************************/
+
+/**
+ * Tests whether the representation class for his flavor is remote.
+ *
+ * @return <code>true</code> if the representation class is remote,
+ * <code>false</code> otherwise.
+ */
+public boolean
+isRepresentationClassRemote()
+{
+ // FIXME: Implement
+ throw new RuntimeException("Not implemented");
+}
+
+/*************************************************************************/
+
+/**
+ * Tests whether or not this flavor represents a serialized object.
+ *
+ * @return <code>true</code> if this flavor represents a serialized
+ * object, <code>false</code> otherwise.
+ */
+public boolean
+isFlavorSerializedObjectType()
+{
+ // FIXME: What is the diff between this and isMimeTypeSerializedObject?
+ return(mimeType.startsWith(javaSerializedObjectMimeType));
+}
+
+/*************************************************************************/
+
+/**
+ * Tests whether or not this flavor represents a remote object.
+ *
+ * @return <code>true</code> if this flavor represents a remote object,
+ * <code>false</code> otherwise.
+ */
+public boolean
+isFlavorRemoteObjectType()
+{
+ return(mimeType.startsWith(javaRemoteObjectMimeType));
+}
+
+/*************************************************************************/
+
+/**
+ * Tests whether or not this flavor represents a list of files.
+ *
+ * @return <code>true</code> if this flavor represents a list of files,
+ * <code>false</code> otherwise.
+ */
+public boolean
+isFlavorJavaFileListType()
+{
+ if (this.mimeType.equals(javaFileListFlavor.mimeType) &&
+ this.representationClass.equals(javaFileListFlavor.representationClass))
+ return(true);
+
+ return(false);
+}
+
+/*************************************************************************/
+
+/**
+ * Returns a copy of this object.
+ *
+ * @return A copy of this object.
+ */
+public Object
+clone()
+{
+ try
+ {
+ return(super.clone());
+ }
+ catch(Exception e)
+ {
+ return(null);
+ }
+}
+
+/*************************************************************************/
+
+/**
+ * This method test the specified <code>DataFlavor</code> for equality
+ * against this object. This will be true if the MIME type and
+ * representation type are the equal.
+ *
+ * @param flavor The <code>DataFlavor</code> to test against.
+ *
+ * @return <code>true</code> if the flavor is equal to this object,
+ * <code>false</code> otherwise.
+ */
+public boolean
+equals(DataFlavor flavor)
+{
+ if (flavor == null)
+ return(false);
+
+ if (!this.mimeType.toLowerCase().equals(flavor.mimeType.toLowerCase()))
+ return(false);
+
+ if (!this.representationClass.equals(flavor.representationClass))
+ return(false);
+
+ return(true);
+}
+
+/*************************************************************************/
+
+/**
+ * This method test the specified <code>Object</code> for equality
+ * against this object. This will be true if the following conditions
+ * are met:
+ * <p>
+ * <ul>
+ * <li>The object is not <code>null</code>.
+ * <li>The object is an instance of <code>DataFlavor</code>.
+ * <li>The object's MIME type and representation class are equal to
+ * this object's.
+ * </ul>
+ *
+ * @param obj The <code>Object</code> to test against.
+ *
+ * @return <code>true</code> if the flavor is equal to this object,
+ * <code>false</code> otherwise.
+ */
+public boolean
+equals(Object obj)
+{
+ if (obj == null)
+ return(false);
+
+ if (!(obj instanceof DataFlavor))
+ return(false);
+
+ return(equals((DataFlavor)obj));
+}
+
+/*************************************************************************/
+
+/**
+ * Tests whether or not the specified string is equal to the MIME type
+ * of this object.
+ *
+ * @param str The string to test against.
+ *
+ * @return <code>true</code> if the string is equal to this object's MIME
+ * type, <code>false</code> otherwise.
+ *
+ * @deprecated Not compatible with <code>hashCode()</code>.
+ * Use <code>isMimeTypeEqual()</code>
+ */
+public boolean
+equals(String str)
+{
+ return(isMimeTypeEqual(str));
+}
+
+/*************************************************************************/
+
+/**
+ * Returns the hash code for this data flavor.
+ * The hash code is based on the (lower case) mime type and the
+ * representation class.
+ */
+public int
+hashCode()
+{
+ return(mimeType.toLowerCase().hashCode()^representationClass.hashCode());
+}
+
+/*************************************************************************/
+
+/**
+ * Returns <code>true</code> when the given <code>DataFlavor</code>
+ * matches this one.
+ */
+public boolean
+match(DataFlavor dataFlavor)
+{
+ // XXX - How is this different from equals?
+ return(equals(dataFlavor));
+}
+
+/*************************************************************************/
+
+/**
+ * This method exists for backward compatibility. It simply returns
+ * the same name/value pair passed in.
+ *
+ * @param name The parameter name.
+ * @param value The parameter value.
+ *
+ * @return The name/value pair.
+ *
+ * @deprecated
+ */
+protected String
+normalizeMimeTypeParameter(String name, String value)
+{
+ return(name + "=" + value);
+}
+
+/*************************************************************************/
+
+/**
+ * This method exists for backward compatibility. It simply returns
+ * the MIME type string unchanged.
+ *
+ * @param type The MIME type.
+ *
+ * @return The MIME type.
+ *
+ * @deprecated
+ */
+protected String
+normalizeMimeType(String type)
+{
+ return(type);
+}
+
+/*************************************************************************/
+
+/**
+ * Serialize this class.
+ *
+ * @param stream The <code>ObjectOutput</code> stream to serialize to.
+ */
+public void
+writeExternal(ObjectOutput stream) throws IOException
+{
+ // FIXME: Implement me
+}
+
+/*************************************************************************/
+
+/**
+ * De-serialize this class.
+ *
+ * @param stream The <code>ObjectInput</code> stream to deserialize from.
+ */
+public void
+readExternal(ObjectInput stream) throws IOException, ClassNotFoundException
+{
+ // FIXME: Implement me
+}
+
+/*************************************************************************/
+
+/**
+ * Returns a string representation of this DataFlavor. Including the
+ * representation class name, MIME type and human presentable name.
+ */
+public String
+toString()
+{
+ return("DataFlavor[representationClass="
+ + representationClass.getName()
+ + ",mimeType="
+ + mimeType
+ + "humanPresentableName="
+ + humanPresentableName);
+}
+
+/*************************************************************************/
+
+/**
+ * XXX - Currently returns <code>plainTextFlavor</code>.
+ */
+public static final DataFlavor
+getTextPlainUnicodeFlavor()
+{
+ return(plainTextFlavor);
+}
+
+/*************************************************************************/
+
+/**
+ * XXX - Currently returns <code>java.io.InputStream</code>.
+ *
+ * @since 1.3
+ */
+public static final Class
+getDefaultRepresentationClass()
+{
+ return(java.io.InputStream.class);
+}
+/*************************************************************************/
+
+/**
+ * XXX - Currently returns <code>java.io.InputStream</code>.
+ */
+public static final String
+getDefaultRepresentationClassAsString()
+{
+ return(getDefaultRepresentationClass().getName());
+}
+
+/*************************************************************************/
+
+/**
+ * Selects the best supported text flavor on this implementation.
+ * Returns <code>null</code> when none of the given flavors is liked.
+ *
+ * The <code>DataFlavor</code> returned the first data flavor in the
+ * array that has either a representation class which is (a subclass of)
+ * <code>Reader</code> or <code>String</code>, or has a representation
+ * class which is (a subclass of) <code>InputStream</code> and has a
+ * primary MIME type of "text" and has an supported encoding.
+ */
+public static final DataFlavor
+selectBestTextFlavor(DataFlavor[] availableFlavors)
+{
+ for(int i=0; i<availableFlavors.length; i++)
+ {
+ DataFlavor df = availableFlavors[i];
+ Class c = df.representationClass;
+
+ // A Reader or String is good.
+ if ((Reader.class.isAssignableFrom(c))
+ || (String.class.isAssignableFrom(c)))
+ {
+ return df;
+ }
+
+ // A InputStream is good if the mime primary type is "text"
+ if ((InputStream.class.isAssignableFrom(c))
+ && ("text".equals(df.getPrimaryType())))
+ {
+ String encoding = availableFlavors[i].getParameter("charset");
+ if (encoding == null)
+ encoding = "us-ascii";
+ Reader r = null;
+ try
+ {
+ // Try to construct a dummy reader with the found encoding
+ r = new InputStreamReader
+ (new ByteArrayInputStream(new byte[0]), encoding);
+ }
+ catch(UnsupportedEncodingException uee) { /* ignore */ }
+ if (r != null)
+ return df;
+ }
+ }
+
+ // Nothing found
+ return(null);
+}
+
+/*************************************************************************/
+
+/**
+ * Creates a <code>Reader</code> for a given <code>Transferable</code>.
+ *
+ * If the representation class is a (subclass of) <code>Reader</code>
+ * then an instance of the representation class is returned. If the
+ * representatation class is a <code>String</code> then a
+ * <code>StringReader</code> is returned. And if the representation class
+ * is a (subclass of) <code>InputStream</code> and the primary MIME type
+ * is "text" then a <code>InputStreamReader</code> for the correct charset
+ * encoding is returned.
+ *
+ * @param transferable The <code>Transferable</code> for which a text
+ * <code>Reader</code> is requested.
+ * @exception UnsupportedFlavorException when the transferable doesn't
+ * support this <code>DataFlavor</code>. Or if the representable class
+ * isn't a (subclass of) <code>Reader</code>, <code>String</code>,
+ * <code>InputStream</code> and/or the primary MIME type isn't "text".
+ * @exception IOException when any IOException occurs.
+ * @exception UnsupportedEncodingException if the "charset" isn't supported
+ * on this platform.
+ */
+public Reader
+getReaderForText(Transferable transferable) throws UnsupportedFlavorException,
+ IOException,
+ UnsupportedEncodingException
+{
+ if (!transferable.isDataFlavorSupported(this))
+ throw new UnsupportedFlavorException(this);
+
+ if (Reader.class.isAssignableFrom(representationClass))
+ return((Reader)transferable.getTransferData(this));
+
+ if (String.class.isAssignableFrom(representationClass))
+ return(new StringReader((String)transferable.getTransferData(this)));
+
+ if (InputStream.class.isAssignableFrom(representationClass)
+ && "text".equals(getPrimaryType()))
+ {
+ InputStream in = (InputStream)transferable.getTransferData(this);
+ String encoding = getParameter("charset");
+ if (encoding == null)
+ encoding = "us-ascii";
+ return(new InputStreamReader(in, encoding));
+ }
+
+ throw new UnsupportedFlavorException(this);
+}
+
+} // class DataFlavor
+
diff --git a/libjava/java/awt/datatransfer/FlavorMap.java b/libjava/java/awt/datatransfer/FlavorMap.java
new file mode 100644
index 0000000..96b1608
--- /dev/null
+++ b/libjava/java/awt/datatransfer/FlavorMap.java
@@ -0,0 +1,82 @@
+/* FlavorMap.java -- Maps between flavor names and MIME types.
+ Copyright (C) 1999, 2001 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.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.awt.datatransfer;
+
+import java.util.Map;
+
+/**
+ * This interface maps between native platform type names and DataFlavors.
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
+ */
+public interface FlavorMap
+{
+
+/**
+ * Maps the specified <code>DataFlavor</code> objects to the native
+ * data type name. The returned <code>Map</code> has keys that are
+ * the data flavors and values that are strings. The returned map
+ * may be modified. This can be useful for implementing nested mappings.
+ *
+ * @param flavors An array of data flavors to map
+ * or null for all data flavors.
+ *
+ * @return A <code>Map</code> of native data types.
+ */
+public abstract Map
+getNativesForFlavors(DataFlavor[] flavors);
+
+/*************************************************************************/
+
+/**
+ * Maps the specified native type names to <code>DataFlavor</code>'s.
+ * The returned <code>Map</code> has keys that are strings and values
+ * that are <code>DataFlavor</code>'s. The returned map may be
+ * modified. This can be useful for implementing nested mappings.
+ *
+ * @param natives An array of native types to map
+ * or null for all native types.
+ *
+ * @return A <code>Map</code> of data flavors.
+ */
+public abstract Map
+getFlavorsForNatives(String[] natives);
+
+} // interface FlavorMap
+
diff --git a/libjava/java/awt/datatransfer/MimeTypeParseException.java b/libjava/java/awt/datatransfer/MimeTypeParseException.java
new file mode 100644
index 0000000..32bc885
--- /dev/null
+++ b/libjava/java/awt/datatransfer/MimeTypeParseException.java
@@ -0,0 +1,70 @@
+/* MimeTypeParseException.java -- Thrown when MIME string couldn't be parsed.
+ Copyright (C) 2001 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.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.awt.datatransfer;
+
+/**
+ * MIME string couldn't be parsed correctly.
+ *
+ * @author Mark Wielaard (mark@klomp.org)
+ */
+public class MimeTypeParseException extends Exception
+{
+
+/**
+ * Initializes a new instance of <code>MimeTypeParseException</code>
+ * without any message.
+ */
+public
+MimeTypeParseException()
+{
+ super();
+}
+
+/**
+ * Initializes a new instance of <code>MimeTypeParseException</code>
+ * with a specified detailed error message.
+ */
+public
+MimeTypeParseException(String message)
+{
+ super(message);
+}
+
+} // class MimeTypeParseException
+
diff --git a/libjava/java/awt/datatransfer/StringSelection.java b/libjava/java/awt/datatransfer/StringSelection.java
new file mode 100644
index 0000000..f6f0116
--- /dev/null
+++ b/libjava/java/awt/datatransfer/StringSelection.java
@@ -0,0 +1,159 @@
+/* StringSelection.java -- Clipboard handler for text.
+ 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.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.awt.datatransfer;
+
+import java.io.StringBufferInputStream;
+import java.io.IOException;
+
+/**
+ * This class transfers a string as plain text using the clipboard.
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
+ */
+public class StringSelection implements Transferable, ClipboardOwner
+{
+
+/*
+ * Class Variables
+ */
+
+// List of flavors we support
+public static final DataFlavor[] supported_flavors
+ = { DataFlavor.plainTextFlavor };
+
+/*************************************************************************/
+
+/*
+ * Instance Variables
+ */
+
+// This is the data to transfer
+private String data;
+
+/*************************************************************************/
+
+/*
+ * Constructors
+ */
+
+/**
+ * Transfer the specfied string as text.
+ */
+public
+StringSelection(String data)
+{
+ this.data = data;
+}
+
+/*************************************************************************/
+
+/*
+ * Instance Methods
+ */
+
+/**
+ * Returns a list of supported data flavors.
+ *
+ * @return A list of supported data flavors.
+ */
+public DataFlavor[]
+getTransferDataFlavors()
+{
+ return(supported_flavors);
+}
+
+/*************************************************************************/
+
+/**
+ * Tests whether or not the specified data flavor is supported.
+ *
+ * @param flavor The data flavor to test.
+ *
+ * @return <code>true</code> if the data flavor is supported,
+ * <code>false</code> otherwise.
+ */
+public boolean
+isDataFlavorSupported(DataFlavor flavor)
+{
+ for (int i = 0; i < supported_flavors.length; i++)
+ if (supported_flavors[i].equals(flavor))
+ return(true);
+
+ return(false);
+}
+
+/*************************************************************************/
+
+/**
+ * This method returns the data in the requested format.
+ *
+ * @param flavor The desired data flavor.
+ *
+ * @return The transferred data.
+ *
+ * @exception UnsupportedFlavorException If the specified flavor is not
+ * supported.
+ * @exception IOException If any other error occurs.
+ */
+public Object
+getTransferData(DataFlavor flavor) throws UnsupportedFlavorException,
+ IOException
+{
+ if (!isDataFlavorSupported(flavor))
+ throw new UnsupportedFlavorException(flavor);
+
+ return(new StringBufferInputStream(data));
+}
+
+/*************************************************************************/
+
+/**
+ * Called when ownership of the clipboard object is lost.
+ *
+ * @param clipboard The affected clipboard.
+ * @param contents The clipboard contents.
+ */
+public void
+lostOwnership(Clipboard clipboard, Transferable contents)
+{
+ // FIXME: What does this do?
+}
+
+} // class StringSelection
+
diff --git a/libjava/java/awt/datatransfer/SystemFlavorMap.java b/libjava/java/awt/datatransfer/SystemFlavorMap.java
new file mode 100644
index 0000000..50064db
--- /dev/null
+++ b/libjava/java/awt/datatransfer/SystemFlavorMap.java
@@ -0,0 +1,180 @@
+/* SystemFlavorMap.java -- Maps between native flavor names and MIME types.
+ Copyright (C) 2001 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.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.awt.datatransfer;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * This class maps between native platform type names and DataFlavors.
+ *
+ * XXX - The current implementation does no mapping at all.
+ *
+ * @author Mark Wielaard (mark@klomp.org)
+ */
+public final class SystemFlavorMap implements FlavorMap
+{
+
+/**
+ * The default (instance) flavor map.
+ */
+private static FlavorMap defaultFlavorMap;
+
+/**
+ * Private constructor.
+ */
+private SystemFlavorMap()
+{
+}
+
+/*************************************************************************/
+
+/**
+ * Maps the specified <code>DataFlavor</code> objects to the native
+ * data type name. The returned <code>Map</code> has keys that are
+ * the data flavors and values that are strings. The returned map
+ * may be modified. This can be useful for implementing nested mappings.
+ *
+ * @param flavors An array of data flavors to map
+ * or null for all data flavors.
+ *
+ * @return A <code>Map</code> of native data types to data flavors.
+ */
+public Map
+getNativesForFlavors(DataFlavor[] flavors)
+{
+ return(new HashMap());
+}
+
+/*************************************************************************/
+
+/**
+ * Maps the specified native type names to <code>DataFlavor</code>'s.
+ * The returned <code>Map</code> has keys that are strings and values
+ * that are <code>DataFlavor</code>'s. The returned map may be
+ * modified. This can be useful for implementing nested mappings.
+ *
+ * @param natives An array of native types to map
+ * or null for all native types.
+ *
+ * @return A <code>Map</code> of data flavors to native type names.
+ */
+public Map
+getFlavorsForNatives(String[] natives)
+{
+ return(new HashMap());
+}
+
+/*************************************************************************/
+
+/**
+ * Returns the default (instance) (System)FlavorMap.
+ */
+public static FlavorMap
+getDefaultFlavorMap()
+{
+ if (defaultFlavorMap == null)
+ defaultFlavorMap = new SystemFlavorMap();
+
+ return(defaultFlavorMap);
+}
+
+/*************************************************************************/
+
+/**
+ * Returns the native type name for the given java mime type.
+ */
+public static String
+encodeJavaMIMEType(String mime)
+{
+ return null;
+}
+
+/*************************************************************************/
+
+/**
+ * Returns the native type name for the given data flavor.
+ */
+public static String
+encodeDataFlavor(DataFlavor df)
+{
+ return null;
+}
+
+/*************************************************************************/
+
+/**
+ * Returns true if the native type name can be represented as
+ * a java mime type.
+ */
+public static boolean
+isJavaMIMEType(String name)
+{
+ return(false);
+}
+
+/*************************************************************************/
+
+/**
+ * Returns the java mime type for the given the native type name.
+ */
+public static String
+decodeJavaMIMEType(String name)
+{
+ return null;
+}
+
+/*************************************************************************/
+
+/**
+ * Returns the data flavor given the native type name
+ * or null when no such data flavor exists.
+ */
+public static DataFlavor
+decodeDataFlavor(String name) throws ClassNotFoundException
+{
+ String javaMIMEType = decodeJavaMIMEType(name);
+ if (javaMIMEType != null)
+ return(new DataFlavor(javaMIMEType));
+ else
+ return(null);
+}
+
+} // class SystemFlavorMap
+
diff --git a/libjava/java/awt/datatransfer/Transferable.java b/libjava/java/awt/datatransfer/Transferable.java
new file mode 100644
index 0000000..52dac69
--- /dev/null
+++ b/libjava/java/awt/datatransfer/Transferable.java
@@ -0,0 +1,92 @@
+/* Transferable.java -- Data transfer source
+ 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.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.awt.datatransfer;
+
+import java.io.IOException;
+
+/**
+ * This interface is implemented by classes that can transfer data.
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
+ */
+public interface Transferable
+{
+
+/**
+ * Returns the data in the specified <code>DataFlavor</code>
+ *
+ * @param flavor The data flavor to return.
+ *
+ * @return The data in the appropriate flavor.
+ *
+ * @exception UnsupportedFlavorException If the flavor is not supported.
+ * @exception IOException If the data is not available.
+ */
+public abstract Object
+getTransferData(DataFlavor flavor) throws UnsupportedFlavorException,
+ IOException;
+
+/*************************************************************************/
+
+/**
+ * This method returns a list of available data flavors for the
+ * data being transferred. The array returned will be sorted from most
+ * preferred flavor at the beginning to least preferred at the end.
+ *
+ * @return A list of data flavors for this data.
+ */
+public abstract DataFlavor[]
+getTransferDataFlavors();
+
+/*************************************************************************/
+
+/**
+ * Tests whether or not this data can be delivered in the specified
+ * data flavor.
+ *
+ * @param flavor The data flavor to test.
+ *
+ * @return <code>true</code> if the data flavor is supported,
+ * <code>false</code> otherwise.
+ */
+public abstract boolean
+isDataFlavorSupported(DataFlavor flavor);
+
+} // interface Transferable
+
diff --git a/libjava/java/awt/datatransfer/UnsupportedFlavorException.java b/libjava/java/awt/datatransfer/UnsupportedFlavorException.java
new file mode 100644
index 0000000..a31059e
--- /dev/null
+++ b/libjava/java/awt/datatransfer/UnsupportedFlavorException.java
@@ -0,0 +1,62 @@
+/* UnsupportedFlavorException.java -- Data flavor is not valid.
+ 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.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.awt.datatransfer;
+
+/**
+ * The data flavor requested is not supported for the transfer data.
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
+ */
+public class UnsupportedFlavorException extends Exception
+{
+
+/**
+ * Initializes a new instance of <code>UnsupportedDataFlavor</code>
+ * for the specified data flavor.
+ *
+ * @param flavor The data flavor that is not supported.
+ */
+public
+UnsupportedFlavorException(DataFlavor flavor)
+{
+ super(flavor.getHumanPresentableName());
+}
+
+} // class UnsupportedFlavorException
+