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

java.lang.Object
  extended by com.guiseframework.component.transfer.AbstractObjectTransferable<S>
Type Parameters:
S - The source of the transfer.
All Implemented Interfaces:
Transferable<S>
Direct Known Subclasses:
TreeControl.TreeNodeTransferable

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

A abstract transferable that carries one or more Java objects. A subclass must implement Transferable.transfer(Class).

Author:
Garret Wilson

Constructor Summary
AbstractObjectTransferable(S source, java.lang.Class<?>... objectClasses)
          Source and object esclass constructor.
 
Method Summary
 boolean canTransfer(com.globalmentor.net.ContentType contentType)
          Determines whether this transferable can transfer data with the given content type.
protected  java.lang.Class<?> getClass(com.globalmentor.net.ContentType contentType)
          Determines the class this content type matches.
 com.globalmentor.net.ContentType[] getContentTypes()
          Determines the content types available for this transfer.
 S getSource()
           
 java.lang.Object transfer(com.globalmentor.net.ContentType contentType)
          Transfers data using the given content type.
 
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
transfer
 

Constructor Detail

AbstractObjectTransferable

public AbstractObjectTransferable(S source,
                                  java.lang.Class<?>... objectClasses)
Source and object esclass constructor.

Parameters:
source - The source of the transferable data.
objectClasses - The classes indicating the typees of object to be transferred.
Throws:
java.lang.NullPointerException - if the provided source and/or object classes is null.
Method Detail

getSource

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

getClass

protected java.lang.Class<?> getClass(com.globalmentor.net.ContentType contentType)
Determines the class this content type matches. This method matches a content type against the primary type and subtype, with a "class" parameter indicating the given object class.

Parameters:
contentType - The type of data requested, which may include wildcards.
Returns:
The matching class, or null if no supported class matches the requested content type.

canTransfer

public boolean canTransfer(com.globalmentor.net.ContentType contentType)
Determines whether this transferable can transfer data with the given content type. This implementation matches a content type against the primary type and subtype, with a "class" parameter indicating the given object class.

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 java.lang.Object transfer(com.globalmentor.net.ContentType contentType)
Transfers data using the given content type. This implementation delegates to Transferable.transfer(Class).

Specified by:
transfer in interface Transferable<S>
Parameters:
contentType - The type of data expected.
Returns:
The transferred data, which may be null.
Throws:
java.lang.IllegalArgumentException - if the given content type is not supported.

getContentTypes

public com.globalmentor.net.ContentType[] getContentTypes()
Determines the content types available for this transfer. This implementation returns content types in the form application/x-java-object;class=package.Class.

Specified by:
getContentTypes in interface Transferable<S>
Returns:
The content types available for this transfer.


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