diff options
author | Andrew Haley <aph@redhat.com> | 2016-09-30 16:24:48 +0000 |
---|---|---|
committer | Andrew Haley <aph@gcc.gnu.org> | 2016-09-30 16:24:48 +0000 |
commit | 07b78716af6a9d7c9fd1e94d9baf94a52c873947 (patch) | |
tree | 3f22b3241c513ad168c8353805614ae1249410f4 /libjava/classpath/java/awt/datatransfer | |
parent | eae993948bae8b788c53772bcb9217c063716f93 (diff) | |
download | gcc-07b78716af6a9d7c9fd1e94d9baf94a52c873947.zip gcc-07b78716af6a9d7c9fd1e94d9baf94a52c873947.tar.gz gcc-07b78716af6a9d7c9fd1e94d9baf94a52c873947.tar.bz2 |
Makefile.def: Remove libjava.
2016-09-30 Andrew Haley <aph@redhat.com>
* Makefile.def: Remove libjava.
* Makefile.tpl: Likewise.
* Makefile.in: Regenerate.
* configure.ac: Likewise.
* configure: Likewise.
* gcc/java: Remove.
* libjava: Likewise.
From-SVN: r240662
Diffstat (limited to 'libjava/classpath/java/awt/datatransfer')
14 files changed, 0 insertions, 2819 deletions
diff --git a/libjava/classpath/java/awt/datatransfer/Clipboard.java b/libjava/classpath/java/awt/datatransfer/Clipboard.java deleted file mode 100644 index d0a1d3a..0000000 --- a/libjava/classpath/java/awt/datatransfer/Clipboard.java +++ /dev/null @@ -1,213 +0,0 @@ -/* Clipboard.java -- Class for transferring data via cut and paste. - Copyright (C) 1999, 2001, 2005, 2006 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., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 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; -import java.util.ArrayList; - -/** - * This class allows data to be transferred using a cut and paste type - * mechanism. - * - * @author Aaron M. Renn (arenn@urbanophile.com) - * @author Mark J. Wielaard (mark@klomp.org) - */ -public class Clipboard -{ - /** - * The data currently on this clipboard. For use by - * subclasses. Also returned by the public method getContents(). - */ - protected Transferable contents; - - /** - * The owner of this clipboard. - */ - protected ClipboardOwner owner; - - // The clipboard name - private final String name; - - // The flavor listeners (most likely small). - private final ArrayList listeners = new ArrayList(3); - - /** - * Initializes a new instance of <code>Clipboard</code> with the - * specified name. - * - * @param name The clipboard name. - */ - public Clipboard(String name) - { - this.name = name; - } - - /** - * Returns the name of the clipboard. - */ - public String getName() - { - return name; - } - - /** - * Returns the contents of the clipboard. - * - * @param requestor The object requesting the contents. This - * implementation ignores this parameter. - * - * @exception IllegalStateException If the clipboard is currently unavailable - */ - 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 <code>lostOwnership()</code> - * is called on the current owner with the old contents of the given - * clipboard. - * - * @param contents The new clipboard contents. - * @param owner The new clipboard owner - * - * @exception IllegalStateException If the clipboard is currently unavailable - */ - public synchronized void setContents(Transferable contents, - ClipboardOwner owner) - { - Transferable oldContents = getContents(null); - this.contents = contents; - if (this.owner != owner) - { - ClipboardOwner oldOwner = this.owner; - this.owner = owner; - if (oldOwner != null) - oldOwner.lostOwnership(this, oldContents); - } - - FlavorListener[] fs = getFlavorListeners(); - if (fs.length > 0) - { - // We are a bit optimistic here. We assume DataFlavors will be - // given in the same order. If the number of flavors is - // different or the order of the DataFlavors in the list then - // fire a change event. - boolean newFlavors = ((contents != null && oldContents == null) - || (contents == null && oldContents != null)); - if (!newFlavors && contents != null && oldContents != null) - { - DataFlavor[] df1 = contents.getTransferDataFlavors(); - DataFlavor[] df2 = oldContents.getTransferDataFlavors(); - newFlavors = df1.length != df2.length; - - for (int i = 0; !newFlavors && i < df1.length; i++) - newFlavors = !df1[i].equals(df2[i]); - } - - if (newFlavors) - { - FlavorEvent e = new FlavorEvent(this); - for (int i = 0; i < fs.length; i++) - fs[i].flavorsChanged(e); - } - } - } - - public DataFlavor[] getAvailableDataFlavors() - { - Transferable c = getContents(null); - if (c == null) - return new DataFlavor[0]; - else - return c.getTransferDataFlavors(); - } - - public boolean isDataFlavorAvailable(DataFlavor flavor) - { - DataFlavor[] fs = getAvailableDataFlavors(); - for (int i = 0; i < fs.length; i++) - if (flavor.equals(fs[i])) - return true; - - return false; - } - - public Object getData(DataFlavor flavor) - throws UnsupportedFlavorException, IOException - { - Transferable c = getContents(null); - if (c == null) - throw new UnsupportedFlavorException(flavor); - else - return c.getTransferData(flavor); - } - - public void addFlavorListener(FlavorListener listener) - { - if (listener == null) - return; - - synchronized(listeners) - { - listeners.add(listener); - } - } - - public void removeFlavorListener(FlavorListener listener) - { - if (listener == null) - return; - - synchronized(listeners) - { - listeners.remove(listener); - } - } - - public FlavorListener[] getFlavorListeners() - { - synchronized(listeners) - { - return (FlavorListener[]) - listeners.toArray(new FlavorListener[listeners.size()]); - } - } -} diff --git a/libjava/classpath/java/awt/datatransfer/ClipboardOwner.java b/libjava/classpath/java/awt/datatransfer/ClipboardOwner.java deleted file mode 100644 index b98059a..0000000 --- a/libjava/classpath/java/awt/datatransfer/ClipboardOwner.java +++ /dev/null @@ -1,56 +0,0 @@ -/* 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., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 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. - */ - void lostOwnership (Clipboard clipboard, Transferable contents); -} diff --git a/libjava/classpath/java/awt/datatransfer/DataFlavor.java b/libjava/classpath/java/awt/datatransfer/DataFlavor.java deleted file mode 100644 index e547704..0000000 --- a/libjava/classpath/java/awt/datatransfer/DataFlavor.java +++ /dev/null @@ -1,1026 +0,0 @@ -/* DataFlavor.java -- A type of data to transfer via the clipboard. - Copyright (C) 1999, 2001, 2004, 2005, 2006 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., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 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.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import java.io.OptionalDataException; -import java.io.Reader; -import java.io.Serializable; -import java.io.StringReader; -import java.io.UnsupportedEncodingException; -import java.nio.ByteBuffer; -import java.nio.CharBuffer; -import java.nio.charset.Charset; -import java.rmi.Remote; - -/** - * 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 -{ - static final long serialVersionUID = 8367026044764648243L; - - // FIXME: Serialization: Need to write methods for. - - /** - * 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 = - new DataFlavor("text/plain; charset=unicode; class=java.io.InputStream", - "plain unicode text"); - - /** - * 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 = - new DataFlavor(java.lang.String.class, "Java Unicode String"); - - /** - * 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 = - new DataFlavor("application/x-java-file-list; class=java.util.List", - "Java File List"); - - /** - * This is an image flavor used for transferring images. The - * representation type is a <code>java.awt.Image</code>. - */ - public static final DataFlavor imageFlavor = - new DataFlavor(java.awt.Image.class, "Java Image"); - - /** - * 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-objectref"; - - /** - * 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"; - - /* - * Instance Variables - */ - - // The MIME type for this flavor - private MimeType mimeType; - - // The representation class for this flavor - private 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 - { - // Bootstrap - try - { - return Class.forName(className); - } - catch(ClassNotFoundException cnfe) - { - // Ignored. - } - - // System - try - { - ClassLoader loader = ClassLoader.getSystemClassLoader(); - return Class.forName(className, true, loader); - } - catch(ClassNotFoundException cnfe) - { - // Ignored. - } - - // Context - try - { - ClassLoader loader = Thread.currentThread().getContextClassLoader(); - return Class.forName(className, true, loader); - } - catch(ClassNotFoundException cnfe) - { - // Ignored. - } - - if (classLoader != null) - return Class.forName(className, true, classLoader); - - throw new ClassNotFoundException(className); - } - - /** - * XXX - Currently returns <code>plainTextFlavor</code>. - */ - public static final DataFlavor getTextPlainUnicodeFlavor() - { - return plainTextFlavor; - } - - /** - * 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; - } - - - /* - * Constructors - */ - - /** - * Empty public constructor needed for externalization. - * Should not be used for normal instantiation. - */ - public DataFlavor() - { - // Used for deserialization only, nothing to do here. - } - - /** - * 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) - { - if (representationClass == null) - throw new NullPointerException("representationClass must not be null"); - try - { - mimeType = new MimeType(javaSerializedObjectMimeType); - } - catch (MimeTypeParseException ex) - { - // Must not happen as we use a constant string. - assert false; - } - if (humanPresentableName == null) - humanPresentableName = javaSerializedObjectMimeType; - this.humanPresentableName = humanPresentableName; - this.representationClass = representationClass; - } - - /** - * 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. - * @exception ClassNotFoundException If the class is not loaded. - */ - public DataFlavor(String mimeType, String humanPresentableName, - ClassLoader classLoader) - throws ClassNotFoundException - { - init(mimeType, humanPresentableName, classLoader); - } - - /** - * 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. - * - * @exception IllegalArgumentException If the representation class - * specified cannot be loaded. - */ - public DataFlavor(String mimeType, String humanPresentableName) - { - try - { - init(mimeType, humanPresentableName, getClass().getClassLoader()); - } - catch (ClassNotFoundException ex) - { - IllegalArgumentException iae = - new IllegalArgumentException("Class not found: " + ex.getMessage()); - iae.initCause(ex); - throw iae; - } - } - - /** - * 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 - { - init(mimeType, null, getClass().getClassLoader()); - } - - /** - * Called by various constructors to initialize this object. - * - * @param mime the mime string - * @param humanPresentableName the human presentable name - * @param loader the class loader to use for loading the representation - * class - */ - private void init(String mime, String humanPresentableName, - ClassLoader loader) - throws ClassNotFoundException - { - if (mime == null) - throw new NullPointerException("The mime type must not be null"); - try - { - mimeType = new MimeType(mime); - } - catch (MimeTypeParseException ex) - { - IllegalArgumentException iae = - new IllegalArgumentException("Invalid mime type"); - iae.initCause(ex); - throw iae; - } - String className = mimeType.getParameter("class"); - if (className == null) - { - if (mimeType.getBaseType().equals(javaSerializedObjectMimeType)) - throw new IllegalArgumentException("Serialized object type must have" - + " a representation class parameter"); - else - representationClass = java.io.InputStream.class; - } - else - representationClass = tryToLoadClass(className, loader); - mimeType.addParameter("class", representationClass.getName()); - - if (humanPresentableName == null) - { - humanPresentableName = mimeType.getParameter("humanPresentableName"); - if (humanPresentableName == null) - humanPresentableName = mimeType.getBaseType(); - } - this.humanPresentableName = humanPresentableName; - } - - /** - * Returns the MIME type of this flavor. - * - * @return The MIME type for this flavor. - */ - public String getMimeType() - { - return(mimeType.toString()); - } - - /** - * 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() - { - return(mimeType.getPrimaryType()); - } - - /** - * Returns the MIME subtype for this flavor. - * - * @return The MIME subtype for this flavor. - */ - public String getSubType() - { - return mimeType.getSubType(); - } - - /** - * 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) - { - if ("humanPresentableName".equals(paramName)) - return getHumanPresentableName(); - - return mimeType.getParameter(paramName); - } - - /** - * 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. Ignores parameters. - * - * @param mimeType The MIME type to test against. - * - * @return <code>true</code> if the MIME type is equal to this object's - * MIME type (ignoring parameters), <code>false</code> otherwise. - * - * @exception NullPointerException If mimeType is null. - */ - public boolean isMimeTypeEqual(String mimeType) - { - if (mimeType == null) - throw new NullPointerException("mimeType must not be null"); - boolean equal = false; - try - { - if (this.mimeType != null) - { - MimeType other = new MimeType(mimeType); - equal = this.mimeType.matches(other); - } - } - catch (MimeTypeParseException ex) - { - // Return false in this case. - } - return equal; - } - - /** - * 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 final 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 isMimeTypeEqual(javaSerializedObjectMimeType); - } - - /** - * Tests whether or not this flavor has a representation class of - * <code>java.io.InputStream</code>. - * - * @return <code>true</code> if the representation class of this flavor - * is <code>java.io.InputStream</code>, <code>false</code> otherwise. - */ - public boolean isRepresentationClassInputStream() - { - return InputStream.class.isAssignableFrom(representationClass); - } - - /** - * Tests whether the representation class for this flavor is - * serializable. - * - * @return <code>true</code> if the representation class is serializable, - * <code>false</code> otherwise. - */ - public boolean isRepresentationClassSerializable() - { - return Serializable.class.isAssignableFrom(representationClass); - } - - /** - * 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() - { - return Remote.class.isAssignableFrom (representationClass); - } - - /** - * 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() - { - return isRepresentationClassSerializable() - && isMimeTypeEqual(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 isRepresentationClassRemote() - && isRepresentationClassSerializable() - && isMimeTypeEqual(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 (getPrimaryType().equals(javaFileListFlavor.getPrimaryType()) - && getSubType().equals(javaFileListFlavor.getSubType()) - && javaFileListFlavor.representationClass - .isAssignableFrom(representationClass)) - return true; - - return false ; - } - - /** - * Returns a copy of this object. - * - * @return A copy of this object. - * - * @exception CloneNotSupportedException If the object's class does not support - * the Cloneable interface. Subclasses that override the clone method can also - * throw this exception to indicate that an instance cannot be cloned. - */ - public Object clone () throws CloneNotSupportedException - { - // FIXME - This cannot be right. - 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 class are the equal. If the primary type is 'text' - * then also the value of the charset parameter is compared. In such a - * case when the charset parameter isn't given then the charset is - * assumed to be equal to the default charset of the platform. All - * other parameters are ignored. - * - * @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; - - String primary = getPrimaryType(); - if (! primary.equals(flavor.getPrimaryType())) - return false; - - String sub = getSubType(); - if (! sub.equals(flavor.getSubType())) - return false; - - if (! this.representationClass.equals(flavor.representationClass)) - return false; - - if (primary.equals("text")) - if (! isRepresentationClassCharBuffer() - && ! isRepresentationClassReader() - && representationClass != java.lang.String.class - && ! (representationClass.isArray() - && representationClass.getComponentType() == Character.TYPE)) - { - String charset = getParameter("charset"); - String otherset = flavor.getParameter("charset"); - String defaultset = Charset.defaultCharset().name(); - - if (charset == null || charset.equals(defaultset)) - return (otherset == null || otherset.equals(defaultset)); - - return charset.equals(otherset); - } - - 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> - * <li>The object is an instance of <code>DataFlavor</code>.</li> - * <li>The object's MIME type and representation class are equal to - * this object's.</li> - * </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 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.toString().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. - * - * @exception IOException If an error occurs. - */ - public void writeExternal(ObjectOutput stream) - throws IOException - { - if (mimeType != null) - { - mimeType.addParameter("humanPresentableName", humanPresentableName); - stream.writeObject(mimeType); - mimeType.removeParameter("humanPresentableName"); - } - else - stream.writeObject(null); - stream.writeObject(representationClass); - } - - - /** - * De-serialize this class. - * - * @param stream The <code>ObjectInput</code> stream to deserialize from. - * - * @exception IOException If an error ocurs. - * @exception ClassNotFoundException If the class for an object being restored - * cannot be found. - */ - public void readExternal(ObjectInput stream) - throws IOException, ClassNotFoundException - { - mimeType = (MimeType) stream.readObject(); - String className = null; - if (mimeType != null) - { - humanPresentableName = - mimeType.getParameter("humanPresentableName"); - mimeType.removeParameter("humanPresentableName"); - className = mimeType.getParameter("class"); - if (className == null) - throw new IOException("No class in mime type"); - } - try - { - representationClass = (Class) stream.readObject(); - } - catch (OptionalDataException ex) - { - if (ex.eof && ex.length == 0) - { - if (className != null) - representationClass = tryToLoadClass(className, - getClass().getClassLoader()); - } - else - throw ex; - } - } - - /** - * Returns a string representation of this DataFlavor. Including the - * representation class name, MIME type and human presentable name. - */ - public String toString() - { - return (getClass().getName() - + "[representationClass=" + getRepresentationClass().getName() - + ",mimeType=" + getMimeType() - + ",humanPresentableName=" + getHumanPresentableName() - + "]"); - } - - /** - * XXX - Currently returns <code>java.io.InputStream</code>. - * - * @since 1.3 - */ - public final Class<?> getDefaultRepresentationClass() - { - return java.io.InputStream.class; - } - - /** - * XXX - Currently returns <code>java.io.InputStream</code>. - */ - public final String getDefaultRepresentationClassAsString() - { - return getDefaultRepresentationClass().getName(); - } - - /** - * 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 IllegalArgumentException If the representation class is not one - * of the seven listed above or the Transferable has null data. - * @exception NullPointerException If the Transferable is null. - * @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 - { - 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); - } - - /** - * Returns whether the representation class for this DataFlavor is - * @see java.nio.ByteBuffer or a subclass thereof. - * - * @since 1.4 - */ - public boolean isRepresentationClassByteBuffer() - { - return ByteBuffer.class.isAssignableFrom(representationClass); - } - - /** - * Returns whether the representation class for this DataFlavor is - * @see java.nio.CharBuffer or a subclass thereof. - * - * @since 1.4 - */ - public boolean isRepresentationClassCharBuffer() - { - return CharBuffer.class.isAssignableFrom(representationClass); - } - - /** - * Returns whether the representation class for this DataFlavor is - * @see java.io.Reader or a subclass thereof. - * - * @since 1.4 - */ - public boolean isRepresentationClassReader() - { - return Reader.class.isAssignableFrom(representationClass); - } - - /** - * Returns whether this <code>DataFlavor</code> is a valid text flavor for - * this implementation of the Java platform. Only flavors equivalent to - * <code>DataFlavor.stringFlavor</code> and <code>DataFlavor</code>s with - * a primary MIME type of "text" can be valid text flavors. - * <p> - * If this flavor supports the charset parameter, it must be equivalent to - * <code>DataFlavor.stringFlavor</code>, or its representation must be - * <code>java.io.Reader</code>, <code>java.lang.String</code>, - * <code>java.nio.CharBuffer</code>, <code>java.io.InputStream</code> or - * <code>java.nio.ByteBuffer</code>, - * If the representation is <code>java.io.InputStream</code> or - * <code>java.nio.ByteBuffer</code>, then this flavor's <code>charset</code> - * parameter must be supported by this implementation of the Java platform. - * If a charset is not specified, then the platform default charset, which - * is always supported, is assumed. - * <p> - * If this flavor does not support the charset parameter, its - * representation must be <code>java.io.InputStream</code>, - * <code>java.nio.ByteBuffer</code>. - * <p> - * See <code>selectBestTextFlavor</code> for a list of text flavors which - * support the charset parameter. - * - * @return <code>true</code> if this <code>DataFlavor</code> is a valid - * text flavor as described above; <code>false</code> otherwise - * @see #selectBestTextFlavor - * @since 1.4 - */ - public boolean isFlavorTextType() { - // FIXME: I'm not 100% sure if this implementation does the same like sun's does - if(equals(DataFlavor.stringFlavor) || getPrimaryType().equals("text")) - { - String charset = getParameter("charset"); - Class c = getRepresentationClass(); - if(charset != null) - { - if(Reader.class.isAssignableFrom(c) - || CharBuffer.class.isAssignableFrom(c) - || String.class.isAssignableFrom(c)) - { - return true; - } - else if(InputStream.class.isAssignableFrom(c) - || ByteBuffer.class.isAssignableFrom(c)) - { - return Charset.isSupported(charset); - } - } - else if(InputStream.class.isAssignableFrom(c) - || ByteBuffer.class.isAssignableFrom(c)) - { - return true; - } - } - return false; - } -} // class DataFlavor diff --git a/libjava/classpath/java/awt/datatransfer/FlavorEvent.java b/libjava/classpath/java/awt/datatransfer/FlavorEvent.java deleted file mode 100644 index 8a292f8..0000000 --- a/libjava/classpath/java/awt/datatransfer/FlavorEvent.java +++ /dev/null @@ -1,57 +0,0 @@ -/* FlavorEvent -- Event indicating a ClipBoard has different flavors available. - Copyright (C) 2005 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., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 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.EventObject; - -/** - * Event indicating a Clipboard has different flavors available. - * Fired by a ClipBoard for registered FlavorListeners. - * - * @author Mark J. Wielaard (mark@klomp.org) - * - * @since 1.5 - */ -public class FlavorEvent extends EventObject -{ - public FlavorEvent(Clipboard board) - { - super(board); - } -} diff --git a/libjava/classpath/java/awt/datatransfer/FlavorListener.java b/libjava/classpath/java/awt/datatransfer/FlavorListener.java deleted file mode 100644 index eb388aa..0000000 --- a/libjava/classpath/java/awt/datatransfer/FlavorListener.java +++ /dev/null @@ -1,54 +0,0 @@ -/* FlavorListener -- Interface for tagging an interest in FlavorEvents. - Copyright (C) 2005 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., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 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.EventListener; - -/** - * Interface for tagging an interest in FlavorEvents by a class. The - * flavorsChanged() method will be called with a FlavorEvent pointing - * to the Clipboard which has content in different Flavors available. - * - * @author Mark J. Wielaard (mark@klomp.org) - */ -public interface FlavorListener - extends EventListener -{ - void flavorsChanged(FlavorEvent event); -} diff --git a/libjava/classpath/java/awt/datatransfer/FlavorMap.java b/libjava/classpath/java/awt/datatransfer/FlavorMap.java deleted file mode 100644 index 8842c8e..0000000 --- a/libjava/classpath/java/awt/datatransfer/FlavorMap.java +++ /dev/null @@ -1,75 +0,0 @@ -/* 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., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 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. - */ - Map<DataFlavor, String> 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. - */ - Map<String, DataFlavor> getFlavorsForNatives (String[] natives); -} diff --git a/libjava/classpath/java/awt/datatransfer/FlavorTable.java b/libjava/classpath/java/awt/datatransfer/FlavorTable.java deleted file mode 100644 index f6c43af..0000000 --- a/libjava/classpath/java/awt/datatransfer/FlavorTable.java +++ /dev/null @@ -1,73 +0,0 @@ -/* FlavorTable.java -- A relaxed mapping between flavors - Copyright (C) 2002, 2005 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., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 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.List; - -/** - * A FlavorMap which no longer requires a 1-to-1 mapping between flavors. Any - * native can map to multiple flavors, and any flavor can map to multiple - * natives; although the mappings are usually symmetric. - * - * @author Eric Blake (ebb9@email.byu.edu) - * @since 1.4 - * @status updated to 1.4 - */ -public interface FlavorTable extends FlavorMap -{ - /** - * Returns a list of String natives corresponding to the given flavor. The - * list should be sorted from best to worst. The list must be modifiable - * without affecting this table. - * - * @param flavor the flavor to look up, or null to return all natives - * @return the sorted list of natives - */ - List<String> getNativesForFlavor(DataFlavor flavor); - - /** - * Returns a list of flavors corresponding to the given String native. The - * list should be sorted from best to worst. The list must be modifiable - * without affecting this table. - * - * @param name the native name to look up, or null to return all flavors - * @return the sorted list of flavors - */ - List<DataFlavor> getFlavorsForNative(String name); -} diff --git a/libjava/classpath/java/awt/datatransfer/MimeType.java b/libjava/classpath/java/awt/datatransfer/MimeType.java deleted file mode 100644 index 143e870..0000000 --- a/libjava/classpath/java/awt/datatransfer/MimeType.java +++ /dev/null @@ -1,283 +0,0 @@ -/* MimeType.java -- A helper class for mime handling in DataFlavor - Copyright (C) 2006 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., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 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 gnu.java.lang.CPStringBuilder; - -import java.io.Externalizable; -import java.io.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.NoSuchElementException; -import java.util.Set; -import java.util.StringTokenizer; - -/** - * A helper class for mime handling in DataFlavor. - * - * A Mauve test for DataFlavor.writeExternal() shows that a non-public - * class java.awt.datatransfer.MimeType gets serialized. This class - * is mainly here for serialization compatibility. Of course, - * now that we have it here, we can just as well implement some - * mime handling facility here. - */ -class MimeType - implements Externalizable -{ - - /** - * The primary type. - */ - private String primaryType; - - /** - * The subtype. - */ - private String subType; - - /** - * Additional parameters to be appended to the mime string. - */ - private HashMap parameters; - - /** - * This is only here for deserialization. - */ - public MimeType() - { - parameters = new HashMap(); - } - - /** - * Creates a new MimeType object. - * - * @param mime the mime type - */ - MimeType(String mime) - throws MimeTypeParseException - { - this(); - parse(mime); - } - - /** - * Adds a mime parameter. - * - * @param param the parameter key - * @param value the parameter value - */ - void addParameter(String param, String value) - { - parameters.put(param, value); - } - - /** - * Removes the parameter with the specified key. - * - * @param param the parameter to remove - */ - void removeParameter(String param) - { - parameters.remove(param); - } - - /** - * Returns the parameter for the <code>key</code>. - * - * @param key the parameter key - * - * @return the parameter for the <code>key</code> - */ - String getParameter(String key) - { - return (String) parameters.get(key); - } - - /** - * Returns the primary type. - * - * @return the primary type - */ - String getPrimaryType() - { - return primaryType; - } - - String getSubType() - { - return subType; - } - - /** - * Returns the base type of this mime type. This is the primary - * type plus the subtype, separated by '/'. - * - * @return the base type of this mime type - */ - String getBaseType() - { - return primaryType + '/' + subType; - } - - /** - * Returns <code>true</code> if this mime type and another mime type - * match. This will be true when their primary types are equal, and their - * subtypes are equal (or when either subtype is * ). - * - * @param other the other mime type - * - * @return <code>true</code> if the mime types match, <code>false</code> - * otherwise - */ - boolean matches(MimeType other) - { - boolean match = false; - if (other != null) - { - match = primaryType.equals(other.primaryType) - && (subType.equals("*") || other.subType.equals("*") - || subType.equals(other.subType)); - } - return match; - } - - /** - * Serializes the mime type. - * - * @param in the input stream to read from - * - * @throws ClassNotFoundException not thrown here - * @throws IOException when something goes wrong on the input stream, - * or when the mime type can't be parsed - */ - public void readExternal(ObjectInput in) - throws ClassNotFoundException, IOException - { - String mime = in.readUTF(); - parameters.clear(); - try - { - parse(mime); - } - catch (MimeTypeParseException ex) - { - IOException ioEx = new IOException(); - ioEx.initCause(ex); - throw ioEx; - } - } - - /** - * Serializes this mime type. - * - * @param out the output stream - * - * @throws IOException when something goes wrong on the output stream - */ - public void writeExternal(ObjectOutput out) - throws IOException - { - out.writeUTF(toString()); - } - - /** - * Creates a string representation of this mime type. - * - * @return a string representation of this mime type - */ - public String toString() - { - CPStringBuilder s = new CPStringBuilder(); - s.append(primaryType); - s.append('/'); - s.append(subType); - if (parameters.size() > 0) - { - Set entries = parameters.entrySet(); - for (Iterator i = entries.iterator(); i.hasNext();) - { - s.append("; "); - Map.Entry entry = (Map.Entry) i.next(); - s.append(entry.getKey()); - s.append('='); - s.append(entry.getValue()); - } - } - return s.toString(); - } - - /** - * Parses the specified mime type string and initializes the fields - * of this object. - * - * @param mime the mime type string - */ - private void parse(String mime) - throws MimeTypeParseException - { - // FIXME: Maybe implement more sophisticated mime string parsing according - // to RFC 2045 and 2046. - StringTokenizer tokenizer = new StringTokenizer(mime); - try - { - primaryType = tokenizer.nextToken("/"); - subType = tokenizer.nextToken("/;"); - } - catch (NoSuchElementException ex) - { - throw new MimeTypeParseException("Expected / separator"); - } - - // Add any parameters. - while (tokenizer.hasMoreTokens()) - { - String keyValuePair = tokenizer.nextToken(";"); - int i = keyValuePair.indexOf('='); - if (i == -1) - throw new MimeTypeParseException("Expected = as parameter separator"); - String key = keyValuePair.substring(0, i).trim(); - String value = keyValuePair.substring(i + 1).trim(); - parameters.put(key, value); - } - } - -} diff --git a/libjava/classpath/java/awt/datatransfer/MimeTypeParseException.java b/libjava/classpath/java/awt/datatransfer/MimeTypeParseException.java deleted file mode 100644 index 6113ab7..0000000 --- a/libjava/classpath/java/awt/datatransfer/MimeTypeParseException.java +++ /dev/null @@ -1,70 +0,0 @@ -/* MimeTypeParseException.java -- thrown when MIME string couldn't be parsed - Copyright (C) 2001, 2002, 2005 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., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 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) - * @status updated to 1.4 - */ -public class MimeTypeParseException extends Exception -{ - /** - * Compatible with JDK 1.1+. - */ - private static final long serialVersionUID = -5604407764691570741L; - - /** - * Create a new instance without any message. - */ - public MimeTypeParseException() - { - } - - /** - * Create a new instance with a specified detailed error message. - * - * @param message the message - */ - public MimeTypeParseException(String message) - { - super(message); - } -} // class MimeTypeParseException diff --git a/libjava/classpath/java/awt/datatransfer/StringSelection.java b/libjava/classpath/java/awt/datatransfer/StringSelection.java deleted file mode 100644 index 4b64cda..0000000 --- a/libjava/classpath/java/awt/datatransfer/StringSelection.java +++ /dev/null @@ -1,157 +0,0 @@ -/* StringSelection.java -- Clipboard handler for text. - Copyright (C) 1999, 2004 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., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 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; -import java.io.StringReader; - -/** - * 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 -// XXX: DataFlavor.plainTextFlavor is deprecated. -static final DataFlavor[] supported_flavors - = { DataFlavor.stringFlavor, - DataFlavor.plainTextFlavor }; - -/*************************************************************************/ - -/* - * Instance Variables - */ - -// This is the data to transfer -private String data; - - /** - * Transfer the specfied string as text. - * - * @param data the data for the string selection - */ - public StringSelection(String data) - { - this.data = data; - } - -/** - * 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); - - if (DataFlavor.plainTextFlavor == flavor) - /* The behavior of this method for DataFlavor.plainTextFlavor and - equivalent DataFlavors is inconsistent with the definition of - DataFlavor.plainTextFlavor. We choose to do like Sun's implementation - and return a Reader instead of an InputString. */ - /* return(new StringBufferInputStream(data)); */ - return(new StringReader(data)); - else // DataFlavor.stringFlavor - return 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/classpath/java/awt/datatransfer/SystemFlavorMap.java b/libjava/classpath/java/awt/datatransfer/SystemFlavorMap.java deleted file mode 100644 index 65c14c1..0000000 --- a/libjava/classpath/java/awt/datatransfer/SystemFlavorMap.java +++ /dev/null @@ -1,561 +0,0 @@ -/* SystemFlavorMap.java -- Maps between native flavor names and MIME types. - Copyright (C) 2001, 2004 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., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 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.awt.Toolkit; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; -import java.security.AccessController; -import java.security.PrivilegedAction; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Properties; -import java.util.WeakHashMap; - -/** - * 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) - * - * @since 1.2 - */ -public final class SystemFlavorMap implements FlavorMap, FlavorTable -{ - /** - * The map which maps the thread's <code>ClassLoaders</code> to - * <code>SystemFlavorMaps</code>. - */ - private static final Map systemFlavorMaps = new WeakHashMap(); - - /** - * Constant which is used to prefix encode Java MIME types. - */ - private static final String GNU_JAVA_MIME_PREFIX = "gnu.java:"; - - /** - * This map maps native <code>String</code>s to lists of - * <code>DataFlavor</code>s - */ - private HashMap<String,List<DataFlavor>> nativeToFlavorMap = - new HashMap<String,List<DataFlavor>>(); - - /** - * This map maps <code>DataFlavor</code>s to lists of native - * <code>String</code>s - */ - private HashMap<DataFlavor, List<String>> flavorToNativeMap = - new HashMap<DataFlavor, List<String>>(); - - /** - * Private constructor. - */ - private SystemFlavorMap () - { - AccessController.doPrivileged - (new PrivilegedAction<Object>() - { - public Object run() - { - try - { - // Load installed flavormap.properties first. - String sep = File.separator; - File propsFile = - new File(System.getProperty("gnu.classpath.home.url") - + sep + "accessibility.properties"); - InputStream in = new FileInputStream(propsFile); - Properties props = new Properties(); - props.load(in); - in.close(); - - String augmented = Toolkit.getProperty("AWT.DnD.flavorMapFileURL", - null); - if (augmented != null) - { - URL url = new URL(augmented); - in = url.openStream(); - props.load(in); - } - setupMapping(props); - } - catch (IOException ex) - { - // Can't do anything about it. - } - return null; - } - }); - } - - /** - * Sets up the mapping from native to mime types and vice versa as specified - * in the flavormap.properties file. - * - * This is package private to avoid an accessor method. - * - * @param props the properties file - */ - void setupMapping(Properties props) - { - Enumeration propNames = props.propertyNames(); - while (propNames.hasMoreElements()) - { - try - { - String nat = (String) propNames.nextElement(); - String mime = (String) props.getProperty(nat); - // Check valid mime type. - MimeType type = new MimeType(mime); - DataFlavor flav = new DataFlavor(mime); - - List<DataFlavor> flavs = nativeToFlavorMap.get(nat); - if (flavs == null) - { - flavs = new ArrayList<DataFlavor>(); - nativeToFlavorMap.put(nat, flavs); - } - List<String> nats = flavorToNativeMap.get(flav); - if (nats == null) - { - nats = new ArrayList<String>(); - flavorToNativeMap.put(flav, nats); - } - flavs.add(flav); - nats.add(nat); - } - catch (ClassNotFoundException ex) - { - // Skip. - } - catch (MimeTypeParseException ex) - { - // Skip. - } - } - } - - /** - * 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<DataFlavor, String> getNativesForFlavors (DataFlavor[] flavors) - { - return new HashMap<DataFlavor, String>(); - } - - /** - * 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<String, DataFlavor> getFlavorsForNatives (String[] natives) - { - return new HashMap<String, DataFlavor>(); - } - - /** - * Returns the (System)FlavorMap for the current thread's - * ClassLoader. - */ - public static FlavorMap getDefaultFlavorMap () - { - ClassLoader classLoader = Thread.currentThread() - .getContextClassLoader(); - - //if ContextClassLoader not set, use system default - if (classLoader == null) - { - classLoader = ClassLoader.getSystemClassLoader(); - } - - synchronized(systemFlavorMaps) - { - FlavorMap map = (FlavorMap) - systemFlavorMaps.get(classLoader); - if (map == null) - { - map = new SystemFlavorMap(); - systemFlavorMaps.put(classLoader, map); - } - return map; - } - } - - /** - * Encodes a MIME type for use as a <code>String</code> native. The format - * of an encoded representation of a MIME type is implementation-dependent. - * The only restrictions are: - * <ul> - * <li>The encoded representation is <code>null</code> if and only if the - * MIME type <code>String</code> is <code>null</code>.</li> - * <li>The encoded representations for two non-<code>null</code> MIME type - * <code>String</code>s are equal if and only if these <code>String</code>s - * are equal according to <code>String.equals(Object)</code>.</li> - * </ul> - * <p> - * The present implementation of this method returns the specified MIME - * type <code>String</code> prefixed with <code>gnu.java:</code>. - * - * @param mime the MIME type to encode - * @return the encoded <code>String</code>, or <code>null</code> if - * mimeType is <code>null</code> - */ - public static String encodeJavaMIMEType (String mime) - { - if (mime != null) - return GNU_JAVA_MIME_PREFIX + mime; - else - return null; - } - - /** - * Encodes a <code>DataFlavor</code> for use as a <code>String</code> - * native. The format of an encoded <code>DataFlavor</code> is - * implementation-dependent. The only restrictions are: - * <ul> - * <li>The encoded representation is <code>null</code> if and only if the - * specified <code>DataFlavor</code> is <code>null</code> or its MIME type - * <code>String</code> is <code>null</code>.</li> - * <li>The encoded representations for two non-<code>null</code> - * <code>DataFlavor</code>s with non-<code>null</code> MIME type - * <code>String</code>s are equal if and only if the MIME type - * <code>String</code>s of these <code>DataFlavor</code>s are equal - * according to <code>String.equals(Object)</code>.</li> - * </ul> - * <p> - * The present implementation of this method returns the MIME type - * <code>String</code> of the specified <code>DataFlavor</code> prefixed - * with <code>gnu.java:</code>. - * - * @param df the <code>DataFlavor</code> to encode - * @return the encoded <code>String</code>, or <code>null</code> if - * flav is <code>null</code> or has a <code>null</code> MIME type - */ - public static String encodeDataFlavor (DataFlavor df) - { - if (df != null) - { - return encodeJavaMIMEType(df.getMimeType()); - } - else - return null; - } - - /** - * Returns true if the native type name can be represented as - * a java mime type. Returns <code>false</code> if parameter is - * <code>null</code>. - */ - public static boolean isJavaMIMEType (String name) - { - return (name != null && name.startsWith(GNU_JAVA_MIME_PREFIX)); - } - - /** - * Decodes a <code>String</code> native for use as a Java MIME type. - * - * @param name the <code>String</code> to decode - * @return the decoded Java MIME type, or <code>null</code> if nat - * is not an encoded <code>String</code> native - */ - public static String decodeJavaMIMEType (String name) - { - if (isJavaMIMEType(name)) - { - return name.substring(GNU_JAVA_MIME_PREFIX.length()); - } - else - 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; - } - - /** - * Returns a List of <code>DataFlavors</code> to which the specified - * <code>String</code> native can be translated by the data transfer - * subsystem. The <code>List</code> will be sorted from best - * <code>DataFlavor</code> to worst. That is, the first <code>DataFlavor - * </code> will best reflect data in the specified native to a Java - * application. - * <p> - * If the specified native is previously unknown to the data transfer - * subsystem, and that native has been properly encoded, then invoking - * this method will establish a mapping in both directions between the - * specified native and a DataFlavor whose MIME type is a decoded - * version of the native. - */ - public List<DataFlavor> getFlavorsForNative(String nat) - { - List<DataFlavor> ret = new ArrayList<DataFlavor>(); - if (nat == null) - { - Collection<List<DataFlavor>> all = nativeToFlavorMap.values(); - for (List<DataFlavor> list : all) - { - for (DataFlavor flav : list) - { - if (! ret.contains(flav)) - ret.add(flav); - } - } - } - else - { - List<DataFlavor> list = nativeToFlavorMap.get(nat); - if (list != null) - ret.addAll(list); - } - return ret; - } - - public List<String> getNativesForFlavor (DataFlavor flav) - { - List<String> ret = new ArrayList<String>(); - if (flav == null) - { - Collection<List<String>> all = flavorToNativeMap.values(); - for (List<String> list : all) - { - for (String nat : list) - { - if (! ret.contains(nat)) - ret.add(nat); - } - } - } - else - { - List<String> list = flavorToNativeMap.get(flav); - if (list != null) - ret.addAll(list); - } - return ret; - } - - /** - * Adds a mapping from a single <code>String</code> native to a single - * <code>DataFlavor</code>. Unlike <code>getFlavorsForNative</code>, the - * mapping will only be established in one direction, and the native will - * not be encoded. To establish a two-way mapping, call - * <code>addUnencodedNativeForFlavor</code> as well. The new mapping will - * be of lower priority than any existing mapping. - * This method has no effect if a mapping from the specified - * <code>String</code> native to the specified or equal - * <code>DataFlavor</code> already exists. - * - * @param nativeStr the <code>String</code> native key for the mapping - * @param flavor the <code>DataFlavor</code> value for the mapping - * @throws NullPointerException if nat or flav is <code>null</code> - * - * @see #addUnencodedNativeForFlavor - * @since 1.4 - */ - public synchronized void addFlavorForUnencodedNative(String nativeStr, - DataFlavor flavor) - { - if ((nativeStr == null) || (flavor == null)) - throw new NullPointerException(); - List<DataFlavor> flavors = nativeToFlavorMap.get(nativeStr); - if (flavors == null) - { - flavors = new ArrayList<DataFlavor>(); - nativeToFlavorMap.put(nativeStr, flavors); - } - else - { - if (! flavors.contains(flavor)) - flavors.add(flavor); - } - } - - /** - * Adds a mapping from the specified <code>DataFlavor</code> (and all - * <code>DataFlavor</code>s equal to the specified <code>DataFlavor</code>) - * to the specified <code>String</code> native. - * Unlike <code>getNativesForFlavor</code>, the mapping will only be - * established in one direction, and the native will not be encoded. To - * establish a two-way mapping, call - * <code>addFlavorForUnencodedNative</code> as well. The new mapping will - * be of lower priority than any existing mapping. - * This method has no effect if a mapping from the specified or equal - * <code>DataFlavor</code> to the specified <code>String</code> native - * already exists. - * - * @param flavor the <code>DataFlavor</code> key for the mapping - * @param nativeStr the <code>String</code> native value for the mapping - * @throws NullPointerException if flav or nat is <code>null</code> - * - * @see #addFlavorForUnencodedNative - * @since 1.4 - */ - public synchronized void addUnencodedNativeForFlavor(DataFlavor flavor, - String nativeStr) - { - if ((nativeStr == null) || (flavor == null)) - throw new NullPointerException(); - List<String> natives = flavorToNativeMap.get(flavor); - if (natives == null) - { - natives = new ArrayList<String>(); - flavorToNativeMap.put(flavor, natives); - } - else - { - if (! natives.contains(nativeStr)) - natives.add(nativeStr); - } - } - - /** - * Discards the current mappings for the specified <code>DataFlavor</code> - * and all <code>DataFlavor</code>s equal to the specified - * <code>DataFlavor</code>, and creates new mappings to the - * specified <code>String</code> natives. - * Unlike <code>getNativesForFlavor</code>, the mappings will only be - * established in one direction, and the natives will not be encoded. To - * establish two-way mappings, call <code>setFlavorsForNative</code> - * as well. The first native in the array will represent the highest - * priority mapping. Subsequent natives will represent mappings of - * decreasing priority. - * <p> - * If the array contains several elements that reference equal - * <code>String</code> natives, this method will establish new mappings - * for the first of those elements and ignore the rest of them. - * <p> - * It is recommended that client code not reset mappings established by the - * data transfer subsystem. This method should only be used for - * application-level mappings. - * - * @param flavor the <code>DataFlavor</code> key for the mappings - * @param natives the <code>String</code> native values for the mappings - * @throws NullPointerException if flav or natives is <code>null</code> - * or if natives contains <code>null</code> elements - * - * @see #setFlavorsForNative - * @since 1.4 - */ - public synchronized void setNativesForFlavor(DataFlavor flavor, - String[] natives) - { - if ((natives == null) || (flavor == null)) - throw new NullPointerException(); - - flavorToNativeMap.remove(flavor); - for (int i = 0; i < natives.length; i++) - { - addUnencodedNativeForFlavor(flavor, natives[i]); - } - } - - /** - * Discards the current mappings for the specified <code>String</code> - * native, and creates new mappings to the specified - * <code>DataFlavor</code>s. Unlike <code>getFlavorsForNative</code>, the - * mappings will only be established in one direction, and the natives need - * not be encoded. To establish two-way mappings, call - * <code>setNativesForFlavor</code> as well. The first - * <code>DataFlavor</code> in the array will represent the highest priority - * mapping. Subsequent <code>DataFlavor</code>s will represent mappings of - * decreasing priority. - * <p> - * If the array contains several elements that reference equal - * <code>DataFlavor</code>s, this method will establish new mappings - * for the first of those elements and ignore the rest of them. - * <p> - * It is recommended that client code not reset mappings established by the - * data transfer subsystem. This method should only be used for - * application-level mappings. - * - * @param nativeStr the <code>String</code> native key for the mappings - * @param flavors the <code>DataFlavor</code> values for the mappings - * @throws NullPointerException if nat or flavors is <code>null</code> - * or if flavors contains <code>null</code> elements - * - * @see #setNativesForFlavor - * @since 1.4 - */ - public synchronized void setFlavorsForNative(String nativeStr, - DataFlavor[] flavors) - { - if ((nativeStr == null) || (flavors == null)) - throw new NullPointerException(); - - nativeToFlavorMap.remove(nativeStr); - for (int i = 0; i < flavors.length; i++) - { - addFlavorForUnencodedNative(nativeStr, flavors[i]); - } - } - -} // class SystemFlavorMap diff --git a/libjava/classpath/java/awt/datatransfer/Transferable.java b/libjava/classpath/java/awt/datatransfer/Transferable.java deleted file mode 100644 index 99239fc..0000000 --- a/libjava/classpath/java/awt/datatransfer/Transferable.java +++ /dev/null @@ -1,82 +0,0 @@ -/* Transferable.java -- Data transfer source - Copyright (C) 1999, 2002, 2005 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., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 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) - * @since 1.1 - * @status updated to 1.4 - */ -public interface Transferable -{ - /** - * 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 adA list of data flavors for this data - */ - DataFlavor[] getTransferDataFlavors(); - - /** - * Tests whether or not this data can be delivered in the specified data - * flavor. - * - * @param flavor the data flavor to test - * @return true if the data flavor is supported - */ - boolean isDataFlavorSupported(DataFlavor flavor); - - /** - * Returns the data in the specified <code>DataFlavor</code>. - * - * @param flavor the data flavor to return - * @return the data in the appropriate flavor - * @throws UnsupportedFlavorException if the flavor is not supported - * @throws IOException if the data is not available - * @see DataFlavor#getRepresentationClass - */ - Object getTransferData(DataFlavor flavor) - throws UnsupportedFlavorException, IOException; - -} // interface Transferable diff --git a/libjava/classpath/java/awt/datatransfer/UnsupportedFlavorException.java b/libjava/classpath/java/awt/datatransfer/UnsupportedFlavorException.java deleted file mode 100644 index 0ca17b2..0000000 --- a/libjava/classpath/java/awt/datatransfer/UnsupportedFlavorException.java +++ /dev/null @@ -1,65 +0,0 @@ -/* UnsupportedFlavorException.java -- ata flavor is not valid - Copyright (C) 1999, 2002, 2005 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., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 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) - * @see Transferable#getTransferData(DataFlavor) - * @status updated to 1.4 - */ -public class UnsupportedFlavorException extends Exception -{ - /** - * Compatible with JDK 1.1+. - */ - private static final long serialVersionUID = 5383814944251665601L; - - /** - * 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 == null ? null : flavor.getHumanPresentableName()); - } -} // class UnsupportedFlavorException diff --git a/libjava/classpath/java/awt/datatransfer/package.html b/libjava/classpath/java/awt/datatransfer/package.html deleted file mode 100644 index 5ab860c..0000000 --- a/libjava/classpath/java/awt/datatransfer/package.html +++ /dev/null @@ -1,47 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> -<!-- package.html - describes classes in java.awt.datatransfer package. - Copyright (C) 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., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 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. --> - -<html> -<head><title>GNU Classpath - java.awt.datatransfer</title></head> - -<body> -<p>Classes to represent different flavors of data for transferring native -and system types through for example a clipboard.</p> - -</body> -</html> |