EVALUATION
What the submitter is really asking for the Clipboard to generate data on
demand, and in the desired DataFlavor, much like the DnD subsystem works. This
is a much needed addition to the API. Committing to merlin for now.
david.mendenhall@eng 1999-12-14
In merlin, we didn't have time to implement delayed data fetch, although we did
at least implement delayed rendering. Committing to tiger.
david.mendenhall@east 2000-12-14
Name: agR10216 Date: 06/27/2003
The following CCC request was approved.
4287795: Would like Clipboard.isDataFlavorSupported() method
Release: Tiger
Type: enhancement
Problem
The related problems are described in the RFE
4287795 [Would like Clipboard.isDataFlavorSupported() method]
and in the bug
4790833 [Memory usage shoots way up using Clipboard.getContents()].
The only way to know something about contents of a clipboard
using the present API is to call
java.awt.datatransfer.Clipboard.getContents() and examine
the Transferable returned. For system clipboard
getContents() retrieves whole contents of the clipboard, it
retrieves data in each supported format, so that
Transferable returned is independent of current contents of
the system clipboard later on. Thus, if one wants only to
check whether data in a particular DataFlavor is available
on the clipboard or to get data in a single DataFlavor,
using getContents() is inefficient: it unnecessarily
consumes a lot of memory and slackens performance.
Solution
Add 3 methods to the class java.awt.datatransfer.Clipboard,
which allow to get DataFlavors currently available on the
clipboard, check whether a particular DataFlavor is
available, and get data in a particular DataFlavor.
Interface summary
exported external method java.awt.datatransfer.Clipboard.getAvailableDataFlavors
isDataFlavorAvailable
getData
Specification
java.awt.datatransfer.Clipboard:
/**
* Returns an array of <code>DataFlavor</code>s in which the current
* contents of this clipboard can be provided. If there are no
* <code>DataFlavor</code>s available, this method returns a zero-length
* array.
*
* @return an array of <code>DataFlavor</code>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()
/**
* Returns whether or not the current contents of this clipboard can be
* provided in the specified <code>DataFlavor</code>.
*
* @param flavor the requested <code>DataFlavor</code> for the contents
*
* @return <code>true</code> if the current contents of this clipboard
* can be provided in the specified <code>DataFlavor</code>;
* <code>false</code> otherwise
*
* @throws NullPointerException if <code>flavor</code> is <code>null</code>
* @throws IllegalStateException if this clipboard is currently unavailable
*
* @since 1.5
*/
public boolean isDataFlavorAvailable(DataFlavor flavor)
/**
* Returns an object representing the current contents of this clipboard
* in the specified <code>DataFlavor</code>.
* The class of the object returned is defined by the representation
* class of <code>flavor</code>.
*
* @param flavor the requested <code>DataFlavor</code> for the contents
*
* @return an object representing the current contents of this clipboard
* in the specified <code>DataFlavor</code>
*
* @throws NullPointerException if <code>flavor</code> is <code>null</code>
* @throws IllegalStateException if this clipboard is currently unavailable
* @throws UnsupportedFlavorException if the requested <code>DataFlavor</code>
* is not available
* @throws IOException if the data in the requested <code>DataFlavor</code>
* can not be retrieved
*
* @see DataFlavor#getRepresentationClass
*
* @since 1.5
*/
public Object getData(DataFlavor flavor)
throws UnsupportedFlavorException, IOException
Compatibility risk: minimal
###@###.### 2003-06-27
======================================================================
|