public class DataHandler extends Object implements Transferable
DataHandler and the Transferable Interface
DataHandler implements the Transferable interface so that data can be used in AWT data transfer operations, such as cut and paste and drag and drop. The implementation of the Transferable interface relies on the availability of an installed DataContentHandler object corresponding to the MIME type of the data represented in the specific instance of the DataHandler.
DataHandler and CommandMaps
The DataHandler keeps track of the current CommandMap that it uses to
service requests for commands (getCommand
,
getAllCommands
, getPreferredCommands
).
Each instance of a DataHandler may have a CommandMap associated with
it using the setCommandMap
method. If a CommandMap was
not set, DataHandler calls the getDefaultCommandMap
method in CommandMap and uses the value it returns. See
CommandMap for more information.
DataHandler and URLs
The current DataHandler implementation creates a private instance of URLDataSource when it is constructed with a URL.
CommandMap
,
DataContentHandler
,
DataSource
,
URLDataSource
Constructor and Description |
---|
DataHandler(DataSource ds)
Create a
DataHandler instance referencing the
specified DataSource. |
DataHandler(Object obj,
String mimeType)
Create a
DataHandler instance representing an object
of this MIME type. |
DataHandler(URL url)
Create a
DataHandler instance referencing a URL. |
Modifier and Type | Method and Description |
---|---|
CommandInfo[] |
getAllCommands()
Return all the commands for this type of data.
|
Object |
getBean(CommandInfo cmdinfo)
A convenience method that takes a CommandInfo object
and instantiates the corresponding command, usually
a JavaBean component.
|
CommandInfo |
getCommand(String cmdName)
Get the command cmdName.
|
Object |
getContent()
Return the data in its preferred Object form.
|
String |
getContentType()
Return the MIME type of this object as retrieved from
the source object.
|
DataSource |
getDataSource()
Return the DataSource associated with this instance
of DataHandler.
|
InputStream |
getInputStream()
Get the InputStream for this object.
|
String |
getName()
Return the name of the data object.
|
OutputStream |
getOutputStream()
Get an OutputStream for this DataHandler to allow overwriting
the underlying data.
|
CommandInfo[] |
getPreferredCommands()
Return the preferred commands for this type of data.
|
Object |
getTransferData(DataFlavor flavor)
Returns an object that represents the data to be
transferred.
|
DataFlavor[] |
getTransferDataFlavors()
Return the DataFlavors in which this data is available.
|
boolean |
isDataFlavorSupported(DataFlavor flavor)
Returns whether the specified data flavor is supported
for this object.
|
void |
setCommandMap(CommandMap commandMap)
Set the CommandMap for use by this DataHandler.
|
static void |
setDataContentHandlerFactory(DataContentHandlerFactory newFactory)
Sets the DataContentHandlerFactory.
|
void |
|