dsto.dfc.swing.dnd
Class ObjectTransferable

java.lang.Object
  extended by dsto.dfc.swing.dnd.ObjectTransferable
All Implemented Interfaces:
Disposable, Transferable

public class ObjectTransferable
extends Object
implements Transferable, Disposable

Allows any object or array of objects to be stored as a Transferable. Automatically supports highest-fidelity transfer by choosing best supported flavors.

Version:
$Revision$

Field Summary
static DataFlavor RAW_SERIALIZED_OBJECT_FLAVOR
           
 
Constructor Summary
ObjectTransferable(Object[] values, String humanName)
          Create a transferable containing a list of values.
ObjectTransferable(Object value, String humanName)
          Creates a transferable with a single value.
 
Method Summary
 void dispose()
          Disposes all disposable values.
protected static Class findCommonClass(Object[] values)
          Find the most specific class common to a set of values.
 Object getTransferData(DataFlavor flavor)
           
 DataFlavor[] getTransferDataFlavors()
           
 boolean isDataFlavorSupported(DataFlavor flavor)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RAW_SERIALIZED_OBJECT_FLAVOR

public static final DataFlavor RAW_SERIALIZED_OBJECT_FLAVOR
Constructor Detail

ObjectTransferable

public ObjectTransferable(Object value,
                          String humanName)
Creates a transferable with a single value. Note that the representation class will be value.getClass (). To use a different representation class (eg an interface of value), use the array version of this constructor instead and ensure the array's component class type is the desired interface type.


ObjectTransferable

public ObjectTransferable(Object[] values,
                          String humanName)
Create a transferable containing a list of values. The representation class of the supported flavors will be array.getComponentType ().

Method Detail

dispose

public void dispose()
Disposes all disposable values.

Specified by:
dispose in interface Disposable

findCommonClass

protected static Class findCommonClass(Object[] values)
Find the most specific class common to a set of values. Only accepts non-null values.


getTransferDataFlavors

public DataFlavor[] getTransferDataFlavors()
Specified by:
getTransferDataFlavors in interface Transferable

isDataFlavorSupported

public boolean isDataFlavorSupported(DataFlavor flavor)
Specified by:
isDataFlavorSupported in interface Transferable

getTransferData

public Object getTransferData(DataFlavor flavor)
                       throws UnsupportedFlavorException,
                              IOException
Specified by:
getTransferData in interface Transferable
Throws:
UnsupportedFlavorException
IOException


Copyright © 2008 Commonwealth of Australia