com.guiseframework.component.transfer
Class AbstractTransferable<S>

java.lang.Object
  extended by com.guiseframework.component.transfer.AbstractTransferable<S>
Type Parameters:
S - The source of the transfer.
All Implemented Interfaces:
Transferable<S>
Direct Known Subclasses:
AbstractImageComponent.DefaultTransferable, AbstractLabel.DefaultTransferable, TextControl.DefaultTransferable

public abstract class AbstractTransferable<S>
extends java.lang.Object
implements Transferable<S>

An abstract object that can be transferred, such as between components using drag and drop.

Author:
Garret Wilson

Constructor Summary
AbstractTransferable(S source)
          Source constructor.
 
Method Summary
 boolean canTransfer(com.globalmentor.net.ContentType contentType)
          Determines whether this transferable can transfer data with the given content type.
 S getSource()
           
<T> T
transfer(java.lang.Class<T> objectClass)
          Transfers data of the given class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.guiseframework.component.transfer.Transferable
getContentTypes, transfer
 

Constructor Detail

AbstractTransferable

public AbstractTransferable(S source)
Source constructor.

Parameters:
source - The source of the transferable data.
Throws:
java.lang.NullPointerException - if the provided source is null.
Method Detail

getSource

public S getSource()
Specified by:
getSource in interface Transferable<S>
Returns:
The source of the transferable data.

canTransfer

public boolean canTransfer(com.globalmentor.net.ContentType contentType)
Determines whether this transferable can transfer data with the given content type. This implementation calls Transferable.getContentTypes().

Specified by:
canTransfer in interface Transferable<S>
Parameters:
contentType - The type of data requested, which may include wildcards.
Returns:
true if this object can transfer data with the requested content type.

transfer

public <T> T transfer(java.lang.Class<T> objectClass)
Transfers data of the given class. This implementation delegates to Transferable.transfer(ContentType).

Specified by:
transfer in interface Transferable<S>
Type Parameters:
T - The type of object to be transferred.
Parameters:
objectClass - The class of object to return.
Returns:
The transferred data object, which may be null.
Throws:
java.lang.IllegalArgumentException - if the given class is not supported.


Copyright © 2005-2010 GlobalMentor, Inc. All Rights Reserved.