X hits on this document

PDF document

Bart Calder, Bill Shannon - page 12 / 21





12 / 21

12 of 21

Primary Framework Interfaces

DataHandler encapsulates the type-to-command object binding service of the Command Map interface for applications. It provides a handle to the operations and data available on a data element.

DataHandler also implements the Transferable interface. This allows applications and applets to retrieve alternative representations of the underlying data, in the form of objects. The DataHandler encapsulates the interface to the component repository and data source.

Let’s examine these groups of features in more detail:


Data Encapsulation A DataHandler object can only be instantiated with data. The data can be in the form of an object implementing the DataSource interface (the preferred way) or as an object with an associated content type.

Once instantiated, the DataHandler tries to provide its data in a flexible way. The DataHandler implements the Transferable interface which allows an object to provide alternative representations of the data. The Transferable interface’s functionality can be extended via objects implementing the DataContentHandler interface, and then made available to the DataHandler either by a DataContentHandlerFactory object, or via a CommandMap.


Command Binding The DataHandler provides wrappers around commonly used functions for command discovery. DataHandler has methods that call into the current CommandMap associated with the DataHandler. By default the DataHandler calls CommandMap’s getDefaultCommandMap method if no CommandMap was explicitly set. As a convenience, DataHandler uses the content type of its data when calls are made to the CommandMap.

6.3 The DataContentHandler Interface

The DataContentHandler interface is implemented by classes that are used by the DataHandler to convert InputStreams into objects and vice versa. In effect, the DataHandler object uses a DataContentHandler object to implement the Transferable interface. DataContentHandlers are discovered via the current CommandMap. A DataContentHandler uses DataFlavors to represent the data types it can access.

The DataContentHandler also converts data from objects into InputStreams. For instance, if an application needs to access a .gif file, it passes the file to the image/gif DataContentHandler. The image/gif DataContentHandler converts the image object into a gif-formatted byte stream.

Applications will typically need to provide DataContentHandlers for all the MIME types they intend to support. (Note that the JavaMail reference implementation provides DataContentHandlers for many of the MIME types used in mail messages.)

Document info
Document views71
Page views71
Page last viewedSun Dec 11 08:41:42 UTC 2016