Additional top-level classes in compilation unit: DataSourceDataContentHandler, ObjectDataContentHandler, DataHandlerDataSource.
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.
javax.activation.CommandMap, javax.activation.DataContentHandler, javax.activation.DataSource, javax.activation.URLDataSource
| Modifier and Type | Field and Description |
|---|---|
| private CommandMap | |
| private DataContentHandler | |
| private DataSource | |
| private static final DataFlavor[] | |
| private static DataContentHandlerFactory | |
| private DataContentHandler | |
| private DataSource | |
| private Object | |
| private String | |
| private DataContentHandlerFactory | |
| private String | |
| private DataFlavor[] |
| Access | Constructor and Description |
|---|---|
| public | DataHandler(DataSource
the DataSource ds)Create a |
| public | DataHandler(Object
the Java Object obj, String the MIME type of the object mimeType)Create a |
| public |
| Modifier and Type | Method and Description |
|---|---|
| public CommandInfo[] | Returns: the CommandInfo objects representing all the commandsReturn all the commands for this type of data. |
| private synchronized String | |
| public Object | Returns: the instantiated command objectthe CommandInfo corresponding to a command cmdinfo)A convenience method that takes a CommandInfo object and instantiates the corresponding command, usually a JavaBean component. |
| public CommandInfo | Returns: the CommandInfo corresponding to the commandthe command name cmdName)Get the command cmdName. |
| private synchronized CommandMap | |
| public Object | |
| public String | Returns: the MIME typeReturn the MIME type of this object as retrieved from the source object. |
| private synchronized DataContentHandler | Returns: the requested DataContentHandlerGet the DataContentHandler for this DataHandler: If a DataContentHandlerFactory is set, use it. |
| public DataSource | Returns: a valid DataSource object for this DataHandlerReturn the DataSource associated with this instance of DataHandler. |
| public InputStream | |
| public String | |
| public OutputStream | Returns: the OutputStreamGet an OutputStream for this DataHandler to allow overwriting the underlying data. |
| public CommandInfo[] | Returns: the CommandInfo objects representing the preferred commandsReturn the preferred commands for this type of data. |
| public Object | Returns: the objectthe requested flavor for the data flavor)Implements java. |
| public synchronized DataFlavor[] | Returns: an array of data flavors in which this data can be transferredImplements java. |
| public boolean | Returns: true if the data flavor is supportedthe requested flavor for the data flavor)Implements java. |
| public synchronized void | setCommandMap(CommandMap
the CommandMap to use in this DataHandler commandMap)Set the CommandMap for use by this DataHandler. |
| public static synchronized void | setDataContentHandlerFactory(DataContentHandlerFactory
the DataContentHandlerFactory newFactory)Sets the DataContentHandlerFactory. |
| public void |
| currentCommandMap | back to summary |
|---|---|
| private CommandMap currentCommandMap | |
| dataContentHandler | back to summary |
|---|---|
| private DataContentHandler dataContentHandler | |
| dataSource | back to summary |
|---|---|
| private DataSource dataSource | |
| emptyFlavors | back to summary |
|---|---|
| private static final DataFlavor[] emptyFlavors | |
| factory | back to summary |
|---|---|
| private static DataContentHandlerFactory factory | |
| factoryDCH | back to summary |
|---|---|
| private DataContentHandler factoryDCH | |
| objDataSource | back to summary |
|---|---|
| private DataSource objDataSource | |
| object | back to summary |
|---|---|
| private Object object | |
| objectMimeType | back to summary |
|---|---|
| private String objectMimeType | |
| oldFactory | back to summary |
|---|---|
| private DataContentHandlerFactory oldFactory | |
| shortType | back to summary |
|---|---|
| private String shortType | |
| transferFlavors | back to summary |
|---|---|
| private DataFlavor[] transferFlavors | |
| DataHandler | back to summary |
|---|---|
| public DataHandler(DataSource ds) Create a
| |
| DataHandler | back to summary |
|---|---|
| public DataHandler(Object obj, String mimeType) Create a | |
| DataHandler | back to summary |
|---|---|
| public DataHandler(URL url) Create a
| |
| getAllCommands | back to summary |
|---|---|
| public CommandInfo[] getAllCommands() Return all the commands for this type of data.
This method returns an array containing all commands
for the type of data represented by this DataHandler. The
MIME type for the underlying data represented by this DataHandler
is used to call through to the
| |
| getBaseType | back to summary |
|---|---|
| private synchronized String getBaseType() Use the MimeType class to extract the MIME type/subtype, ignoring the parameters. The type is cached. | |
| getBean | back to summary |
|---|---|
| public Object getBean(CommandInfo cmdinfo) A convenience method that takes a CommandInfo object and instantiates the corresponding command, usually a JavaBean component.
This method calls the CommandInfo's
| |
| getCommand | back to summary |
|---|---|
| public CommandInfo getCommand(String cmdName) Get the command cmdName. Use the search semantics as
defined by the CommandMap installed in this DataHandler. The
MIME type for the underlying data represented by this DataHandler
is used to call through to the
| |
| getCommandMap | back to summary |
|---|---|
| private synchronized CommandMap getCommandMap() Return the CommandMap for this instance of DataHandler. | |
| getContent | back to summary |
|---|---|
| public Object getContent() throws IOException Return the data in its preferred Object form. 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
| |
| getContentType | back to summary |
|---|---|
| public String getContentType() Return the MIME type of this object as retrieved from the source object. Note that this is the full type with parameters.
| |
| getDataContentHandler | back to summary |
|---|---|
| private synchronized DataContentHandler getDataContentHandler() Get the DataContentHandler for this DataHandler: If a DataContentHandlerFactory is set, use it. Otherwise look for an object to serve DCH in the following order: 1) if a factory is set, use it 2) if a CommandMap is set, use it 3) use the default CommandMap In any case, wrap the real DataContentHandler with one of our own to handle any missing cases, fill in defaults, and to ensure that we always have a non-null DataContentHandler.
| |
| getDataSource | back to summary |
|---|---|
| public DataSource getDataSource() Return the DataSource associated with this instance of DataHandler. 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.
| |
| getInputStream | back to summary |
|---|---|
| public InputStream getInputStream() throws IOException Get the InputStream for this object.
For DataHandlers instantiated with a DataSource, the DataHandler
calls the
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
DataContentHandler's
| |
| getName | back to summary |
|---|---|
| public String getName() Return the name of the data object. If this DataHandler
was created with a DataSource, this method calls through
to the
| |
| getOutputStream | back to summary |
|---|---|
| public OutputStream getOutputStream() throws IOException Get an OutputStream for this DataHandler to allow overwriting
the underlying data.
If the DataHandler was created with a DataSource, the
DataSource's
| |
| getPreferredCommands | back to summary |
|---|---|
| public CommandInfo[] getPreferredCommands() Return the preferred commands for this type of data.
This method calls the
| |
| getTransferData | back to summary |
|---|---|
| public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException Implements java. Returns an object that represents the data to be transferred. The class of the object returned is defined by the representation class of the data flavor. 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.
| |
| getTransferDataFlavors | back to summary |
|---|---|
| public synchronized DataFlavor[] getTransferDataFlavors() Implements java. Return the DataFlavors in which this data is available. 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
and the
| |
| isDataFlavorSupported | back to summary |
|---|---|
| public boolean isDataFlavorSupported(DataFlavor flavor) Implements java. Returns whether the specified data flavor is supported for this object.
This method iterates through the DataFlavors returned from
| |
| setCommandMap | back to summary |
|---|---|
| public synchronized void setCommandMap(CommandMap commandMap) Set the CommandMap for use by this DataHandler.
Setting it to
| |
| setDataContentHandlerFactory | back to summary |
|---|---|
| public static synchronized void setDataContentHandlerFactory(DataContentHandlerFactory newFactory) Sets the DataContentHandlerFactory. The DataContentHandlerFactory is called first to find DataContentHandlers. The DataContentHandlerFactory can only be set once. If the DataContentHandlerFactory has already been set, this method throws an Error.
| |
| writeTo | back to summary |
|---|---|
| public void writeTo(OutputStream os) throws IOException Write the data to an 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
| |