Class AbstractObjectTransferable<S>
- java.lang.Object
-
- io.guise.framework.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 implementTransferable.transfer(Class)
.- Author:
- Garret Wilson
-
-
Constructor Summary
Constructors Constructor Description AbstractObjectTransferable(S source, java.lang.Class<?>... objectClasses)
Source and object esclass constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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()
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 io.guise.framework.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 isnull
.
-
-
Method Detail
-
getSource
public S getSource()
- Specified by:
getSource
in interfaceTransferable<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 "application" primary type and "x-java-object" 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 "application" primary type and "x-java-object" subtype, with a "class" parameter indicating the given object class.
- Specified by:
canTransfer
in interfaceTransferable<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 interfaceTransferable<S>
- Parameters:
contentType
- The type of data expected.- Returns:
- The transferred data, which may be
null
.
-
getContentTypes
public com.globalmentor.net.ContentType[] getContentTypes()
This implementation returns content types in the form
application/x-java-object;class=package.Class
.- Specified by:
getContentTypes
in interfaceTransferable<S>
- Returns:
- The content types available for this transfer.
-
-