United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-4287795 Would like Clipboard.isDataFlavorSupported() method
JDK-4287795 : Would like Clipboard.isDataFlavorSupported() method

Details
Type:
Enhancement
Submit Date:
1999-11-04
Status:
Resolved
Updated Date:
2003-07-25
Project Name:
JDK
Resolved Date:
2003-07-25
Component:
client-libs
OS:
generic
Sub-Component:
java.awt
CPU:
generic
Priority:
P4
Resolution:
Fixed
Affected Versions:
1.2.2
Fixed Versions:
5.0 (tiger)

Related Reports
Relates:
Relates:
Relates:

Sub Tasks

Description

Name: krT82822			Date: 11/03/99


java version "1.2.2"
HotSpot VM (1.0.1, mixed mode, build c)
Currently, to see if the Paste menu item in a Java application should be
enabled, you must do Clipboard.getContents(), and if it doesn't return null,
see if the returned Transferable has a compatible datatype by calling
Transferable.isDataFlavorSupported(). However, getContents() can take a while
if the clipboard contents is large (e.g. many pages of text).

It isn't actually necessary to retrieve the contents of the clipboard to enable
the menu item, only to see if the clipboard contains appropriate data. A method
Clipboard.isDataFlavorSupported() would be very helpful if it were faster than
Clipboard.getContents().
(Review ID: 97424) 
======================================================================

                                    

Comments
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
======================================================================
                                     
2003-06-27
SUGGESTED FIX



Name: agR10216			Date: 06/27/2003


Implement the new methods described in the evaluation
for private and system clipboards.

###@###.###  2003-06-27
======================================================================
                                     
2003-06-27
CONVERTED DATA

BugTraq+ Release Management Values

COMMIT TO FIX:
tiger

FIXED IN:
tiger

INTEGRATED IN:
tiger
tiger-b13


                                     
2004-08-24



Hardware and Software, Engineered to Work Together