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
A abstract transferable that carries one or more Java objects. A subclass must implement
Transferable.transfer(Class)
.- Author:
- Garret Wilson
-
Constructor Summary
ConstructorDescriptionAbstractObjectTransferable
(S source, Class<?>... objectClasses) Source and object esclass constructor. -
Method Summary
Modifier and TypeMethodDescriptionboolean
canTransfer
(com.globalmentor.net.MediaType contentType) Determines whether this transferable can transfer data with the given content type.protected Class<?>
getClass
(com.globalmentor.net.MediaType contentType) Determines the class this content type matches.com.globalmentor.net.MediaType[]
transfer
(com.globalmentor.net.MediaType 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 Details
-
AbstractObjectTransferable
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:
NullPointerException
- if the provided source and/or object classes isnull
.
-
-
Method Details
-
getSource
- Specified by:
getSource
in interfaceTransferable<S>
- Returns:
- The source of the transferable data.
-
getClass
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.MediaType 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
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.MediaType[] 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.
-