uk.ac.starlink.datanode.tree
Class BasicTransferable

java.lang.Object
  extended by uk.ac.starlink.datanode.tree.BasicTransferable
All Implemented Interfaces:
Transferable
Direct Known Subclasses:
DataNodeTransferable

public class BasicTransferable
extends Object
implements Transferable

A basic implementation of the Transferable interface used to implement drag'n'drop operations. It initially supports no DataFlavors, but they can be added by using the various add* methods provided. They should be called in order of priority (most specific first).

Author:
Mark Taylor (Starlink)

Constructor Summary
BasicTransferable()
           
 
Method Summary
 void addDataSource(DataSource datsrc, String mimeType)
          Adds streamed data.
 void addLocalObject(Object obj, Class clazz, String type)
          Adds an object which can be transferred within a single JVM.
 void addSerializableObject(Serializable obj, Class clazz, String type)
          Adds a Serializable object which can be serialized and thus passed outside of this JVM.
 void addString(String text)
          Adds a plain text string.
 void addURL(URL url)
          Adds a URL.
 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
 

Constructor Detail

BasicTransferable

public BasicTransferable()
Method Detail

addLocalObject

public void addLocalObject(Object obj,
                           Class clazz,
                           String type)
Adds an object which can be transferred within a single JVM.

Parameters:
obj - the object
clazz - the class as which it should be declared in the MIME type
type - a human-readable description of the type

addSerializableObject

public void addSerializableObject(Serializable obj,
                                  Class clazz,
                                  String type)
Adds a Serializable object which can be serialized and thus passed outside of this JVM.

Parameters:
obj - the serializable object
clazz - the class as which it should be declared in the MIME type
type - a human-readable description of the type

addURL

public void addURL(URL url)
Adds a URL. This is currently installed as both a local and a serializable object.

Parameters:
url - the URL

addString

public void addString(String text)
Adds a plain text string.

Parameters:
text - the string

addDataSource

public void addDataSource(DataSource datsrc,
                          String mimeType)
Adds streamed data.

Parameters:
datsrc - the DataSource holding the data
mimeType - the MIME type with which the data should declare itself

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 IOException,
                              UnsupportedFlavorException
Specified by:
getTransferData in interface Transferable
Throws:
IOException
UnsupportedFlavorException


Copyright © 2015 Central Laboratory of the Research Councils. All Rights Reserved.