de.fhg.igd.semoa.ui
Class HostSelection

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

public class HostSelection
extends Object
implements Transferable

A Transferable which implements the capability required to transfer a host address. This Transferable supports:

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

Field Summary
private  Name dn_
          the distinguished name to transfer
static DataFlavor DN_FLAVOR
          The DataFlavor representing a distinguished name using a Name class.
private  URL url_
          the URL to transfer
 
Constructor Summary
HostSelection(URL url, Name dn)
          Creates a Transferable capable of transferring a host with the specified url and the specified distinguished name dn.
 
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

DN_FLAVOR

public static final DataFlavor DN_FLAVOR
The DataFlavor representing a distinguished name using a Name class.


dn_

private Name dn_
the distinguished name to transfer


url_

private URL url_
the URL to transfer

Constructor Detail

HostSelection

public HostSelection(URL url,
                     Name dn)
Creates a Transferable capable of transferring a host with the specified url and the specified distinguished name dn. Either url or dn may be specified as null but not both arguments.

Parameters:
url - the URL to transfer
dn - the distinguished name to transfer
Throws:
IllegalArgumentException - if both url and dn are equal to null
Method Detail

getTransferDataFlavors

public DataFlavor[] getTransferDataFlavors()
Returns an array of flavors in which this Transferable can provide the data. DataFlavor.stringFlavor and DropZone.DROPZONE_FLAVOR are supported by all HostSelection objects. Those constructed with a non null url also support URLSelection.URL_FLAVOR and those constructed with a non null distinguished name also support DN_FLAVOR.

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

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 supported by this Transferable

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 DN_FLAVOR a String representation of the hosts distinguished name is returned. If the desired flavor is URLSelection.URL_FLAVOR a URL object representing the host address is returned. If the desired flavor is DataFlavor.stringFlavor and this HostSelection has been constructed with a non null url, the String representing the host URL is returned. If the desired flavor is DataFlavor.stringFlavor and this HostSelection has been constructed with a null url and a non null dn, the String representing the host distinguished name is returned. If the desired flavor is DropZone.DROPZONE_FLAVOR and this HostSelection has been constructed with a non null url an InputStream is returned, that should be used in conjunction with an ObjectInputStream to read an URL object. If the desired flavor is DropZone.DROPZONE_FLAVOR and this HostSelection has been constructed with a null url and a non null distinguished name an InputStream is returned, that should be used in conjunction with an ObjectInputStream to read a String 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 supported by this HostSelection
IOException - if an IOException occurs while retrieving the data
NullPointerException - if flavor is null


Copyright © Fraunhofer Gesellschaft. All Rights Reserved.