--- old/src/java.datatransfer/share/classes/java/awt/datatransfer/Clipboard.java 2017-05-23 19:14:11.000000000 -0700 +++ new/src/java.datatransfer/share/classes/java/awt/datatransfer/Clipboard.java 2017-05-23 19:14:11.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,29 +25,26 @@ package java.awt.datatransfer; -import sun.datatransfer.DataFlavorUtil; - +import java.io.IOException; +import java.util.Arrays; +import java.util.HashSet; import java.util.Objects; import java.util.Set; -import java.util.HashSet; -import java.util.Arrays; -import java.io.IOException; +import sun.datatransfer.DataFlavorUtil; /** - * A class that implements a mechanism to transfer data using - * cut/copy/paste operations. + * A class that implements a mechanism to transfer data using cut/copy/paste + * operations. *
- * {@link FlavorListener}s may be registered on an instance of the
- * Clipboard class to be notified about changes to the set of
- * {@link DataFlavor}s available on this clipboard (see
- * {@link #addFlavorListener}).
+ * {@link FlavorListener}s may be registered on an instance of the Clipboard
+ * class to be notified about changes to the set of {@link DataFlavor}s
+ * available on this clipboard (see {@link #addFlavorListener}).
*
+ * @author Amy Fowler
+ * @author Alexander Gerasimov
* @see java.awt.Toolkit#getSystemClipboard
* @see java.awt.Toolkit#getSystemSelection
- *
- * @author Amy Fowler
- * @author Alexander Gerasimov
*/
public class Clipboard {
@@ -57,6 +54,7 @@
* The owner of the clipboard.
*/
protected ClipboardOwner owner;
+
/**
* Contents of the clipboard.
*/
@@ -70,9 +68,9 @@
private Set
- * If there is an existing owner different from the argument
- *
- * The method throws
- * An instance of {@code DataFlavor} encapsulates a content type as
- * defined in RFC 2045
- * and RFC 2046.
- * A content type is typically referred to as a MIME type.
+ * An instance of {@code DataFlavor} encapsulates a content type as defined in
+ * RFC 2045 and
+ * RFC 2046. A content type is
+ * typically referred to as a MIME type.
*
- * A content type consists of a media type (referred
- * to as the primary type), a subtype, and optional parameters. See
- * RFC 2045
- * for details on the syntax of a MIME type.
+ * A content type consists of a media type (referred to as the primary type), a
+ * subtype, and optional parameters. See
+ * RFC 2045 for details on the
+ * syntax of a MIME type.
*
- * The JRE data transfer implementation interprets the parameter "class"
- * of a MIME type as a representation class.
- * The representation class reflects the class of the object being
- * transferred. In other words, the representation class is the type of
- * object returned by {@link Transferable#getTransferData}.
- * For example, the MIME type of {@link #imageFlavor} is
- * {@code "image/x-java-image;class=java.awt.Image"},
- * the primary type is {@code image}, the subtype is
- * {@code x-java-image}, and the representation class is
- * {@code java.awt.Image}. When {@code getTransferData} is invoked
- * with a {@code DataFlavor} of {@code imageFlavor}, an instance of
- * {@code java.awt.Image} is returned.
- * It's important to note that {@code DataFlavor} does no error checking
- * against the representation class. It is up to consumers of
- * {@code DataFlavor}, such as {@code Transferable}, to honor the representation
- * class.
+ * The JRE data transfer implementation interprets the parameter
+ * "class" of a MIME type as a representation class. The
+ * representation class reflects the class of the object being transferred. In
+ * other words, the representation class is the type of object returned by
+ * {@link Transferable#getTransferData}. For example, the MIME type of
+ * {@link #imageFlavor} is {@code "image/x-java-image;class=java.awt.Image"},
+ * the primary type is {@code image}, the subtype is {@code x-java-image}, and
+ * the representation class is {@code java.awt.Image}. When
+ * {@code getTransferData} is invoked with a {@code DataFlavor} of
+ * {@code imageFlavor}, an instance of {@code java.awt.Image} is returned. It's
+ * important to note that {@code DataFlavor} does no error checking against the
+ * representation class. It is up to consumers of {@code DataFlavor}, such as
+ * {@code Transferable}, to honor the representation class.
*
- * Also, {@code DataFlavor} instances with the "text" primary
- * MIME type may have a "charset" parameter. Refer to
+ * Also, {@code DataFlavor} instances with the "text" primary MIME
+ * type may have a "charset" parameter. Refer to
* RFC 2046 and
- * {@link #selectBestTextFlavor} for details on "text" MIME types
- * and the "charset" parameter.
+ * {@link #selectBestTextFlavor} for details on "text" MIME types and
+ * the "charset" parameter.
*
- * Equality of {@code DataFlavors} is determined by the primary type,
- * subtype, and representation class. Refer to {@link #equals(DataFlavor)} for
- * details. When determining equality, any optional parameters are ignored.
- * For example, the following produces two {@code DataFlavors} that
- * are considered identical:
+ * Equality of {@code DataFlavors} is determined by the primary type, subtype,
+ * and representation class. Refer to {@link #equals(DataFlavor)} for details.
+ * When determining equality, any optional parameters are ignored. For example,
+ * the following produces two {@code DataFlavors} that are considered identical:
*
- * For more information on using data transfer with Swing see
- * the
- * How to Use Drag and Drop and Data Transfer,
- * section in Java Tutorial.
+ * For more information on using data transfer with Swing see the
+ * How
+ * to Use Drag and Drop and Data Transfer, section in
+ * Java Tutorial.
*
- * @author Blake Sullivan
- * @author Laurence P. G. Cable
- * @author Jeff Dunn
+ * @author Blake Sullivan
+ * @author Laurence P. G. Cable
+ * @author Jeff Dunn
*/
public class DataFlavor implements Externalizable, Cloneable {
@@ -119,13 +114,13 @@
private static final Class
+ * The representation class associated with this {@code DataFlavor}
+ * identifies the Java type of an object returned as a reference from an
+ * invocation {@code java.awt.datatransfer.getTransferData}.
*/
public static final String javaSerializedObjectMimeType = "application/x-java-serialized-object";
/**
- * To transfer a list of files to/from Java (and the underlying
- * platform) a
- * The object reference returned from
- *
+ * The object reference returned from {@code Transferable.getTransferData}
+ * for a {@code DataFlavor} with this MIME Content-Type is required to be an
+ * instance of the representation Class of the {@code DataFlavor}.
*/
public static final String javaJVMLocalObjectMimeType = "application/x-java-jvm-local-objectref";
/**
* In order to pass a live link to a Remote object via a Drag and Drop
- *
- * The returned
- * The returned
- * If the
* Otherwise:
*
- * The returned
* If the mimeType is
* "application/x-java-serialized-object; class=<representation class>",
* the result is the same as calling
- *
* Otherwise:
*
* Flavors are first sorted by their MIME types in the following order:
* For example, "text/sgml" will be selected over
- * "text/html", and
+ * For example, "text/sgml" will be selected over "text/html", and
+ * {@code DataFlavor.stringFlavor} will be chosen over
+ * {@code DataFlavor.plainTextFlavor}.
*
* If two or more flavors share the best MIME type in the array, then that
* MIME type will be checked to see if it supports the charset parameter.
@@ -668,8 +655,8 @@
*
* If the best MIME type in the array does not support the charset
* parameter, the flavors which share that MIME type will then be sorted by
* their representation classes in the following order:
- *
* If two or more flavors share the best representation class, or if no
* flavor has one of the three specified representations, then one of those
@@ -705,9 +691,9 @@
*
* If the best MIME type in the array does support the charset parameter,
* the flavors which share that MIME type will then be sorted by their
- * representation classes in the following order:
- *
* If two or more flavors share the best representation class, and that
* representation is one of the four explicitly listed, then one of those
@@ -717,23 +703,22 @@
* "UTF-16BE", "UTF-16LE", and their aliases, are considered best. After
* them, the platform default charset and its aliases are selected.
* "US-ASCII" and its aliases are worst. All other charsets are chosen in
- * alphabetical order, but only charsets supported by this implementation
- * of the Java platform will be considered.
+ * alphabetical order, but only charsets supported by this implementation of
+ * the Java platform will be considered.
*
* If two or more flavors share the best charset, the flavors will then
* again be sorted by their representation classes in the following order:
- *
* If two or more flavors share the best representation class, or if no
* flavor has one of the three specified representations, then one of those
* flavors will be chosen non-deterministically.
*
- * @param availableFlavors an array of available
* Because text flavors which do not support the charset parameter are
* encoded in a non-standard format, this method should not be called for
- * such flavors. However, in order to maintain backward-compatibility,
- * if this method is called for such a flavor, this method will treat the
- * flavor as though it supports the charset parameter and attempt to
- * decode it accordingly. See
- * The equals comparison for the {@code DataFlavor} class is implemented
- * as follows: Two
* If this flavor supports the charset parameter, it must be equivalent to
- *
- * If this flavor does not support the charset parameter, its
- * representation must be
+ * If this flavor does not support the charset parameter, its representation
+ * must be {@code java.io.InputStream}, {@code java.nio.ByteBuffer}, or
+ * {@code [B}.
*
- * See
- * This method is called for each parameter name/value pair and should
- * return the normalized representation of the
+ * This method is called for each parameter name/value pair and should
+ * return the normalized representation of the {@code parameterValue}.
+ *
+ * @param parameterName the parameter name
+ * @param parameterValue the parameter value
+ * @return the parameter value
+ * @deprecated This method is never invoked by this implementation from 1.1
+ * onwards
+ */
@Deprecated
protected String normalizeMimeTypeParameter(String parameterName, String parameterValue) {
return parameterValue;
}
- /**
- * Called for each MIME type string to give
- * Some notifications may be redundant — they are not
- * caused by a change of the set of DataFlavors available
- * on the clipboard.
- * For example, if the clipboard subsystem supposes that
- * the system clipboard's contents has been changed but it
- * can't ascertain whether its DataFlavors have been changed
- * because of some exceptional condition when accessing the
- * clipboard, the notification is sent to ensure from omitting
- * a significant notification. Ordinarily, those redundant
- * notifications should be occasional.
+ * Some notifications may be redundant — they are not caused by a
+ * change of the set of DataFlavors available on the clipboard. For example,
+ * if the clipboard subsystem supposes that the system clipboard's contents
+ * has been changed but it can't ascertain whether its DataFlavors have been
+ * changed because of some exceptional condition when accessing the
+ * clipboard, the notification is sent to ensure from omitting a significant
+ * notification. Ordinarily, those redundant notifications should be
+ * occasional.
*
- * @param e a
+ * THIS IS *NOT* - REPEAT *NOT* - A PUBLIC CLASS! DataFlavor IS THE PUBLIC
+ * INTERFACE, AND THIS IS PROVIDED AS A ***PRIVATE*** (THAT IS AS IN *NOT*
+ * PUBLIC) HELPER CLASS!
*/
class MimeType implements Externalizable, Cloneable {
@@ -50,45 +48,45 @@
static final long serialVersionUID = -6568722458793895906L;
/**
- * Constructor for externalization; this constructor should not be
- * called directly by an application, since the result will be an
- * uninitialized, immutable
+ * This {@code Transferable} properly supports {@code DataFlavor.stringFlavor}
+ * and all equivalent flavors. Support for {@code DataFlavor.plainTextFlavor}
+ * and all equivalent flavors is deprecated. No other {@code DataFlavor}s
+ * are supported.
*
- * @see java.awt.datatransfer.DataFlavor#stringFlavor
- * @see java.awt.datatransfer.DataFlavor#plainTextFlavor
+ * @see DataFlavor#stringFlavor
+ * @see DataFlavor#plainTextFlavor
*/
public class StringSelection implements Transferable, ClipboardOwner {
@@ -56,23 +54,23 @@
private String data;
/**
- * Creates a
+ * Do not use the field directly, use {@link #getNativeToFlavor} instead.
*/
private final Map
+ * Do not use the field directly, use {@link #getFlavorToNative} instead.
*/
private final Map
+ * Do not use this field directly, use {@link #getTextTypeToNative} instead.
*/
private MapDataFlavor
s that is available on
- * this local clipboard. It is used for tracking changes
- * of DataFlavor
s available on this clipboard.
+ * A set of {@code DataFlavor}s that is available on this local clipboard.
+ * It is used for tracking changes of {@code DataFlavor}s available on this
+ * clipboard.
*
* @since 1.5
*/
@@ -80,7 +78,8 @@
/**
* Creates a clipboard object.
- * @param name for the clipboard
+ *
+ * @param name for the clipboard
* @see java.awt.Toolkit#getSystemClipboard
*/
public Clipboard(String name) {
@@ -89,8 +88,8 @@
/**
* Returns the name of this clipboard object.
- * @return the name of this clipboard object
*
+ * @return the name of this clipboard object
* @see java.awt.Toolkit#getSystemClipboard
*/
public String getName() {
@@ -98,27 +97,25 @@
}
/**
- * Sets the current contents of the clipboard to the specified
- * transferable object and registers the specified clipboard owner
- * as the owner of the new contents.
+ * Sets the current contents of the clipboard to the specified transferable
+ * object and registers the specified clipboard owner as the owner of the
+ * new contents.
* owner
, that owner is notified that it no longer
- * holds ownership of the clipboard contents via an invocation
- * of ClipboardOwner.lostOwnership()
on that owner.
- * An implementation of setContents()
is free not
- * to invoke lostOwnership()
directly from this method.
- * For example, lostOwnership()
may be invoked later on
- * a different thread. The same applies to FlavorListener
s
- * registered on this clipboard.
+ * If there is an existing owner different from the argument {@code owner},
+ * that owner is notified that it no longer holds ownership of the clipboard
+ * contents via an invocation of {@code ClipboardOwner.lostOwnership()} on
+ * that owner. An implementation of {@code setContents()} is free not to
+ * invoke {@code lostOwnership()} directly from this method. For example,
+ * {@code lostOwnership()} may be invoked later on a different thread. The
+ * same applies to {@code FlavorListener}s registered on this clipboard.
* IllegalStateException
if the clipboard
- * is currently unavailable. For example, on some platforms, the system
+ * The method throws {@code IllegalStateException} if the clipboard is
+ * currently unavailable. For example, on some platforms, the system
* clipboard is unavailable while it is accessed by another application.
*
- * @param contents the transferable object representing the
- * clipboard content
- * @param owner the object which owns the clipboard content
+ * @param contents the transferable object representing the clipboard
+ * content
+ * @param owner the object which owns the clipboard content
* @throws IllegalStateException if the clipboard is currently unavailable
* @see java.awt.Toolkit#getSystemClipboard
*/
@@ -137,15 +134,14 @@
}
/**
- * Returns a transferable object representing the current contents
- * of the clipboard. If the clipboard currently has no contents,
- * it returns null
. The parameter Object requestor is
- * not currently used. The method throws
- * IllegalStateException
if the clipboard is currently
- * unavailable. For example, on some platforms, the system clipboard is
+ * Returns a transferable object representing the current contents of the
+ * clipboard. If the clipboard currently has no contents, it returns
+ * {@code null}. The parameter Object requestor is not currently used. The
+ * method throws {@code IllegalStateException} if the clipboard is currently
+ * unavailable. For example, on some platforms, the system clipboard is
* unavailable while it is accessed by another application.
*
- * @param requestor the object requesting the clip data (not used)
+ * @param requestor the object requesting the clip data (not used)
* @return the current transferable object on the clipboard
* @throws IllegalStateException if the clipboard is currently unavailable
* @see java.awt.Toolkit#getSystemClipboard
@@ -154,18 +150,14 @@
return contents;
}
-
/**
- * Returns an array of DataFlavor
s in which the current
- * contents of this clipboard can be provided. If there are no
- * DataFlavor
s available, this method returns a zero-length
- * array.
- *
- * @return an array of DataFlavor
s in which the current
- * contents of this clipboard can be provided
+ * Returns an array of {@code DataFlavor}s in which the current contents of
+ * this clipboard can be provided. If there are no {@code DataFlavor}s
+ * available, this method returns a zero-length array.
*
+ * @return an array of {@code DataFlavor}s in which the current contents of
+ * this clipboard can be provided
* @throws IllegalStateException if this clipboard is currently unavailable
- *
* @since 1.5
*/
public DataFlavor[] getAvailableDataFlavors() {
@@ -178,17 +170,14 @@
/**
* Returns whether or not the current contents of this clipboard can be
- * provided in the specified DataFlavor
.
- *
- * @param flavor the requested DataFlavor
for the contents
- *
- * @return true
if the current contents of this clipboard
- * can be provided in the specified DataFlavor
;
- * false
otherwise
+ * provided in the specified {@code DataFlavor}.
*
- * @throws NullPointerException if flavor
is null
+ * @param flavor the requested {@code DataFlavor} for the contents
+ * @return {@code true} if the current contents of this clipboard can be
+ * provided in the specified {@code DataFlavor}; {@code false}
+ * otherwise
+ * @throws NullPointerException if {@code flavor} is {@code null}
* @throws IllegalStateException if this clipboard is currently unavailable
- *
* @since 1.5
*/
public boolean isDataFlavorAvailable(DataFlavor flavor) {
@@ -204,25 +193,20 @@
}
/**
- * Returns an object representing the current contents of this clipboard
- * in the specified DataFlavor
.
- * The class of the object returned is defined by the representation
- * class of flavor
.
- *
- * @param flavor the requested DataFlavor
for the contents
- *
- * @return an object representing the current contents of this clipboard
- * in the specified DataFlavor
- *
- * @throws NullPointerException if flavor
is null
+ * Returns an object representing the current contents of this clipboard in
+ * the specified {@code DataFlavor}. The class of the object returned is
+ * defined by the representation class of {@code flavor}.
+ *
+ * @param flavor the requested {@code DataFlavor} for the contents
+ * @return an object representing the current contents of this clipboard in
+ * the specified {@code DataFlavor}
+ * @throws NullPointerException if {@code flavor} is {@code null}
* @throws IllegalStateException if this clipboard is currently unavailable
- * @throws UnsupportedFlavorException if the requested DataFlavor
- * is not available
- * @throws IOException if the data in the requested DataFlavor
- * can not be retrieved
- *
+ * @throws UnsupportedFlavorException if the requested {@code DataFlavor} is
+ * not available
+ * @throws IOException if the data in the requested {@code DataFlavor} can
+ * not be retrieved
* @see DataFlavor#getRepresentationClass
- *
* @since 1.5
*/
public Object getData(DataFlavor flavor)
@@ -238,15 +222,12 @@
return cntnts.getTransferData(flavor);
}
-
/**
- * Registers the specified FlavorListener
to receive
- * FlavorEvent
s from this clipboard.
- * If listener
is null
, no exception
- * is thrown and no action is performed.
- *
- * @param listener the listener to be added
+ * Registers the specified {@code FlavorListener} to receive
+ * {@code FlavorEvent}s from this clipboard. If {@code listener} is
+ * {@code null}, no exception is thrown and no action is performed.
*
+ * @param listener the listener to be added
* @see #removeFlavorListener
* @see #getFlavorListeners
* @see FlavorListener
@@ -267,16 +248,14 @@
}
/**
- * Removes the specified FlavorListener
so that it no longer
- * receives FlavorEvent
s from this Clipboard
.
- * This method performs no function, nor does it throw an exception, if
- * the listener specified by the argument was not previously added to this
- * Clipboard
.
- * If listener
is null
, no exception
- * is thrown and no action is performed.
- *
- * @param listener the listener to be removed
+ * Removes the specified {@code FlavorListener} so that it no longer
+ * receives {@code FlavorEvent}s from this {@code Clipboard}. This method
+ * performs no function, nor does it throw an exception, if the listener
+ * specified by the argument was not previously added to this
+ * {@code Clipboard}. If {@code listener} is {@code null}, no exception is
+ * thrown and no action is performed.
*
+ * @param listener the listener to be removed
* @see #addFlavorListener
* @see #getFlavorListeners
* @see FlavorListener
@@ -291,11 +270,11 @@
}
/**
- * Returns an array of all the FlavorListener
s currently
- * registered on this Clipboard
.
+ * Returns an array of all the {@code FlavorListener}s currently registered
+ * on this {@code Clipboard}.
*
- * @return all of this clipboard's FlavorListener
s or an empty
- * array if no listeners are currently registered
+ * @return all of this clipboard's {@code FlavorListener}s or an empty array
+ * if no listeners are currently registered
* @see #addFlavorListener
* @see #removeFlavorListener
* @see FlavorListener
@@ -308,9 +287,9 @@
}
/**
- * Checks change of the DataFlavor
s and, if necessary,
- * notifies all listeners that have registered interest for notification
- * on FlavorEvent
s.
+ * Checks change of the {@code DataFlavor}s and, if necessary, notifies all
+ * listeners that have registered interest for notification on
+ * {@code FlavorEvent}s.
*
* @since 1.5
*/
@@ -330,12 +309,11 @@
}
/**
- * Returns a set of DataFlavor
s currently available
- * on this clipboard.
- *
- * @return a set of DataFlavor
s currently available
- * on this clipboard
+ * Returns a set of {@code DataFlavor}s currently available on this
+ * clipboard.
*
+ * @return a set of {@code DataFlavor}s currently available on this
+ * clipboard
* @since 1.5
*/
private Set
- * Note, if you do not specify a representation class when
- * creating a {@code DataFlavor}, the default
- * representation class is used. See appropriate documentation for
- * {@code DataFlavor}'s constructors.
+ * Note, if you do not specify a representation class when creating a
+ * {@code DataFlavor}, the default representation class is used. See appropriate
+ * documentation for {@code DataFlavor}'s constructors.
*
* DataFlavor flavor1 = new DataFlavor(Object.class, "X-test/test; class=<java.lang.Object>; foo=bar");
* DataFlavor flavor2 = new DataFlavor(Object.class, "X-test/test; class=<java.lang.Object>; x=y");
@@ -104,14 +99,14 @@
* As such, asking a {@code Transferable} for either {@code DataFlavor} returns
* the same results.
*
DataFlavor
representing a Java Unicode String class,
- * where:
+ * The {@code DataFlavor} representing a Java Unicode String class, where:
*
* representationClass = java.lang.String
- * mimeType = "application/x-java-serialized-object"
+ * mimeType = "application/x-java-serialized-object"
*
*/
public static final DataFlavor stringFlavor = createConstant(java.lang.String.class, "Unicode String");
/**
- * The DataFlavor
representing a Java Image class,
- * where:
+ * The {@code DataFlavor} representing a Java Image class, where:
*
* representationClass = java.awt.Image
* mimeType = "image/x-java-image"
@@ -218,79 +211,78 @@
public static final DataFlavor imageFlavor = createConstant("image/x-java-image; class=java.awt.Image", "Image");
/**
- * The
DataFlavor
representing plain text with Unicode
- * encoding, where:
+ * The {@code DataFlavor} representing plain text with Unicode encoding,
+ * where:
*
* representationClass = InputStream
* mimeType = "text/plain; charset=unicode"
*
- * This DataFlavor
has been deprecated because
- * (1) Its representation is an InputStream, an 8-bit based representation,
- * while Unicode is a 16-bit character set; and (2) The charset "unicode"
- * is not well-defined. "unicode" implies a particular platform's
- * implementation of Unicode, not a cross-platform implementation.
+ * This {@code DataFlavor} has been deprecated because:
+ *
+ *
*
- * @deprecated as of 1.3. Use DataFlavor.getReaderForText(Transferable)
- * instead of Transferable.getTransferData(DataFlavor.plainTextFlavor)
.
+ * @deprecated as of 1.3. Use {@link #getReaderForText} instead of
+ * {@code Transferable.getTransferData(DataFlavor.plainTextFlavor)}.
*/
@Deprecated
public static final DataFlavor plainTextFlavor = createConstant("text/plain; charset=unicode; class=java.io.InputStream", "Plain Text");
/**
- * A MIME Content-Type of application/x-java-serialized-object represents
- * a graph of Java object(s) that have been made persistent.
- *
- * The representation class associated with this DataFlavor
- * identifies the Java type of an object returned as a reference
- * from an invocation java.awt.datatransfer.getTransferData
.
+ * A MIME Content-Type of application/x-java-serialized-object represents a
+ * graph of Java object(s) that have been made persistent.
+ * DataFlavor
of this type/subtype and
- * representation class of java.util.List
is used.
- * Each element of the list is required/guaranteed to be of type
- * java.io.File
.
+ * To transfer a list of files to/from Java (and the underlying platform) a
+ * {@code DataFlavor} of this type/subtype and representation class of
+ * {@code java.util.List} is used. Each element of the list is
+ * required/guaranteed to be of type {@code java.io.File}.
*/
public static final DataFlavor javaFileListFlavor = createConstant("application/x-java-file-list;class=java.util.List", null);
/**
- * To transfer a reference to an arbitrary Java object reference that
- * has no associated MIME Content-type, across a Transferable
- * interface WITHIN THE SAME JVM, a DataFlavor
- * with this type/subtype is used, with a representationClass
- * equal to the type of the class/interface being passed across the
- * Transferable
.
- * Transferable.getTransferData
for a DataFlavor
- * with this MIME Content-Type is required to be
- * an instance of the representation Class of the DataFlavor
.
+ * To transfer a reference to an arbitrary Java object reference that has no
+ * associated MIME Content-type, across a {@code Transferable} interface
+ * WITHIN THE SAME JVM, a {@code DataFlavor} with this type/subtype is used,
+ * with a {@code representationClass} equal to the type of the
+ * class/interface being passed across the {@code Transferable}.
+ * ACTION_LINK
operation a Mime Content Type of
- * application/x-java-remote-object should be used,
- * where the representation class of the DataFlavor
- * represents the type of the Remote
interface to be
- * transferred.
+ * {@code ACTION_LINK} operation a Mime Content Type of
+ * application/x-java-remote-object should be used, where the representation
+ * class of the {@code DataFlavor} represents the type of the {@code Remote}
+ * interface to be transferred.
*/
public static final String javaRemoteObjectMimeType = "application/x-java-remote-object";
/**
* Represents a piece of an HTML markup. The markup consists of the part
* selected on the source side. Therefore some tags in the markup may be
- * unpaired. If the flavor is used to represent the data in
- * a {@link Transferable} instance, no additional changes will be made.
- * This DataFlavor instance represents the same HTML markup as DataFlavor
+ * unpaired. If the flavor is used to represent the data in a
+ * {@link Transferable} instance, no additional changes will be made. This
+ * DataFlavor instance represents the same HTML markup as DataFlavor
* instances which content MIME type does not contain document parameter
* and representation class is the String class.
*
* representationClass = String
- * mimeType = "text/html"
+ * mimeType = "text/html"
*
*
* @since 1.8
@@ -299,12 +291,12 @@
/**
* Represents a piece of an HTML markup. If possible, the markup received
- * from a native system is supplemented with pair tags to be
- * a well-formed HTML markup. If the flavor is used to represent the data in
- * a {@link Transferable} instance, no additional changes will be made.
+ * from a native system is supplemented with pair tags to be a well-formed
+ * HTML markup. If the flavor is used to represent the data in a
+ * {@link Transferable} instance, no additional changes will be made.
*
* representationClass = String
- * mimeType = "text/html"
+ * mimeType = "text/html"
*
*
* @since 1.8
@@ -312,25 +304,23 @@
public static DataFlavor fragmentHtmlFlavor = initHtmlDataFlavor("fragment");
/**
- * Represents a piece of an HTML markup. If possible, the markup
- * received from a native system is supplemented with additional
- * tags to make up a well-formed HTML document. If the flavor is used to
- * represent the data in a {@link Transferable} instance,
- * no additional changes will be made.
+ * Represents a piece of an HTML markup. If possible, the markup received
+ * from a native system is supplemented with additional tags to make up a
+ * well-formed HTML document. If the flavor is used to represent the data in
+ * a {@link Transferable} instance, no additional changes will be made.
*
* representationClass = String
- * mimeType = "text/html"
+ * mimeType = "text/html"
*
*
* @since 1.8
*/
- public static DataFlavor allHtmlFlavor = initHtmlDataFlavor("all");
+ public static DataFlavor allHtmlFlavor = initHtmlDataFlavor("all");
/**
- * Constructs a new DataFlavor
. This constructor is
- * provided only for the purpose of supporting the
- * Externalizable
interface. It is not
- * intended for public (client) use.
+ * Constructs a new {@code DataFlavor}. This constructor is provided only
+ * for the purpose of supporting the {@code Externalizable} interface. It is
+ * not intended for public (client) use.
*
* @since 1.2
*/
@@ -339,10 +329,10 @@
}
/**
- * Constructs a fully specified DataFlavor
.
+ * Constructs a fully specified {@code DataFlavor}.
*
- * @exception NullPointerException if either primaryType
,
- * subType
or representationClass
is null
+ * @throws NullPointerException if either {@code primaryType},
+ * {@code subType} or {@code representationClass} is {@code null}
*/
private DataFlavor(String primaryType, String subType, MimeTypeParameterList params, Class> representationClass, String humanPresentableName) {
super();
@@ -380,19 +370,21 @@
}
/**
- * Constructs a DataFlavor
that represents a Java class.
+ * Constructs a {@code DataFlavor} that represents a Java class.
* DataFlavor
will have the following
- * characteristics:
+ * The returned {@code DataFlavor} will have the following characteristics:
*
* representationClass = representationClass
* mimeType = application/x-java-serialized-object
*
- * @param representationClass the class used to transfer data in this flavor
- * @param humanPresentableName the human-readable string used to identify
- * this flavor; if this parameter is null
- * then the value of the MIME Content Type is used
- * @exception NullPointerException if representationClass
is null
+ *
+ * @param representationClass the class used to transfer data in this
+ * flavor
+ * @param humanPresentableName the human-readable string used to identify
+ * this flavor; if this parameter is {@code null} then the value of
+ * the MIME Content Type is used
+ * @throws NullPointerException if {@code representationClass} is
+ * {@code null}
*/
public DataFlavor(Class> representationClass, String humanPresentableName) {
this("application", "x-java-serialized-object", null, representationClass, humanPresentableName);
@@ -402,33 +394,31 @@
}
/**
- * Constructs a DataFlavor
that represents a
- * MimeType
.
+ * Constructs a {@code DataFlavor} that represents a {@code MimeType}.
* DataFlavor
will have the following
- * characteristics:
+ * The returned {@code DataFlavor} will have the following characteristics:
* mimeType
is
+ * If the {@code mimeType} is
* "application/x-java-serialized-object; class=<representation class>",
* the result is the same as calling
- * new DataFlavor(Class.forName(<representation class>)
.
+ * {@code new DataFlavor(Class.forName(
* representationClass = InputStream
* mimeType = mimeType
*
- * @param mimeType the string used to identify the MIME type for this flavor;
- * if the mimeType
does not specify a
- * "class=" parameter, or if the class is not successfully
- * loaded, then an IllegalArgumentException
- * is thrown
- * @param humanPresentableName the human-readable string used to identify
- * this flavor; if this parameter is null
- * then the value of the MIME Content Type is used
- * @exception IllegalArgumentException if mimeType
is
- * invalid or if the class is not successfully loaded
- * @exception NullPointerException if mimeType
is null
+ *
+ * @param mimeType the string used to identify the MIME type for this
+ * flavor; if the {@code mimeType} does not specify a "class="
+ * parameter, or if the class is not successfully loaded, then an
+ * {@code IllegalArgumentException} is thrown
+ * @param humanPresentableName the human-readable string used to identify
+ * this flavor; if this parameter is {@code null} then the value of
+ * the MIME Content Type is used
+ * @throws IllegalArgumentException if {@code mimeType} is invalid or if the
+ * class is not successfully loaded
+ * @throws NullPointerException if {@code mimeType} is {@code null}
*/
public DataFlavor(String mimeType, String humanPresentableName) {
super();
@@ -445,30 +435,29 @@
}
/**
- * Constructs a DataFlavor
that represents a
- * MimeType
.
+ * Constructs a {@code DataFlavor} that represents a {@code MimeType}.
* DataFlavor
will have the following
- * characteristics:
+ * The returned {@code DataFlavor} will have the following characteristics:
* new DataFlavor(Class.forName(<representation class>)
.
+ * {@code new DataFlavor(Class.forName(
* representationClass = InputStream
* mimeType = mimeType
*
- * @param mimeType the string used to identify the MIME type for this flavor
- * @param humanPresentableName the human-readable string used to
- * identify this flavor
- * @param classLoader the class loader to use
- * @exception ClassNotFoundException if the class is not loaded
- * @exception IllegalArgumentException if mimeType
is
- * invalid
- * @exception NullPointerException if mimeType
is null
+ *
+ * @param mimeType the string used to identify the MIME type for this
+ * flavor
+ * @param humanPresentableName the human-readable string used to identify
+ * this flavor
+ * @param classLoader the class loader to use
+ * @throws ClassNotFoundException if the class is not loaded
+ * @throws IllegalArgumentException if {@code mimeType} is invalid
+ * @throws NullPointerException if {@code mimeType} is {@code null}
*/
public DataFlavor(String mimeType, String humanPresentableName, ClassLoader classLoader) throws ClassNotFoundException {
super();
@@ -483,20 +472,19 @@
}
/**
- * Constructs a DataFlavor
from a mimeType
string.
- * The string can specify a "class=<fully specified Java class name>"
- * parameter to create a DataFlavor
with the desired
- * representation class. If the string does not contain "class=" parameter,
- * java.io.InputStream
is used as default.
- *
- * @param mimeType the string used to identify the MIME type for this flavor;
- * if the class specified by "class=" parameter is not
- * successfully loaded, then an
- * ClassNotFoundException
is thrown
- * @exception ClassNotFoundException if the class is not loaded
- * @exception IllegalArgumentException if mimeType
is
- * invalid
- * @exception NullPointerException if mimeType
is null
+ * Constructs a {@code DataFlavor} from a {@code mimeType} string. The
+ * string can specify a "class=<fully specified Java class name>"
+ * parameter to create a {@code DataFlavor} with the desired representation
+ * class. If the string does not contain "class=" parameter,
+ * {@code java.io.InputStream} is used as default.
+ *
+ * @param mimeType the string used to identify the MIME type for this
+ * flavor; if the class specified by "class=" parameter is not
+ * successfully loaded, then an {@code ClassNotFoundException} is
+ * thrown
+ * @throws ClassNotFoundException if the class is not loaded
+ * @throws IllegalArgumentException if {@code mimeType} is invalid
+ * @throws NullPointerException if {@code mimeType} is {@code null}
*/
public DataFlavor(String mimeType) throws ClassNotFoundException {
super();
@@ -510,20 +498,17 @@
}
}
- /**
- * Common initialization code called from various constructors.
- *
- * @param mimeType the MIME Content Type (must have a class= param)
- * @param humanPresentableName the human Presentable Name or
- * null
- * @param classLoader the fallback class loader to resolve against
- *
- * @throws MimeTypeParseException
- * @throws ClassNotFoundException
- * @throws NullPointerException if mimeType
is null
- *
- * @see #tryToLoadClass
- */
+ /**
+ * Common initialization code called from various constructors.
+ *
+ * @param mimeType the MIME Content Type (must have a class= param)
+ * @param humanPresentableName the human Presentable Name or {@code null}
+ * @param classLoader the fallback class loader to resolve against
+ * @throws MimeTypeParseException
+ * @throws ClassNotFoundException
+ * @throws NullPointerException if {@code mimeType} is {@code null}
+ * @see #tryToLoadClass
+ */
private void initialize(String mimeType, String humanPresentableName, ClassLoader classLoader) throws MimeTypeParseException, ClassNotFoundException {
if (mimeType == null) {
throw new NullPointerException("mimeType");
@@ -557,15 +542,15 @@
}
/**
- * String representation of this DataFlavor
and its
- * parameters. The resulting String
contains the name of
- * the DataFlavor
class, this flavor's MIME type, and its
- * representation class. If this flavor has a primary MIME type of "text",
- * supports the charset parameter, and has an encoded representation, the
- * flavor's charset is also included. See selectBestTextFlavor
- * for a list of text flavors which support the charset parameter.
+ * String representation of this {@code DataFlavor} and its parameters. The
+ * resulting {@code String} contains the name of the {@code DataFlavor}
+ * class, this flavor's MIME type, and its representation class. If this
+ * flavor has a primary MIME type of "text", supports the charset parameter,
+ * and has an encoded representation, the flavor's charset is also included.
+ * See {@code selectBestTextFlavor} for a list of text flavors which support
+ * the charset parameter.
*
- * @return string representation of this DataFlavor
+ * @return string representation of this {@code DataFlavor}
* @see #selectBestTextFlavor
*/
public String toString() {
@@ -599,19 +584,20 @@
}
/**
- * Returns a DataFlavor
representing plain text with Unicode
+ * Returns a {@code DataFlavor} representing plain text with Unicode
* encoding, where:
*
* representationClass = java.io.InputStream
* mimeType = "text/plain;
* charset=<platform default Unicode encoding>"
*
- * Sun's implementation for Microsoft Windows uses the encoding utf-16le
.
+ * Sun's implementation for Microsoft Windows uses the encoding
+ * {@code utf-16le}.
* Sun's implementation for Solaris and Linux uses the encoding
- * iso-10646-ucs-2
.
+ * {@code iso-10646-ucs-2}.
*
- * @return a DataFlavor
representing plain text
- * with Unicode encoding
+ * @return a {@code DataFlavor} representing plain text with Unicode
+ * encoding
* @since 1.3
*/
public static final DataFlavor getTextPlainUnicodeFlavor() {
@@ -621,10 +607,10 @@
}
/**
- * Selects the best text DataFlavor
from an array of
- * DataFlavor
s. Only DataFlavor.stringFlavor
, and
- * equivalent flavors, and flavors that have a primary MIME type of "text",
- * are considered for selection.
+ * Selects the best text {@code DataFlavor} from an array of
+ * {@code DataFlavor}s. Only {@code DataFlavor.stringFlavor}, and equivalent
+ * flavors, and flavors that have a primary MIME type of "text", are
+ * considered for selection.
*
@@ -646,9 +632,10 @@
*
- * DataFlavor.stringFlavor
will be chosen
- * over DataFlavor.plainTextFlavor
.
+ *
*
* For "text/<other>" MIME types, the first time the JRE needs to
* determine whether the MIME type supports the charset parameter, it will
- * check whether the parameter is explicitly listed in an arbitrarily
- * chosen DataFlavor
which uses that MIME type. If so, the JRE
- * will assume from that point on that the MIME type supports the charset
- * parameter and will not check again. If the parameter is not explicitly
- * listed, the JRE will assume from that point on that the MIME type does
- * not support the charset parameter and will not check again. Because
- * this check is performed on an arbitrarily chosen
- * DataFlavor
, developers must ensure that all
- * DataFlavor
s with a "text/<other>" MIME type specify
- * the charset parameter if it is supported by that MIME type. Developers
- * should never rely on the JRE to substitute the platform's default
- * charset for a "text/<other>" DataFlavor. Failure to adhere to this
- * restriction will lead to undefined behavior.
+ * check whether the parameter is explicitly listed in an arbitrarily chosen
+ * {@code DataFlavor} which uses that MIME type. If so, the JRE will assume
+ * from that point on that the MIME type supports the charset parameter and
+ * will not check again. If the parameter is not explicitly listed, the JRE
+ * will assume from that point on that the MIME type does not support the
+ * charset parameter and will not check again. Because this check is
+ * performed on an arbitrarily chosen {@code DataFlavor}, developers must
+ * ensure that all {@code DataFlavor}s with a "text/<other>" MIME type
+ * specify the charset parameter if it is supported by that MIME type.
+ * Developers should never rely on the JRE to substitute the platform's
+ * default charset for a "text/<other>" DataFlavor. Failure to adhere
+ * to this restriction will lead to undefined behavior.
* java.io.InputStream
, java.nio.ByteBuffer
,
- * [B
, <all others>.
+ * {@code java.io.InputStream}, {@code java.nio.ByteBuffer}, {@code [B},
+ * <all others>.
* java.io.Reader
, java.lang.String
,
- * java.nio.CharBuffer
, [C
, <all others>.
+ * representation classes in the following order: {@code java.io.Reader},
+ * {@code java.lang.String}, {@code java.nio.CharBuffer}, {@code [C},
+ * <all others>.
* java.io.InputStream
, java.nio.ByteBuffer
,
- * [B
, <all others>.
+ * {@code java.io.InputStream}, {@code java.nio.ByteBuffer}, {@code [B},
+ * <all others>.
* DataFlavor
s
+ * @param availableFlavors an array of available {@code DataFlavor}s
* @return the best (highest fidelity) flavor according to the rules
- * specified above, or null
,
- * if availableFlavors
is null
,
- * has zero length, or contains no text flavors
+ * specified above, or {@code null}, if {@code availableFlavors} is
+ * {@code null}, has zero length, or contains no text flavors
* @since 1.3
*/
public static final DataFlavor selectBestTextFlavor(
@@ -755,40 +740,33 @@
/**
* Gets a Reader for a text flavor, decoded, if necessary, for the expected
* charset (encoding). The supported representation classes are
- * java.io.Reader
, java.lang.String
,
- * java.nio.CharBuffer
, [C
,
- * java.io.InputStream
, java.nio.ByteBuffer
,
- * and [B
.
+ * {@code java.io.Reader}, {@code java.lang.String},
+ * {@code java.nio.CharBuffer}, {@code [C}, {@code java.io.InputStream},
+ * {@code java.nio.ByteBuffer}, and {@code [B}.
* selectBestTextFlavor
for a list
- * of text flavors which do not support the charset parameter.
- *
- * @param transferable the Transferable
whose data will be
- * requested in this flavor
- *
- * @return a Reader
to read the Transferable
's
- * data
- *
- * @exception IllegalArgumentException if the representation class
- * is not one of the seven listed above
- * @exception IllegalArgumentException if the Transferable
- * has null
data
- * @exception NullPointerException if the Transferable
is
- * null
- * @exception UnsupportedEncodingException if this flavor's representation
- * is java.io.InputStream
,
- * java.nio.ByteBuffer
, or [B
and
- * this flavor's encoding is not supported by this
- * implementation of the Java platform
- * @exception UnsupportedFlavorException if the Transferable
- * does not support this flavor
- * @exception IOException if the data cannot be read because of an
- * I/O error
+ * such flavors. However, in order to maintain backward-compatibility, if
+ * this method is called for such a flavor, this method will treat the
+ * flavor as though it supports the charset parameter and attempt to decode
+ * it accordingly. See {@code selectBestTextFlavor} for a list of text
+ * flavors which do not support the charset parameter.
+ *
+ * @param transferable the {@code Transferable} whose data will be
+ * requested in this flavor
+ * @return a {@code Reader} to read the {@code Transferable}'s data
+ * @throws IllegalArgumentException if the representation class is not one
+ * of the seven listed above
+ * @throws IllegalArgumentException if the {@code Transferable} has
+ * {@code null} data
+ * @throws NullPointerException if the {@code Transferable} is {@code null}
+ * @throws UnsupportedEncodingException if this flavor's representation is
+ * {@code java.io.InputStream}, {@code java.nio.ByteBuffer}, or
+ * {@code [B} and this flavor's encoding is not supported by this
+ * implementation of the Java platform
+ * @throws UnsupportedFlavorException if the {@code Transferable} does not
+ * support this flavor
+ * @throws IOException if the data cannot be read because of an I/O error
* @see #selectBestTextFlavor
* @since 1.3
*/
@@ -840,7 +818,8 @@
}
/**
- * Returns the MIME type string for this DataFlavor
.
+ * Returns the MIME type string for this {@code DataFlavor}.
+ *
* @return the MIME type string for this flavor
*/
public String getMimeType() {
@@ -848,12 +827,12 @@
}
/**
- * Returns the Class
which objects supporting this
- * DataFlavor
will return when this DataFlavor
- * is requested.
- * @return the Class
which objects supporting this
- * DataFlavor
will return when this DataFlavor
- * is requested
+ * Returns the {@code Class} which objects supporting this
+ * {@code DataFlavor} will return when this {@code DataFlavor} is requested.
+ *
+ * @return the {@code Class} which objects supporting this
+ * {@code DataFlavor} will return when this {@code DataFlavor} is
+ * requested
*/
public Class> getRepresentationClass() {
return representationClass;
@@ -861,39 +840,42 @@
/**
* Returns the human presentable name for the data format that this
- * DataFlavor
represents. This name would be localized
- * for different countries.
+ * {@code DataFlavor} represents. This name would be localized for different
+ * countries.
+ *
* @return the human presentable name for the data format that this
- * DataFlavor
represents
+ * {@code DataFlavor} represents
*/
public String getHumanPresentableName() {
return humanPresentableName;
}
/**
- * Returns the primary MIME type for this DataFlavor
.
- * @return the primary MIME type of this DataFlavor
+ * Returns the primary MIME type for this {@code DataFlavor}.
+ *
+ * @return the primary MIME type of this {@code DataFlavor}
*/
public String getPrimaryType() {
return (mimeType != null) ? mimeType.getPrimaryType() : null;
}
/**
- * Returns the sub MIME type of this DataFlavor
.
- * @return the Sub MIME type of this DataFlavor
+ * Returns the sub MIME type of this {@code DataFlavor}.
+ *
+ * @return the Sub MIME type of this {@code DataFlavor}
*/
public String getSubType() {
return (mimeType != null) ? mimeType.getSubType() : null;
}
/**
- * Returns the human presentable name for this DataFlavor
- * if paramName
equals "humanPresentableName". Otherwise
- * returns the MIME type value associated with paramName
.
- *
- * @param paramName the parameter name requested
- * @return the value of the name parameter, or null
- * if there is no associated value
+ * Returns the human presentable name for this {@code DataFlavor} if
+ * {@code paramName} equals "humanPresentableName". Otherwise returns the
+ * MIME type value associated with {@code paramName}.
+ *
+ * @param paramName the parameter name requested
+ * @return the value of the name parameter, or {@code null} if there is no
+ * associated value
*/
public String getParameter(String paramName) {
if (paramName.equals("humanPresentableName")) {
@@ -906,9 +888,10 @@
/**
* Sets the human presentable name for the data format that this
- * DataFlavor
represents. This name would be localized
- * for different countries.
- * @param humanPresentableName the new human presentable name
+ * {@code DataFlavor} represents. This name would be localized for different
+ * countries.
+ *
+ * @param humanPresentableName the new human presentable name
*/
public void setHumanPresentableName(String humanPresentableName) {
this.humanPresentableName = humanPresentableName;
@@ -917,22 +900,21 @@
/**
* {@inheritDoc}
* DataFlavor
s are considered equal if and
- * only if their MIME primary type and subtype and representation class are
- * equal. Additionally, if the primary type is "text", the subtype denotes
- * a text flavor which supports the charset parameter, and the
- * representation class is not java.io.Reader
,
- * java.lang.String
, java.nio.CharBuffer
, or
- * [C
, the charset
parameter must also be equal.
- * If a charset is not explicitly specified for one or both
- * DataFlavor
s, the platform default encoding is assumed. See
- * selectBestTextFlavor
for a list of text flavors which
- * support the charset parameter.
- *
- * @param o the Object
to compare with this
- * @return true
if that
is equivalent to this
- * DataFlavor
; false
otherwise
+ * The equals comparison for the {@code DataFlavor} class is implemented as
+ * follows: Two {@code DataFlavor}s are considered equal if and only if
+ * their MIME primary type and subtype and representation class are equal.
+ * Additionally, if the primary type is "text", the subtype denotes a text
+ * flavor which supports the charset parameter, and the representation class
+ * is not {@code java.io.Reader}, {@code java.lang.String},
+ * {@code java.nio.CharBuffer}, or {@code [C}, the {@code charset} parameter
+ * must also be equal. If a charset is not explicitly specified for one or
+ * both {@code DataFlavor}s, the platform default encoding is assumed. See
+ * {@code selectBestTextFlavor} for a list of text flavors which support the
+ * charset parameter.
+ *
+ * @param o the {@code Object} to compare with {@code this}
+ * @return {@code true} if {@code that} is equivalent to this
+ * {@code DataFlavor}; {@code false} otherwise
* @see #selectBestTextFlavor
*/
public boolean equals(Object o) {
@@ -940,14 +922,13 @@
}
/**
- * This method has the same behavior as {@link #equals(Object)}.
- * The only difference being that it takes a {@code DataFlavor} instance
- * as a parameter.
- *
- * @param that the DataFlavor
to compare with
- * this
- * @return true
if that
is equivalent to this
- * DataFlavor
; false
otherwise
+ * This method has the same behavior as {@link #equals(Object)}. The only
+ * difference being that it takes a {@code DataFlavor} instance as a
+ * parameter.
+ *
+ * @param that the {@code DataFlavor} to compare with {@code this}
+ * @return {@code true} if {@code that} is equivalent to this
+ * {@code DataFlavor}; {@code false} otherwise
* @see #selectBestTextFlavor
*/
public boolean equals(DataFlavor that) {
@@ -998,17 +979,16 @@
}
/**
- * Compares only the mimeType
against the passed in
- * String
and representationClass
is
- * not considered in the comparison.
- *
- * If representationClass
needs to be compared, then
- * equals(new DataFlavor(s))
may be used.
- * @deprecated As inconsistent with hashCode()
contract,
- * use isMimeTypeEqual(String)
instead.
- * @param s the {@code mimeType} to compare.
- * @return true if the String (MimeType) is equal; false otherwise or if
- * {@code s} is {@code null}
+ * Compares only the {@code mimeType} against the passed in {@code String}
+ * and {@code representationClass} is not considered in the comparison. If
+ * {@code representationClass} needs to be compared, then
+ * {@code equals(new DataFlavor(s))} may be used.
+ *
+ * @param s the {@code mimeType} to compare
+ * @return {@code true} if the String (MimeType) is equal; {@code false}
+ * otherwise or if {@code s} is {@code null}
+ * @deprecated As inconsistent with {@code hashCode()} contract, use
+ * {@link #isMimeTypeEqual(String)} instead.
*/
@Deprecated
public boolean equals(String s) {
@@ -1018,14 +998,13 @@
}
/**
- * Returns hash code for this DataFlavor
.
- * For two equal DataFlavor
s, hash codes are equal.
- * For the String
- * that matches DataFlavor.equals(String)
, it is not
- * guaranteed that DataFlavor
's hash code is equal
- * to the hash code of the String
.
+ * Returns hash code for this {@code DataFlavor}. For two equal
+ * {@code DataFlavor}s, hash codes are equal. For the {@code String} that
+ * matches {@code DataFlavor.equals(String)}, it is not guaranteed that
+ * {@code DataFlavor}'s hash code is equal to the hash code of the
+ * {@code String}.
*
- * @return a hash code for this DataFlavor
+ * @return a hash code for this {@code DataFlavor}
*/
public int hashCode() {
int total = 0;
@@ -1069,10 +1048,9 @@
/**
* Identical to {@link #equals(DataFlavor)}.
*
- * @param that the DataFlavor
to compare with
- * this
- * @return true
if that
is equivalent to this
- * DataFlavor
; false
otherwise
+ * @param that the {@code DataFlavor} to compare with {@code this}
+ * @return {@code true} if {@code that} is equivalent to this
+ * {@code DataFlavor}; {@code false} otherwise
* @see #selectBestTextFlavor
* @since 1.3
*/
@@ -1081,15 +1059,15 @@
}
/**
- * Returns whether the string representation of the MIME type passed in
- * is equivalent to the MIME type of this DataFlavor
.
- * Parameters are not included in the comparison.
- *
- * @param mimeType the string representation of the MIME type
- * @return true if the string representation of the MIME type passed in is
- * equivalent to the MIME type of this DataFlavor
;
- * false otherwise
- * @throws NullPointerException if mimeType is null
+ * Returns whether the string representation of the MIME type passed in is
+ * equivalent to the MIME type of this {@code DataFlavor}. Parameters are
+ * not included in the comparison.
+ *
+ * @param mimeType the string representation of the MIME type
+ * @return {@code true} if the string representation of the MIME type passed
+ * in is equivalent to the MIME type of this {@code DataFlavor};
+ * {@code false} otherwise
+ * @throws NullPointerException if mimeType is {@code null}
*/
public boolean isMimeTypeEqual(String mimeType) {
// JCK Test DataFlavor0117: if 'mimeType' is null, throw NPE
@@ -1107,26 +1085,24 @@
}
/**
- * Compares the mimeType
of two DataFlavor
- * objects. No parameters are considered.
+ * Compares the {@code mimeType} of two {@code DataFlavor} objects. No
+ * parameters are considered.
*
- * @param dataFlavor the DataFlavor
to be compared
- * @return true if the MimeType
s are equal,
- * otherwise false
+ * @param dataFlavor the {@code DataFlavor} to be compared
+ * @return {@code true} if the {@code MimeType}s are equal, otherwise
+ * {@code false}
*/
-
public final boolean isMimeTypeEqual(DataFlavor dataFlavor) {
return isMimeTypeEqual(dataFlavor.mimeType);
}
/**
- * Compares the mimeType
of two DataFlavor
- * objects. No parameters are considered.
+ * Compares the {@code mimeType} of two {@code DataFlavor} objects. No
+ * parameters are considered.
*
- * @return true if the MimeType
s are equal,
- * otherwise false
+ * @return {@code true} if the {@code MimeType}s are equal, otherwise
+ * {@code false}
*/
-
private boolean isMimeTypeEqual(MimeType mtype) {
if (this.mimeType == null) {
return (mtype == null);
@@ -1138,8 +1114,8 @@
* Checks if the representation class is one of the standard text
* representation classes.
*
- * @return true if the representation class is one of the standard text
- * representation classes, otherwise false
+ * @return {@code true} if the representation class is one of the standard
+ * text representation classes, otherwise {@code false}
*/
private boolean isStandardTextRepresentationClass() {
return isRepresentationClassReader()
@@ -1148,16 +1124,18 @@
|| char[].class.equals(representationClass);
}
- /**
- * Does the DataFlavor
represent a serialized object?
- * @return whether or not a serialized object is represented
- */
+ /**
+ * Does the {@code DataFlavor} represent a serialized object?
+ *
+ * @return whether or not a serialized object is represented
+ */
public boolean isMimeTypeSerializedObject() {
return isMimeTypeEqual(javaSerializedObjectMimeType);
}
/**
* Returns the default representation class.
+ *
* @return the default representation class
*/
public final Class> getDefaultRepresentationClass() {
@@ -1166,30 +1144,30 @@
/**
* Returns the name of the default representation class.
+ *
* @return the name of the default representation class
*/
public final String getDefaultRepresentationClassAsString() {
return getDefaultRepresentationClass().getName();
}
- /**
- * Does the DataFlavor
represent a
- * java.io.InputStream
?
- * @return whether or not this {@code DataFlavor} represent a
- * {@code java.io.InputStream}
- */
+ /**
+ * Does the {@code DataFlavor} represent a {@code java.io.InputStream}?
+ *
+ * @return whether or not this {@code DataFlavor} represent a
+ * {@code java.io.InputStream}
+ */
public boolean isRepresentationClassInputStream() {
return ioInputStreamClass.isAssignableFrom(representationClass);
}
/**
- * Returns whether the representation class for this
- * DataFlavor
is java.io.Reader
or a subclass
- * thereof.
- * @return whether or not the representation class for this
- * {@code DataFlavor} is {@code java.io.Reader} or a subclass
- * thereof
+ * Returns whether the representation class for this {@code DataFlavor} is
+ * {@code java.io.Reader} or a subclass thereof.
*
+ * @return whether or not the representation class for this
+ * {@code DataFlavor} is {@code java.io.Reader} or a subclass
+ * thereof
* @since 1.4
*/
public boolean isRepresentationClassReader() {
@@ -1197,13 +1175,12 @@
}
/**
- * Returns whether the representation class for this
- * DataFlavor
is java.nio.CharBuffer
or a
- * subclass thereof.
- * @return whether or not the representation class for this
- * {@code DataFlavor} is {@code java.nio.CharBuffer} or a subclass
- * thereof
+ * Returns whether the representation class for this {@code DataFlavor} is
+ * {@code java.nio.CharBuffer} or a subclass thereof.
*
+ * @return whether or not the representation class for this
+ * {@code DataFlavor} is {@code java.nio.CharBuffer} or a subclass
+ * thereof
* @since 1.4
*/
public boolean isRepresentationClassCharBuffer() {
@@ -1211,103 +1188,100 @@
}
/**
- * Returns whether the representation class for this
- * DataFlavor
is java.nio.ByteBuffer
or a
- * subclass thereof.
- * @return whether or not the representation class for this
- * {@code DataFlavor} is {@code java.nio.ByteBuffer} or a subclass
- * thereof
+ * Returns whether the representation class for this {@code DataFlavor} is
+ * {@code java.nio.ByteBuffer} or a subclass thereof.
*
+ * @return whether or not the representation class for this
+ * {@code DataFlavor} is {@code java.nio.ByteBuffer} or a subclass
+ * thereof
* @since 1.4
*/
public boolean isRepresentationClassByteBuffer() {
return java.nio.ByteBuffer.class.isAssignableFrom(representationClass);
}
- /**
- * Returns true if the representation class can be serialized.
- * @return true if the representation class can be serialized
- */
-
+ /**
+ * Returns {@code true} if the representation class can be serialized.
+ *
+ * @return {@code true} if the representation class can be serialized
+ */
public boolean isRepresentationClassSerializable() {
return java.io.Serializable.class.isAssignableFrom(representationClass);
}
- /**
- * Returns true if the representation class is Remote
.
- * @return true if the representation class is Remote
- */
+ /**
+ * Returns {@code true} if the representation class is {@code Remote}.
+ *
+ * @return {@code true} if the representation class is {@code Remote}
+ */
public boolean isRepresentationClassRemote() {
return DataFlavorUtil.RMI.isRemote(representationClass);
}
- /**
- * Returns true if the DataFlavor
specified represents
- * a serialized object.
- * @return true if the DataFlavor
specified represents
- * a Serialized Object
- */
-
+ /**
+ * Returns {@code true} if the {@code DataFlavor} specified represents a
+ * serialized object.
+ *
+ * @return {@code true} if the {@code DataFlavor} specified represents a
+ * Serialized Object
+ */
public boolean isFlavorSerializedObjectType() {
return isRepresentationClassSerializable() && isMimeTypeEqual(javaSerializedObjectMimeType);
}
/**
- * Returns true if the DataFlavor
specified represents
- * a remote object.
- * @return true if the DataFlavor
specified represents
- * a Remote Object
+ * Returns {@code true} if the {@code DataFlavor} specified represents a
+ * remote object.
+ *
+ * @return {@code true} if the {@code DataFlavor} specified represents a
+ * Remote Object
*/
-
public boolean isFlavorRemoteObjectType() {
return isRepresentationClassRemote()
&& isRepresentationClassSerializable()
&& isMimeTypeEqual(javaRemoteObjectMimeType);
}
-
- /**
- * Returns true if the DataFlavor
specified represents
- * a list of file objects.
- * @return true if the DataFlavor
specified represents
- * a List of File objects
- */
-
- public boolean isFlavorJavaFileListType() {
+ /**
+ * Returns {@code true} if the {@code DataFlavor} specified represents a
+ * list of file objects.
+ *
+ * @return {@code true} if the {@code DataFlavor} specified represents a
+ * List of File objects
+ */
+ public boolean isFlavorJavaFileListType() {
if (mimeType == null || representationClass == null)
return false;
return java.util.List.class.isAssignableFrom(representationClass) &&
mimeType.match(javaFileListFlavor.mimeType);
- }
+ }
/**
- * Returns whether this DataFlavor
is a valid text flavor for
- * this implementation of the Java platform. Only flavors equivalent to
- * DataFlavor.stringFlavor
and DataFlavor
s with
- * a primary MIME type of "text" can be valid text flavors.
+ * Returns whether this {@code DataFlavor} is a valid text flavor for this
+ * implementation of the Java platform. Only flavors equivalent to
+ * {@code DataFlavor.stringFlavor} and {@code DataFlavor}s with a primary
+ * MIME type of "text" can be valid text flavors.
* DataFlavor.stringFlavor
, or its representation must be
- * java.io.Reader
, java.lang.String
,
- * java.nio.CharBuffer
, [C
,
- * java.io.InputStream
, java.nio.ByteBuffer
, or
- * [B
. If the representation is
- * java.io.InputStream
, java.nio.ByteBuffer
, or
- * [B
, then this flavor's charset
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.
- * java.io.InputStream
,
- * java.nio.ByteBuffer
, or [B
.
+ * {@code DataFlavor.stringFlavor}, or its representation must be
+ * {@code java.io.Reader}, {@code java.lang.String},
+ * {@code java.nio.CharBuffer}, {@code [C}, {@code java.io.InputStream},
+ * {@code java.nio.ByteBuffer}, or {@code [B}. If the representation is
+ * {@code java.io.InputStream}, {@code java.nio.ByteBuffer}, or {@code [B},
+ * then this flavor's {@code charset} 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.
+ * selectBestTextFlavor
for a list of text flavors which
- * support the charset parameter.
+ * See {@code selectBestTextFlavor} for a list of text flavors which support
+ * the charset parameter.
*
- * @return true
if this DataFlavor
is a valid
- * text flavor as described above; false
otherwise
+ * @return {@code true} if this {@code DataFlavor} is a valid text flavor as
+ * described above; {@code false} otherwise
* @see #selectBestTextFlavor
* @since 1.4
*/
@@ -1316,10 +1290,9 @@
DataFlavorUtil.isFlavorNoncharsetTextType(this));
}
- /**
- * Serializes this DataFlavor
.
- */
-
+ /**
+ * Serializes this {@code DataFlavor}.
+ */
public synchronized void writeExternal(ObjectOutput os) throws IOException {
if (mimeType != null) {
mimeType.setParameter("humanPresentableName", humanPresentableName);
@@ -1332,12 +1305,11 @@
os.writeObject(representationClass);
}
- /**
- * Restores this DataFlavor
from a Serialized state.
- */
-
- public synchronized void readExternal(ObjectInput is) throws IOException , ClassNotFoundException {
- String rcn = null;
+ /**
+ * Restores this {@code DataFlavor} from a Serialized state.
+ */
+ public synchronized void readExternal(ObjectInput is) throws IOException , ClassNotFoundException {
+ String rcn = null;
mimeType = (MimeType)is.readObject();
if (mimeType != null) {
@@ -1364,13 +1336,13 @@
DataFlavor.tryToLoadClass(rcn, getClass().getClassLoader());
}
}
- }
-
- /**
- * Returns a clone of this DataFlavor
.
- * @return a clone of this DataFlavor
- */
+ }
+ /**
+ * Returns a clone of this {@code DataFlavor}.
+ *
+ * @return a clone of this {@code DataFlavor}
+ */
public Object clone() throws CloneNotSupportedException {
Object newObj = super.clone();
if (mimeType != null) {
@@ -1379,41 +1351,37 @@
return newObj;
} // clone()
- /**
- * Called on DataFlavor
for every MIME Type parameter
- * to allow DataFlavor
subclasses to handle special
- * parameters like the text/plain charset
- * parameters, whose values are case insensitive. (MIME type parameter
- * values are supposed to be case sensitive.
- * parameterValue
.
- *
- * This method is never invoked by this implementation from 1.1 onwards.
- *
- * @param parameterName the parameter name
- * @param parameterValue the parameter value
- * @return the parameter value
- * @deprecated
- */
+ /**
+ * Called on {@code DataFlavor} for every MIME Type parameter to allow
+ * {@code DataFlavor} subclasses to handle special parameters like the
+ * text/plain {@code charset} parameters, whose values are case insensitive.
+ * (MIME type parameter values are supposed to be case sensitive.
+ * DataFlavor
subtypes
- * the opportunity to change how the normalization of MIME types is
- * accomplished. One possible use would be to add default
- * parameter/value pairs in cases where none are present in the MIME
- * type string passed in.
- *
- * This method is never invoked by this implementation from 1.1 onwards.
- *
- * @param mimeType the mime type
- * @return the mime type
- * @deprecated
- */
+ /**
+ * Called for each MIME type string to give {@code DataFlavor} subtypes the
+ * opportunity to change how the normalization of MIME types is
+ * accomplished. One possible use would be to add default parameter/value
+ * pairs in cases where none are present in the MIME type string passed in.
+ *
+ * @param mimeType the mime type
+ * @return the mime type
+ * @deprecated This method is never invoked by this implementation from 1.1
+ * onwards
+ */
@Deprecated
protected String normalizeMimeType(String mimeType) {
return mimeType;
@@ -1433,8 +1401,9 @@
private String humanPresentableName;
- /** Java class of objects this DataFlavor represents **/
-
+ /**
+ * Java class of objects this DataFlavor represents.
+ **/
private Class> representationClass;
} // class DataFlavor
--- old/src/java.datatransfer/share/classes/java/awt/datatransfer/FlavorEvent.java 2017-05-23 19:14:13.000000000 -0700
+++ new/src/java.datatransfer/share/classes/java/awt/datatransfer/FlavorEvent.java 2017-05-23 19:14:13.000000000 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -22,29 +22,27 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
+
package java.awt.datatransfer;
import java.util.EventObject;
-
/**
- * FlavorEvent
is used to notify interested parties
- * that available {@link DataFlavor}s have changed in the
- * {@link Clipboard} (the event source).
- *
- * @see FlavorListener
+ * {@code FlavorEvent} is used to notify interested parties that available
+ * {@link DataFlavor}s have changed in the {@link Clipboard} (the event source).
*
* @author Alexander Gerasimov
+ * @see FlavorListener
* @since 1.5
*/
public class FlavorEvent extends EventObject {
+
private static final long serialVersionUID = -5842664112252414548L;
/**
- * Constructs a FlavorEvent
object.
- *
- * @param source the Clipboard
that is the source of the event
+ * Constructs a {@code FlavorEvent} object.
*
+ * @param source the {@code Clipboard} that is the source of the event
* @throws IllegalArgumentException if the {@code source} is {@code null}
*/
public FlavorEvent(Clipboard source) {
--- old/src/java.datatransfer/share/classes/java/awt/datatransfer/FlavorListener.java 2017-05-23 19:14:14.000000000 -0700
+++ new/src/java.datatransfer/share/classes/java/awt/datatransfer/FlavorListener.java 2017-05-23 19:14:14.000000000 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -22,11 +22,11 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
+
package java.awt.datatransfer;
import java.util.EventListener;
-
/**
* Defines an object which listens for {@link FlavorEvent}s.
*
@@ -34,22 +34,21 @@
* @since 1.5
*/
public interface FlavorListener extends EventListener {
+
/**
- * Invoked when the target {@link Clipboard} of the listener
- * has changed its available {@link DataFlavor}s.
+ * Invoked when the target {@link Clipboard} of the listener has changed its
+ * available {@link DataFlavor}s.
* FlavorEvent
object
+ * @param e a {@code FlavorEvent} object
*/
void flavorsChanged(FlavorEvent e);
}
--- old/src/java.datatransfer/share/classes/java/awt/datatransfer/FlavorMap.java 2017-05-23 19:14:14.000000000 -0700
+++ new/src/java.datatransfer/share/classes/java/awt/datatransfer/FlavorMap.java 2017-05-23 19:14:14.000000000 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,49 +27,45 @@
import java.util.Map;
-
/**
- * A two-way Map between "natives" (Strings), which correspond to platform-
- * specific data formats, and "flavors" (DataFlavors), which correspond to
- * platform-independent MIME types. FlavorMaps need not be symmetric, but
+ * A two-way Map between "natives" (Strings), which correspond to
+ * platform-specific data formats, and "flavors" (DataFlavors), which correspond
+ * to platform-independent MIME types. FlavorMaps need not be symmetric, but
* typically are.
*
- *
* @since 1.2
*/
public interface FlavorMap {
/**
- * Returns a Map
of the specified DataFlavor
s to
- * their corresponding String
native. The returned
- * Map
is a modifiable copy of this FlavorMap
's
- * internal data. Client code is free to modify the Map
- * without affecting this object.
+ * Returns a {@code Map} of the specified {@code DataFlavor}s to their
+ * corresponding {@code String} native. The returned {@code Map} is a
+ * modifiable copy of this {@code FlavorMap}'s internal data. Client code is
+ * free to modify the {@code Map} without affecting this object.
*
- * @param flavors an array of DataFlavor
s which will be the
- * key set of the returned Map
. If null
is
- * specified, a mapping of all DataFlavor
s currently
- * known to this FlavorMap
to their corresponding
- * String
natives will be returned.
- * @return a java.util.Map
of DataFlavor
s to
- * String
natives
+ * @param flavors an array of {@code DataFlavor}s which will be the key set
+ * of the returned {@code Map}. If {@code null} is specified, a
+ * mapping of all {@code DataFlavor}s currently known to this
+ * {@code FlavorMap} to their corresponding {@code String} natives
+ * will be returned.
+ * @return a {@code java.util.Map} of {@code DataFlavor}s to {@code String}
+ * natives
*/
- MapMap
of the specified String
natives
- * to their corresponding DataFlavor
. The returned
- * Map
is a modifiable copy of this FlavorMap
's
- * internal data. Client code is free to modify the Map
- * without affecting this object.
+ * Returns a {@code Map} of the specified {@code String} natives to their
+ * corresponding {@code DataFlavor}. The returned {@code Map} is a
+ * modifiable copy of this {@code FlavorMap}'s internal data. Client code is
+ * free to modify the {@code Map} without affecting this object.
*
- * @param natives an array of String
s which will be the
- * key set of the returned Map
. If null
is
- * specified, a mapping of all String
natives currently
- * known to this FlavorMap
to their corresponding
- * DataFlavor
s will be returned.
- * @return a java.util.Map
of String
natives to
- * DataFlavor
s
+ * @param natives an array of {@code String}s which will be the key set of
+ * the returned {@code Map}. If {@code null} is specified, a mapping
+ * of all {@code String} natives currently known to this
+ * {@code FlavorMap} to their corresponding {@code DataFlavor}s will
+ * be returned.
+ * @return a {@code java.util.Map} of {@code String} natives to
+ * {@code DataFlavor}s
*/
- MapList
of String
natives to which the
- * specified DataFlavor
corresponds. The List
- * will be sorted from best native to worst. That is, the first native will
- * best reflect data in the specified flavor to the underlying native
- * platform. The returned List
is a modifiable copy of this
- * FlavorTable
's internal data. Client code is free to modify
- * the List
without affecting this object.
+ * Returns a {@code List} of {@code String} natives to which the specified
+ * {@code DataFlavor} corresponds. The {@code List} will be sorted from best
+ * native to worst. That is, the first native will best reflect data in the
+ * specified flavor to the underlying native platform. The returned
+ * {@code List} is a modifiable copy of this {@code FlavorTable}'s internal
+ * data. Client code is free to modify the {@code List} without affecting
+ * this object.
*
- * @param flav the DataFlavor
whose corresponding natives
- * should be returned. If null
is specified, all
- * natives currently known to this FlavorTable
are
- * returned in a non-deterministic order.
- * @return a java.util.List
of java.lang.String
- * objects which are platform-specific representations of platform-
- * specific data formats
+ * @param flav the {@code DataFlavor} whose corresponding natives should be
+ * returned. If {@code null} is specified, all natives currently
+ * known to this {@code FlavorTable} are returned in a
+ * non-deterministic order.
+ * @return a {@code java.util.List} of {@code java.lang.String} objects
+ * which are platform-specific representations of platform-specific
+ * data formats
*/
ListList
of DataFlavor
s to which the
- * specified String
corresponds. The List
will be
- * sorted from best DataFlavor
to worst. That is, the first
- * DataFlavor
will best reflect data in the specified
- * native to a Java application. The returned List
is a
- * modifiable copy of this FlavorTable
's internal data.
- * Client code is free to modify the List
without affecting
- * this object.
+ * Returns a {@code List} of {@code DataFlavor}s to which the specified
+ * {@code String} corresponds. The {@code List} will be sorted from best
+ * {@code DataFlavor} to worst. That is, the first {@code DataFlavor} will
+ * best reflect data in the specified native to a Java application. The
+ * returned {@code List} is a modifiable copy of this {@code FlavorTable}'s
+ * internal data. Client code is free to modify the {@code List} without
+ * affecting this object.
*
- * @param nat the native whose corresponding DataFlavor
s
- * should be returned. If null
is specified, all
- * DataFlavor
s currently known to this
- * FlavorTable
are returned in a non-deterministic
- * order.
- * @return a java.util.List
of DataFlavor
- * objects into which platform-specific data in the specified,
- * platform-specific native can be translated
+ * @param nat the native whose corresponding {@code DataFlavor}s should be
+ * returned. If {@code null} is specified, all {@code DataFlavor}s
+ * currently known to this {@code FlavorTable} are returned in a
+ * non-deterministic order.
+ * @return a {@code java.util.List} of {@code DataFlavor} objects into which
+ * platform-specific data in the specified, platform-specific native
+ * can be translated
*/
ListMimeType
object.
+ * Constructor for externalization; this constructor should not be called
+ * directly by an application, since the result will be an uninitialized,
+ * immutable {@code MimeType} object.
*/
public MimeType() {
}
/**
- * Builds a MimeType
from a String
.
+ * Builds a {@code MimeType} from a {@code String}.
*
- * @param rawdata text used to initialize the MimeType
- * @throws NullPointerException if rawdata
is null
+ * @param rawdata text used to initialize the {@code MimeType}
+ * @throws NullPointerException if {@code rawdata} is {@code null}
*/
public MimeType(String rawdata) throws MimeTypeParseException {
parse(rawdata);
}
/**
- * Builds a MimeType
with the given primary and sub
- * type but has an empty parameter list.
+ * Builds a {@code MimeType} with the given primary and sub type but has an
+ * empty parameter list.
*
- * @param primary the primary type of this MimeType
- * @param sub the subtype of this MimeType
- * @throws NullPointerException if either primary
or
- * sub
is null
+ * @param primary the primary type of this {@code MimeType}
+ * @param sub the subtype of this {@code MimeType}
+ * @throws NullPointerException if either {@code primary} or {@code sub} is
+ * {@code null}
*/
public MimeType(String primary, String sub) throws MimeTypeParseException {
this(primary, sub, new MimeTypeParameterList());
}
/**
- * Builds a MimeType
with a pre-defined
- * and valid (or empty) parameter list.
+ * Builds a {@code MimeType} with a pre-defined and valid (or empty)
+ * parameter list.
*
- * @param primary the primary type of this MimeType
- * @param sub the subtype of this MimeType
- * @param mtpl the requested parameter list
- * @throws NullPointerException if either primary
,
- * sub
or mtpl
is null
+ * @param primary the primary type of this {@code MimeType}
+ * @param sub the subtype of this {@code MimeType}
+ * @param mtpl the requested parameter list
+ * @throws NullPointerException if either {@code primary}, {@code sub} or
+ * {@code mtpl} is {@code null}
*/
public MimeType(String primary, String sub, MimeTypeParameterList mtpl) throws
MimeTypeParseException {
@@ -121,13 +119,12 @@
} // hashCode()
/**
- * MimeType
s are equal if their primary types,
- * subtypes, and parameters are all equal. No default values
- * are taken into account.
- * @param thatObject the object to be evaluated as a
- * MimeType
- * @return true
if thatObject
is
- * a MimeType
; otherwise returns false
+ * {@code MimeType}s are equal if their primary types, subtypes, and
+ * parameters are all equal. No default values are taken into account.
+ *
+ * @param thatObject the object to be evaluated as a {@code MimeType}
+ * @return {@code true} if {@code thatObject} is a {@code MimeType};
+ * otherwise returns {@code false}
*/
public boolean equals(Object thatObject) {
if (!(thatObject instanceof MimeType)) {
@@ -144,7 +141,7 @@
/**
* A routine for parsing the MIME type out of a String.
*
- * @throws NullPointerException if rawdata
is null
+ * @throws NullPointerException if {@code rawdata} is {@code null}
*/
private void parse(String rawdata) throws MimeTypeParseException {
int slashIndex = rawdata.indexOf('/');
@@ -213,8 +210,8 @@
}
/**
- * Retrieve the value associated with the given name, or null if there
- * is no current association.
+ * Retrieve the value associated with the given name, or {@code null} if
+ * there is no current association.
*/
public String getParameter(String name) {
return parameters.get(name);
@@ -247,23 +244,21 @@
}
/**
- * Return a String representation of this object
- * without the parameter list.
+ * Return a String representation of this object without the parameter list.
*/
public String getBaseType() {
return primaryType + "/" + subType;
}
/**
- * Returns true
if the primary type and the
- * subtype of this object are the same as the specified
- * type
; otherwise returns false
.
- *
- * @param type the type to compare to this
's type
- * @return true
if the primary type and the
- * subtype of this object are the same as the
- * specified type
; otherwise returns
- * false
+ * Returns {@code true} if the primary type and the subtype of this object
+ * are the same as the specified {@code type}; otherwise returns
+ * {@code false}.
+ *
+ * @param type the type to compare to {@code this}'s type
+ * @return {@code true} if the primary type and the subtype of this object
+ * are the same as the specified {@code type}; otherwise returns
+ * {@code false}
*/
public boolean match(MimeType type) {
if (type == null)
@@ -275,17 +270,15 @@
}
/**
- * Returns true
if the primary type and the
- * subtype of this object are the same as the content type
- * described in rawdata
; otherwise returns
- * false
.
- *
- * @param rawdata the raw data to be examined
- * @return true
if the primary type and the
- * subtype of this object are the same as the content type
- * described in rawdata
; otherwise returns
- * false
; if rawdata
is
- * null
, returns false
+ * Returns {@code true} if the primary type and the subtype of this object
+ * are the same as the content type described in {@code rawdata}; otherwise
+ * returns {@code false}.
+ *
+ * @param rawdata the raw data to be examined
+ * @return {@code true} if the primary type and the subtype of this object
+ * are the same as the content type described in {@code rawdata};
+ * otherwise returns {@code false}; if {@code rawdata} is
+ * {@code null}, returns {@code false}
*/
public boolean match(String rawdata) throws MimeTypeParseException {
if (rawdata == null)
@@ -294,11 +287,11 @@
}
/**
- * The object implements the writeExternal method to save its contents
- * by calling the methods of DataOutput for its primitive values or
- * calling the writeObject method of ObjectOutput for objects, strings
- * and arrays.
- * @exception IOException Includes any I/O exceptions that may occur
+ * The object implements the writeExternal method to save its contents by
+ * calling the methods of DataOutput for its primitive values or calling the
+ * writeObject method of ObjectOutput for objects, strings and arrays.
+ *
+ * @throws IOException Includes any I/O exceptions that may occur
*/
public void writeExternal(ObjectOutput out) throws IOException {
String s = toString(); // contains ASCII chars only
@@ -314,13 +307,14 @@
}
/**
- * The object implements the readExternal method to restore its
- * contents by calling the methods of DataInput for primitive
- * types and readObject for objects, strings and arrays. The
- * readExternal method must read the values in the same sequence
- * and with the same types as were written by writeExternal.
- * @exception ClassNotFoundException If the class for an object being
- * restored cannot be found.
+ * The object implements the readExternal method to restore its contents by
+ * calling the methods of DataInput for primitive types and readObject for
+ * objects, strings and arrays. The readExternal method must read the values
+ * in the same sequence and with the same types as were written by
+ * writeExternal.
+ *
+ * @throws ClassNotFoundException If the class for an object being restored
+ * cannot be found
*/
public void readExternal(ObjectInput in) throws IOException,
ClassNotFoundException {
@@ -339,9 +333,9 @@
/**
* Returns a clone of this object.
+ *
* @return a clone of this object
*/
-
public Object clone() {
MimeType newObj = null;
try {
@@ -368,7 +362,7 @@
/**
* Determines whether or not a given string is a legal token.
*
- * @throws NullPointerException if s
is null
+ * @throws NullPointerException if {@code s} is {@code null}
*/
private boolean isValidToken(String s) {
int len = s.length();
@@ -388,7 +382,5 @@
/**
* A string that holds all the special chars.
*/
-
private static final String TSPECIALS = "()<>@,;:\\\"/[]?=";
-
} // class MimeType
--- old/src/java.datatransfer/share/classes/java/awt/datatransfer/MimeTypeParameterList.java 2017-05-23 19:14:17.000000000 -0700
+++ new/src/java.datatransfer/share/classes/java/awt/datatransfer/MimeTypeParameterList.java 2017-05-23 19:14:16.000000000 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -31,10 +31,9 @@
import java.util.Map;
import java.util.Set;
-
/**
- * An object that encapsulates the parameter list of a MimeType
- * as defined in RFC 2045 and 2046.
+ * An object that encapsulates the parameter list of a MimeType as defined in
+ * RFC 2045 and 2046.
*
* @author jeff.dunn@eng.sun.com
*/
@@ -71,9 +70,9 @@
} // hashCode()
/**
- * Two parameter lists are considered equal if they have exactly
- * the same set of parameter names and associated values. The
- * order of the parameters is not considered.
+ * Two parameter lists are considered equal if they have exactly the same
+ * set of parameter names and associated values. The order of the parameters
+ * is not considered.
*/
public boolean equals(Object thatObject) {
//System.out.println("MimeTypeParameterList.equals("+this+","+thatObject+")");
@@ -246,16 +245,16 @@
}
/**
- * Retrieve the value associated with the given name, or null if there
- * is no current association.
+ * Retrieve the value associated with the given name, or {@code null} if
+ * there is no current association.
*/
public String get(String name) {
return parameters.get(name.trim().toLowerCase());
}
/**
- * Set the value to be associated with the given name, replacing
- * any previous association.
+ * Set the value to be associated with the given name, replacing any
+ * previous association.
*/
public void set(String name, String value) {
parameters.put(name.trim().toLowerCase(), value);
@@ -294,18 +293,20 @@
}
/**
+ * Returns a clone of this object.
+ *
* @return a clone of this object
*/
@SuppressWarnings("unchecked") // Cast from clone
- public Object clone() {
- MimeTypeParameterList newObj = null;
- try {
- newObj = (MimeTypeParameterList)super.clone();
- } catch (CloneNotSupportedException cannotHappen) {
- }
- newObj.parameters = (HashtableTransferable
which implements the capability required
- * to transfer a String
.
- *
- * This Transferable
properly supports
- * DataFlavor.stringFlavor
- * and all equivalent flavors. Support for
- * DataFlavor.plainTextFlavor
- * and all equivalent flavors is deprecated. No other
- * DataFlavor
s are supported.
+ * A {@code Transferable} which implements the capability required to transfer a
+ * {@code String}.
+ * Transferable
capable of transferring
- * the specified String
.
- * @param data the string to be transferred
+ * Creates a {@code Transferable} capable of transferring the specified
+ * {@code String}.
+ *
+ * @param data the string to be transferred
*/
public StringSelection(String data) {
this.data = data;
}
/**
- * Returns an array of flavors in which this Transferable
- * can provide the data. DataFlavor.stringFlavor
- * is properly supported.
- * Support for DataFlavor.plainTextFlavor
is
- * deprecated.
+ * Returns an array of flavors in which this {@code Transferable} can
+ * provide the data. {@code DataFlavor.stringFlavor} is properly supported.
+ * Support for {@code DataFlavor.plainTextFlavor} is deprecated.
*
- * @return an array of length two, whose elements are DataFlavor.
- * stringFlavor
and DataFlavor.plainTextFlavor
+ * @return an array of length two, whose elements are
+ * {@code DataFlavor.stringFlavor} and
+ * {@code DataFlavor.plainTextFlavor}
*/
public DataFlavor[] getTransferDataFlavors() {
// returning flavors itself would allow client code to modify
@@ -82,14 +80,14 @@
/**
* Returns whether the requested flavor is supported by this
- * Transferable
.
+ * {@code Transferable}.
*
- * @param flavor the requested flavor for the data
- * @return true if flavor
is equal to
- * DataFlavor.stringFlavor
or
- * DataFlavor.plainTextFlavor
; false if flavor
- * is not one of the above flavors
- * @throws NullPointerException if flavor is null
+ * @param flavor the requested flavor for the data
+ * @return {@code true} if {@code flavor} is equal to
+ * {@code DataFlavor.stringFlavor} or
+ * {@code DataFlavor.plainTextFlavor}; {@code false} if
+ * {@code flavor} is not one of the above flavors
+ * @throws NullPointerException if {@code flavor} is {@code null}
*/
public boolean isDataFlavorSupported(DataFlavor flavor) {
// JCK Test StringSelection0003: if 'flavor' is null, throw NPE
@@ -102,27 +100,27 @@
}
/**
- * Returns the Transferable
's data in the requested
- * DataFlavor
if possible. If the desired flavor is
- * DataFlavor.stringFlavor
, or an equivalent flavor,
- * the String
representing the selection is
- * returned. If the desired flavor is
- * DataFlavor.plainTextFlavor
,
- * or an equivalent flavor, a Reader
is returned.
+ * Returns the {@code Transferable}'s data in the requested
+ * {@code DataFlavor} if possible. If the desired flavor is
+ * {@code DataFlavor.stringFlavor}, or an equivalent flavor, the
+ * {@code String} representing the selection is returned. If the desired
+ * flavor is {@code DataFlavor.plainTextFlavor}, or an equivalent flavor, a
+ * {@code Reader} is returned.
+ *
* Note: The behavior of this method for
- * DataFlavor.plainTextFlavor
- * and equivalent DataFlavor
s is inconsistent with the
- * definition of DataFlavor.plainTextFlavor
.
+ * {@code DataFlavor.plainTextFlavor}
+ * and equivalent {@code DataFlavor}s is inconsistent with the definition of
+ * {@code DataFlavor.plainTextFlavor}.
*
- * @param flavor the requested flavor for the data
+ * @param flavor the requested flavor for the data
* @return the data in the requested flavor, as outlined above
- * @throws UnsupportedFlavorException if the requested data flavor is
- * not equivalent to either DataFlavor.stringFlavor
- * or DataFlavor.plainTextFlavor
+ * @throws UnsupportedFlavorException if the requested data flavor is not
+ * equivalent to either {@code DataFlavor.stringFlavor} or
+ * {@code DataFlavor.plainTextFlavor}
* @throws IOException if an IOException occurs while retrieving the data.
* By default, StringSelection never throws this exception, but a
* subclass may.
- * @throws NullPointerException if flavor is null
+ * @throws NullPointerException if {@code flavor} is {@code null}
* @see java.io.Reader
*/
public Object getTransferData(DataFlavor flavor)
--- old/src/java.datatransfer/share/classes/java/awt/datatransfer/SystemFlavorMap.java 2017-05-23 19:14:19.000000000 -0700
+++ new/src/java.datatransfer/share/classes/java/awt/datatransfer/SystemFlavorMap.java 2017-05-23 19:14:19.000000000 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,9 +25,6 @@
package java.awt.datatransfer;
-import sun.datatransfer.DataFlavorUtil;
-import sun.datatransfer.DesktopDatatransferService;
-
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
@@ -45,11 +42,14 @@
import java.util.Objects;
import java.util.Set;
+import sun.datatransfer.DataFlavorUtil;
+import sun.datatransfer.DesktopDatatransferService;
+
/**
* The SystemFlavorMap is a configurable map between "natives" (Strings), which
* correspond to platform-specific data formats, and "flavors" (DataFlavors),
- * which correspond to platform-independent MIME types. This mapping is used
- * by the data transfer subsystem to transfer data between Java and native
+ * which correspond to platform-independent MIME types. This mapping is used by
+ * the data transfer subsystem to transfer data between Java and native
* applications, and between Java applications in separate VMs.
*
* @since 1.2
@@ -57,8 +57,7 @@
public final class SystemFlavorMap implements FlavorMap, FlavorTable {
/**
- * Constant prefix used to tag Java types converted to native platform
- * type.
+ * Constant prefix used to tag Java types converted to native platform type.
*/
private static String JavaMIME = "JAVA_DATAFLAVOR:";
@@ -93,14 +92,15 @@
/**
* Maps native Strings to Lists of DataFlavors (or base type Strings for
* text DataFlavors).
- * Do not use the field directly, use getNativeToFlavor() instead.
+ *