
CHAPTER 6
Data Transfer
Data transfer refers to the ability of an application to transfer selected data in a
variety of ways. For example, an application can use data transfer to support mov-
ing data between its own subparts. An application can also use data transfer to
exchange data with other Java applications that are running in the same Java VM
or in another Java VM or with native applications that are not running in a VM at
all. There are two commonly used metaphors for data transfer: cut-and-paste and
drag-and-dr op. Java 1.1 included a basic data transfer architectur e and supported
cut-and-paste. The Java 2 platform extends the architectur e in minor ways and
adds support for drag-and-drop.
The Data Transfer Framework
Both the cut-and-paste and drag-and-drop metaphors rely on the same underlying
data transfer architectur e. This architectur e was defined in Java 1.1 in the
java.awt.datatransfer package. It consists of the DataFlavor class, which
describes data types and data formats, and the
Transferable inter face, which
defines methods that must be implemented if data is to be transferred.
The DataFlavor Class
A data transfer mechanism requir es a precise and portable way to specify the type
of data to be transferred. This is necessary so that both parties to the transfer—the
data source and the data sink—can agree on exactly what is being transferred.
Since the data source and the data sink ...