de.fhg.igd.semoa.ui
Class URLSelection

java.lang.Object
  extended byde.fhg.igd.semoa.ui.URLSelection
All Implemented Interfaces:
Transferable

public class URLSelection
extends Object
implements Transferable

A Transferable which implements the capability required to transfer an URL. This Transferable supports:

Version:
$Id: URLSelection.java 1913 2007-08-08 02:41:53Z jpeters $
Author:
Dennis Bartussek
See Also:
DataFlavor.stringFlavor, DropZone.DROPZONE_FLAVOR, URL_FLAVOR

Field Summary
private  URL url_
          the URL to transfer
static DataFlavor URL_FLAVOR
          The DataFlavor representing a de.fhg.igd.util.URL class.
 
Constructor Summary
URLSelection(URL url)
          Creates a Transferable capable of transferring the specified URL.
 
Method Summary
 Object getTransferData(DataFlavor flavor)
          Returns the Transferable's data in the requested DataFlavor if possible.
 DataFlavor[] getTransferDataFlavors()
          Returns an array of flavors in which this Transferable can provide the data.
 boolean isDataFlavorSupported(DataFlavor flavor)
          Returns whether the requested flavor is supported by this Transferable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

URL_FLAVOR

public static final DataFlavor URL_FLAVOR
The DataFlavor representing a de.fhg.igd.util.URL class.


url_

private URL url_
the URL to transfer

Constructor Detail

URLSelection

public URLSelection(URL url)
Creates a Transferable capable of transferring the specified URL.

Parameters:
url - the URL to transfer
Throws:
NullPointerException - if the specified URL is null
Method Detail

getTransferDataFlavors

public DataFlavor[] getTransferDataFlavors()
Returns an array of flavors in which this Transferable can provide the data. URL_FLAVOR, DataFlavor.stringFlavor and DropZone.DROPZONE_FLAVOR are supported.

Specified by:
getTransferDataFlavors in interface Transferable
Returns:
an array of length three, whose elements are URL_FLAVOR, DataFlavor.stringFlavor and DropZone.DROPZONE_FLAVOR

isDataFlavorSupported

public boolean isDataFlavorSupported(DataFlavor flavor)
Returns whether the requested flavor is supported by this Transferable.

Specified by:
isDataFlavorSupported in interface Transferable
Parameters:
flavor - the requested flavor for the data
Returns:
true if flavor is equal to URL_FLAVOR, DataFlavor.stringFlavor or DropZone.DROPZONE_FLAVOR; false if flavor is not one of the above flavors

getTransferData

public Object getTransferData(DataFlavor flavor)
                       throws UnsupportedFlavorException,
                              IOException
Returns the Transferable's data in the requested DataFlavor if possible. If the desired flavor is URL_FLAVOR, an URL object is returned. If the desired flavor is DataFlavor.stringFlavor, the String representing the URL selection is returned. If the desired flavor is DropZone.DROPZONE_FLAVOR an InputStream is returned, that should be used in conjunction with an ObjectInputStream to read an URL object.

Specified by:
getTransferData in interface Transferable
Parameters:
flavor - the requested flavor for the data
Returns:
the data in the requested flavor, as outlined above
Throws:
UnsupportedFlavorException - if the requested data flavor is not equal to URL_FLAVOR, DataFlavor.stringFlavor or DropZone.DROPZONE_FLAVOR.
IOException - if an IOException occurs while retrieving the data
NullPointerException - if flavor is null


Copyright © Fraunhofer Gesellschaft. All Rights Reserved.