javax.activation
Class DataHandler
java.lang.Object
javax.activation.DataHandler
- All Implemented Interfaces:
- java.awt.datatransfer.Transferable
- public class DataHandler
- extends java.lang.Object
- implements java.awt.datatransfer.Transferable
- Version:
- $Rev: 180468 $ $Date: 2005-06-06 14:32:39 -0600 (Mon, 06 Jun 2005) $
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ds
private final DataSource ds
flavor
private final java.awt.datatransfer.DataFlavor flavor
commandMap
private CommandMap commandMap
dch
private DataContentHandler dch
originalFactory
private DataContentHandlerFactory originalFactory
- This is used to check if the DataContentHandlerFactory has been changed.
This is not specified behaviour but this check is required to make this work like the RI.
factory
private static DataContentHandlerFactory factory
DataHandler
public DataHandler(DataSource ds)
DataHandler
public DataHandler(java.lang.Object data,
java.lang.String type)
DataHandler
public DataHandler(java.net.URL url)
getDataSource
public DataSource getDataSource()
getName
public java.lang.String getName()
getContentType
public java.lang.String getContentType()
getInputStream
public java.io.InputStream getInputStream()
throws java.io.IOException
- Throws:
java.io.IOException
writeTo
public void writeTo(java.io.OutputStream os)
throws java.io.IOException
- Throws:
java.io.IOException
getOutputStream
public java.io.OutputStream getOutputStream()
throws java.io.IOException
- Throws:
java.io.IOException
getTransferDataFlavors
public java.awt.datatransfer.DataFlavor[] getTransferDataFlavors()
- Specified by:
getTransferDataFlavors in interface java.awt.datatransfer.Transferable
isDataFlavorSupported
public boolean isDataFlavorSupported(java.awt.datatransfer.DataFlavor flavor)
- Specified by:
isDataFlavorSupported in interface java.awt.datatransfer.Transferable
getTransferData
public java.lang.Object getTransferData(java.awt.datatransfer.DataFlavor flavor)
throws java.awt.datatransfer.UnsupportedFlavorException,
java.io.IOException
- Specified by:
getTransferData in interface java.awt.datatransfer.Transferable
- Throws:
java.awt.datatransfer.UnsupportedFlavorException
java.io.IOException
getPreferredCommands
public CommandInfo[] getPreferredCommands()
getAllCommands
public CommandInfo[] getAllCommands()
getCommand
public CommandInfo getCommand(java.lang.String cmdName)
getContent
public java.lang.Object getContent()
throws java.io.IOException
- Throws:
java.io.IOException
getBean
public java.lang.Object getBean(CommandInfo cmdinfo)
setCommandMap
public void setCommandMap(CommandMap commandMap)
getCommandMap
private CommandMap getCommandMap()
getDataContentHandler
private DataContentHandler getDataContentHandler()
- Search for a DataContentHandler for our mime type.
The search is performed by first checking if a global factory has been set using
setDataContentHandlerFactory(DataContentHandlerFactory);
if found then it is called to attempt to create a handler.
If this attempt fails, we then call the command map set using setCommandMap(CommandMap)
(or if that has not been set, the default map returned by CommandMap.getDefaultCommandMap())
to create the handler.
The resulting handler is cached until the global factory is changed.
- Returns:
setDataContentHandlerFactory
public static void setDataContentHandlerFactory(DataContentHandlerFactory newFactory)
- Set the DataContentHandlerFactory to use.
If this method has already been called then an Error is raised.
- Parameters:
newFactory - the new factory
- Throws:
java.lang.SecurityException - if the caller does not have "SetFactory" RuntimePermission