All Implemented Interfaces:
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 (
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
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.
public DataHandler(Object obj, String mimeType)
|Method from javax.activation.DataHandler Summary:|
|getAllCommands, getBean, getCommand, getContent, getContentType, getDataSource, getInputStream, getName, getOutputStream, getPreferredCommands, getTransferData, getTransferDataFlavors, isDataFlavorSupported, setCommandMap, setDataContentHandlerFactory, writeTo|
|Methods from java.lang.Object:|
|clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait|
|Method from javax.activation.DataHandler Detail:|
public CommandInfo getAllCommands()
public Object getBean(CommandInfo cmdinfo)
This method calls the CommandInfo's
public CommandInfo getCommand(String cmdName)
public Object getContent() throws IOException
If the DataHandler was instantiated with an object, return the object.
If the DataHandler was instantiated with a DataSource,
this method uses a DataContentHandler to return the content
object for the data represented by this DataHandler. If no
public String getContentType()
public DataSource getDataSource()
For DataHandlers that have been instantiated with a DataSource, this method returns the DataSource that was used to create the DataHandler object. In other cases the DataHandler constructs a DataSource from the data used to construct the DataHandler. DataSources created for DataHandlers not instantiated with a DataSource are cached for performance reasons.
public InputStream getInputStream() throws IOException
For DataHandlers instantiated with a DataSource, the DataHandler
For DataHandlers instantiated with an Object, the DataHandler
first attempts to find a DataContentHandler for the Object. If
the DataHandler can not find a DataContentHandler for this MIME
type, it throws an UnsupportedDataTypeException. If it is
successful, it creates a pipe and a thread. The thread uses the
public OutputStream getOutputStream() throws IOException
public CommandInfo getPreferredCommands()
public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException
For DataHandler's created with DataSources or URLs:
The DataHandler attempts to locate a DataContentHandler
for this MIME type. If one is found, the passed in DataFlavor
and the type of the data are passed to its
For DataHandler's created with Objects:
The DataHandler attempts to locate a DataContentHandler for this MIME type. If one is found, the passed in DataFlavor and the type of the data are passed to its getTransferData method. If the DataHandler fails to locate a DataContentHandler and the flavor specifies this object's MIME type and its class, this DataHandler's referenced object is returned. Otherwise it throws an UnsupportedFlavorException.
public synchronized DataFlavor getTransferDataFlavors()
Returns an array of DataFlavor objects indicating the flavors the data can be provided in. The array is usually ordered according to preference for providing the data, from most richly descriptive to least richly descriptive.
The DataHandler attempts to find a DataContentHandler that
corresponds to the MIME type of the data. If one is located,
the DataHandler calls the DataContentHandler's
If a DataContentHandler can not be located, and if the
DataHandler was created with a DataSource (or URL), one
DataFlavor is returned that represents this object's MIME type
public boolean isDataFlavorSupported(DataFlavor flavor)
This method iterates through the DataFlavors returned from
public synchronized void setCommandMap(CommandMap commandMap)
public static synchronized void setDataContentHandlerFactory(DataContentHandlerFactory newFactory)
If the DataContentHandlerFactory has already been set, this method throws an Error.
public void writeTo(OutputStream os) throws IOException
If the DataHandler was created with a DataSource, writeTo retrieves the InputStream and copies the bytes from the InputStream to the OutputStream passed in.
If the DataHandler was created with an object, writeTo
retrieves the DataContentHandler for the object's type.
If the DataContentHandler was found, it calls the