Bali Share 1.1.18

oracle.bali.share.datatransfer
Class CompoundTransferable

java.lang.Object
  |
  +--oracle.bali.share.datatransfer.CompoundTransferable
All Implemented Interfaces:
java.awt.datatransfer.Transferable

public class CompoundTransferable
extends java.lang.Object
implements java.awt.datatransfer.Transferable

CompoundTransferables make it simpler to provide Transferables that support multiple data types. They do not provide support for Transferables containing multiple objects, a subtle but important distinction. In general, all the Transferables should simply be different representations of the same underlying data.

Clients should always order the sub-transferables so that the highest-fidelity format is first. For example, a styled text format should be placed before a plain text format. Conversely, clients that read data from Transferables (any Transferables, not just this class), should always request their preferred data flavor first if they have a preference. If there is no clear preferred transferable, pick the first DataFlavor you support returned by getTransferDataFlavors.

See Also:
ObjectTransferable

Constructor Summary
CompoundTransferable(java.awt.datatransfer.Transferable[] transferables)
          Creates a CompoundTransferable, joining all the provided transferables into a single transferable.
CompoundTransferable(java.awt.datatransfer.Transferable a, java.awt.datatransfer.Transferable b)
          Creates a CompoundTransferable out of two separate Transferables.
 
Method Summary
 java.lang.Object getTransferData(java.awt.datatransfer.DataFlavor flavor)
          Returns an object which represents the data to be transferred.
 java.awt.datatransfer.DataFlavor[] getTransferDataFlavors()
          Returns an array of DataFlavor objects indicating the flavors the data can be provided in.
 boolean isDataFlavorSupported(java.awt.datatransfer.DataFlavor flavor)
          Returns whether or not the specified data flavor is supported for this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CompoundTransferable

public CompoundTransferable(java.awt.datatransfer.Transferable a,
                            java.awt.datatransfer.Transferable b)
Creates a CompoundTransferable out of two separate Transferables.
Parameters:
a - the first transferable
b - the second transferable

CompoundTransferable

public CompoundTransferable(java.awt.datatransfer.Transferable[] transferables)
Creates a CompoundTransferable, joining all the provided transferables into a single transferable.
Parameters:
transferables - an array of Transferable implementations
Method Detail

getTransferDataFlavors

public java.awt.datatransfer.DataFlavor[] getTransferDataFlavors()
Returns an array of DataFlavor objects indicating the flavors the data can be provided in. The array, a concatenation of all the data flavors supported by all the sub-transferables, will be ordered first by the order in which the Transferables were passed to the constructor.

Specified by:
getTransferDataFlavors in interface java.awt.datatransfer.Transferable
Returns:
an array of data flavors in which this data can be transferred

isDataFlavorSupported

public boolean isDataFlavorSupported(java.awt.datatransfer.DataFlavor flavor)
Returns whether or not the specified data flavor is supported for this object. Will return true if the requested data flavor is supported by any of the sub-transferables.
Specified by:
isDataFlavorSupported in interface java.awt.datatransfer.Transferable
Parameters:
flavor - the requested flavor for the data
Returns:
boolean indicating whether or not the data flavor is supported

getTransferData

public final java.lang.Object getTransferData(java.awt.datatransfer.DataFlavor flavor)
                                       throws java.awt.datatransfer.UnsupportedFlavorException,
                                              java.io.IOException
Returns an object which represents the data to be transferred. The data will be retrieved from the first sub-transferable that claims to support the DataFlavor.

Specified by:
getTransferData in interface java.awt.datatransfer.Transferable
Parameters:
flavor - the requested flavor for the data
Throws:
java.io.IOException - if the data is no longer available in the requested flavor.
java.awt.datatransfer.UnsupportedFlavorException - if the requested data flavor is not supported.

Bali Share 1.1.18