public static class FileDrop.TransferableObject extends java.lang.Object implements java.awt.datatransfer.Transferable
Modifier and Type | Class and Description |
---|---|
static interface |
FileDrop.TransferableObject.Fetcher
Instead of passing your data directly to the
FileDrop.TransferableObject constructor, you
may want to know exactly when your data was received
in case you need to remove it from its source (or do anyting else to it). |
Modifier and Type | Field and Description |
---|---|
static java.awt.datatransfer.DataFlavor |
DATA_FLAVOR
The default
DataFlavor for FileDrop.TransferableObject has
the representation class net.iharder.TransferableObject.class and the MIME
type application/x-net.iharder.TransferableObject. |
static java.lang.String |
MIME_TYPE
The MIME type for
DATA_FLAVOR is
application/x-net.iharder.TransferableObject. |
Constructor and Description |
---|
FileDrop.TransferableObject(java.lang.Class dataClass,
FileDrop.TransferableObject.Fetcher fetcher)
Creates a new
FileDrop.TransferableObject that will return the
object that is returned by fetcher. |
FileDrop.TransferableObject(FileDrop.TransferableObject.Fetcher fetcher)
Creates a new
FileDrop.TransferableObject that will return the
object that is returned by fetcher. |
FileDrop.TransferableObject(java.lang.Object data)
Creates a new
FileDrop.TransferableObject that wraps data. |
Modifier and Type | Method and Description |
---|---|
java.awt.datatransfer.DataFlavor |
getCustomDataFlavor()
Returns the custom
DataFlavor associated
with the encapsulated object or null if the FileDrop.TransferableObject.Fetcher constructor was used
without passing a Class . |
java.lang.Object |
getTransferData(java.awt.datatransfer.DataFlavor flavor)
Returns the data encapsulated in this
FileDrop.TransferableObject . |
java.awt.datatransfer.DataFlavor[] |
getTransferDataFlavors()
Returns a two- or three-element array containing first
the custom data flavor, if one was created in the constructors,
second the default
DATA_FLAVOR associated with FileDrop.TransferableObject , and
third the DataFlavor.stringFlavor . |
boolean |
isDataFlavorSupported(java.awt.datatransfer.DataFlavor flavor)
Returns true if flavor is one of the supported
flavors.
|
public static final java.lang.String MIME_TYPE
DATA_FLAVOR
is
application/x-net.iharder.TransferableObject.public static final java.awt.datatransfer.DataFlavor DATA_FLAVOR
DataFlavor
for FileDrop.TransferableObject
has
the representation class net.iharder.TransferableObject.class and the MIME
type application/x-net.iharder.TransferableObject.public FileDrop.TransferableObject(java.lang.Object data)
FileDrop.TransferableObject
that wraps data.
Along with the DATA_FLAVOR
associated with this class,
this creates a custom data flavor with a representation class
determined from data.getClass()
and the MIME type
application/x-net.iharder.TransferableObject.data
- The data to transferpublic FileDrop.TransferableObject(FileDrop.TransferableObject.Fetcher fetcher)
FileDrop.TransferableObject
that will return the
object that is returned by fetcher.
No custom data flavor is set other than the default DATA_FLAVOR
.fetcher
- The FileDrop.TransferableObject.Fetcher
that will return the data objectFileDrop.TransferableObject.Fetcher
public FileDrop.TransferableObject(java.lang.Class dataClass, FileDrop.TransferableObject.Fetcher fetcher)
FileDrop.TransferableObject
that will return the
object that is returned by fetcher.
Along with the DATA_FLAVOR
associated with this class,
this creates a custom data flavor with a representation class dataClass
and the MIME type application/x-net.iharder.TransferableObject.dataClass
- The Class
to use in the custom data flavorfetcher
- The FileDrop.TransferableObject.Fetcher
that will return the data objectFileDrop.TransferableObject.Fetcher
public java.awt.datatransfer.DataFlavor getCustomDataFlavor()
DataFlavor
associated
with the encapsulated object or null if the FileDrop.TransferableObject.Fetcher
constructor was used
without passing a Class
.public java.awt.datatransfer.DataFlavor[] getTransferDataFlavors()
DATA_FLAVOR
associated with FileDrop.TransferableObject
, and
third the DataFlavor.stringFlavor
.getTransferDataFlavors
in interface java.awt.datatransfer.Transferable
public java.lang.Object getTransferData(java.awt.datatransfer.DataFlavor flavor) throws java.awt.datatransfer.UnsupportedFlavorException, java.io.IOException
FileDrop.TransferableObject
.
If the FileDrop.TransferableObject.Fetcher
constructor was used, then this is when
the getObject()
method will be called.
If the requested data flavor is not supported, then the getObject()
method will not be called.getTransferData
in interface java.awt.datatransfer.Transferable
flavor
- The data flavor for the data to returnjava.awt.datatransfer.UnsupportedFlavorException
java.io.IOException
public boolean isDataFlavorSupported(java.awt.datatransfer.DataFlavor flavor)
equals(...)
method.isDataFlavorSupported
in interface java.awt.datatransfer.Transferable
flavor
- The data flavor to check