Preferences Editor

de.jppietsch.prefedit
Class AbstractTransferable

java.lang.Object
  extended byde.jppietsch.prefedit.AbstractTransferable
All Implemented Interfaces:
Transferable
Direct Known Subclasses:
Preference, Subtree

public abstract class AbstractTransferable
extends Object
implements Transferable

A convenient base class for simple transferables which support only two data flavors for strings and objects local to a virtual machine.

Version:
$Revision: 1.2 $
Author:
Jan-Peter Pietsch

Constructor Summary
AbstractTransferable()
           
 
Method Summary
 void copy()
          Puts this transferable to the system clipboard.
 void cut()
          May be overwritten to remove this from somewhere.
protected abstract  void doPaste(Preferences somePreferences)
          Adds this transferable to the given preferences.
protected  DataFlavor flavor()
          Creates a special data flavor for this object.
 Object getTransferData(DataFlavor aFlavor)
          Returns this object or a string representation of it.
 DataFlavor[] getTransferDataFlavors()
          Returns an array of data flavors for this transferable.
protected abstract  String humanPresentableClassName()
          Returns a human presentable name for this class.
 boolean isDataFlavorSupported(DataFlavor aFlavor)
          Does this transferable support a given data flavor?
static void paste(Preferences somePreferences)
          Takes an instance of this class from the system clipboard.
private static Clipboard systemClipboard()
          Convenience method to return the system clipboard.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractTransferable

public AbstractTransferable()
Method Detail

getTransferDataFlavors

public DataFlavor[] getTransferDataFlavors()
Returns an array of data flavors for this transferable.

Specified by:
getTransferDataFlavors in interface Transferable
Returns:
Some flavors.

isDataFlavorSupported

public boolean isDataFlavorSupported(DataFlavor aFlavor)
Does this transferable support a given data flavor?

Specified by:
isDataFlavorSupported in interface Transferable
Parameters:
aFlavor - which is requested.
Returns:
This transferable supports aFlavor.

getTransferData

public Object getTransferData(DataFlavor aFlavor)
                       throws UnsupportedFlavorException
Returns this object or a string representation of it.

Specified by:
getTransferData in interface Transferable
Parameters:
aFlavor - how the result should taste.
Returns:
This object or a string representation of it.
Throws:
UnsupportedFlavorException

copy

public void copy()
Puts this transferable to the system clipboard.


cut

public void cut()
May be overwritten to remove this from somewhere. This implementation just calls copy().


paste

public static void paste(Preferences somePreferences)
                  throws UnsupportedFlavorException,
                         IOException
Takes an instance of this class from the system clipboard.

Parameters:
somePreferences - is given to doPaste(Preferences).
Throws:
UnsupportedFlavorException - If the clipboard contains something else but not an AbstractTransferable.
IOException

flavor

protected DataFlavor flavor()
Creates a special data flavor for this object.

Returns:
Data flavor for this object which depends on its concrete class.

humanPresentableClassName

protected abstract String humanPresentableClassName()
Returns a human presentable name for this class. This is needed for the implementation of flavor().

Returns:
A human presentable name for the concrete class.

doPaste

protected abstract void doPaste(Preferences somePreferences)
Adds this transferable to the given preferences.

Parameters:
somePreferences - to which this is added.

systemClipboard

private static Clipboard systemClipboard()
Convenience method to return the system clipboard.

Returns:
The system clipboard from the default toolkit.

Preferences Editor