JavaTM 2 Platform
Std. Ed. v1.3.1

com.apple.mrj.datatransfer
Class Transfer

java.lang.Object
  |
  +--com.apple.mrj.datatransfer.Transfer
All Implemented Interfaces:
FlaggedTransferable, Transferable
Direct Known Subclasses:
DragItem

Deprecated. As of MacOSX 10.2

public class Transfer
extends Object
implements FlaggedTransferable

Generic implementation of FlaggedTransferable to simplify data transfer. Allows a transfer initiator to shovel flavor data into a drag or clipboard without having to define any new classes.


Fields inherited from interface com.apple.mrj.datatransfer.FlaggedTransferable
kFlavorNotSaved, kFlavorSenderOnly, kFlavorSenderTranslated, kFlavorSystemTranslated
 
Constructor Summary
Transfer()
          Deprecated. Creates a new empty Transfer.
 
Method Summary
 void addFlavor(DataFlavor flavor, Object data)
          Deprecated. Adds a data flavor, with its data.
 void addPromiseFlavor(DataFlavor flavor)
          Deprecated. Adds a data flavor with a "promise" of its data.
 void freeze()
          Deprecated. Makes this object immutable -- no more flavors can be added.
 int getDataFlavorFlags(DataFlavor flavor)
          Deprecated. Returns the flags associated with a DataFlavor.
protected  Object getPromiseData(DataFlavor flavor)
          Deprecated. Called to request the data for a flavor that was "promised", i.e.
 Object getRawTransferData(DataFlavor flavor)
          Deprecated. Gets the transfer data without resolving promises (calling getPromiseData) or wrapping any InputStreams around byte arrays.
 Object getTransferData(DataFlavor flavor)
          Deprecated. Returns an object which represents the data to be transferred.
 DataFlavor[] getTransferDataFlavors()
          Deprecated. Returns an array of DataFlavor objects indicating the flavors the data can be provided in.
 boolean isDataAvailable(DataFlavor flavor)
          Deprecated. Returns whether or not the data of the specified flavor is already available.
 boolean isDataFlavorSupported(DataFlavor flavor)
          Deprecated. Returns whether or not the specified data flavor is supported for this object.
 void setDataFlavorFlags(DataFlavor flavor, int flags)
          Deprecated. Sets the flags for a data flavor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Transfer

public Transfer()
Deprecated. 
Creates a new empty Transfer.
Method Detail

addFlavor

public void addFlavor(DataFlavor flavor,
                      Object data)
Deprecated. 
Adds a data flavor, with its data. The class of the data must match that of the DataFlavor's representationClass, except that it is allowable to pass a byte[] array when the representationClass is InputStream -- when the data is requested, a ByteArrayInputStream will automatically be wrapped around the array.

There is one danger with passing in an InputStream directly: Since streams have state, the stream data will only be readable once. A second call to getTransferData will return the same stream object, which will probably already be at its EOF. For this reason it's usually safer to provide streams as "promises" so you can return a fresh stream object every time.


addPromiseFlavor

public void addPromiseFlavor(DataFlavor flavor)
Deprecated. 
Adds a data flavor with a "promise" of its data. If you use this method you must subclass Transfer and override the getPromiseData method to return the appropriate Object when this flavor is requested.

setDataFlavorFlags

public void setDataFlavorFlags(DataFlavor flavor,
                               int flags)
                        throws UnsupportedFlavorException
Deprecated. 
Sets the flags for a data flavor. These flags may or may not be interpreted by the specific data transfer mechanism (clipboard, drag and drop) that operates on this Transfer.

freeze

public void freeze()
Deprecated. 
Makes this object immutable -- no more flavors can be added.

getTransferDataFlavors

public DataFlavor[] getTransferDataFlavors()
Deprecated. 
Returns an array of DataFlavor objects indicating the flavors the data can be provided in. The array should be ordered according to preference for providing the data (from most richly descriptive to least descriptive).
Specified by:
getTransferDataFlavors in interface Transferable
Returns:
an array of data flavors in which this data can be transferred

isDataFlavorSupported

public boolean isDataFlavorSupported(DataFlavor flavor)
Deprecated. 
Returns whether or not the specified data flavor is supported for this object.
Specified by:
isDataFlavorSupported in interface Transferable
Parameters:
flavor - the requested flavor for the data
Returns:
boolean indicating wjether or not the data flavor is supported

isDataAvailable

public boolean isDataAvailable(DataFlavor flavor)
Deprecated. 
Returns whether or not the data of the specified flavor is already available. This will return false if the data was promised (not provided at the time that addFlavor was called) and getPromiseData has not yet been called for that flavor.

getRawTransferData

public Object getRawTransferData(DataFlavor flavor)
                          throws UnsupportedFlavorException
Deprecated. 
Gets the transfer data without resolving promises (calling getPromiseData) or wrapping any InputStreams around byte arrays.

getTransferData

public Object getTransferData(DataFlavor flavor)
                       throws UnsupportedFlavorException,
                              IOException
Deprecated. 
Returns an object which represents the data to be transferred. The class of the object returned is defined by the representation class of the flavor.
Specified by:
getTransferData in interface Transferable
Parameters:
flavor - the requested flavor for the data
Throws:
IOException - if the data is no longer available in the requested flavor.
UnsupportedFlavorException - if the requested data flavor is not supported.
See Also:
DataFlavor.getRepresentationClass()

getPromiseData

protected Object getPromiseData(DataFlavor flavor)
                         throws IOException
Deprecated. 
Called to request the data for a flavor that was "promised", i.e. whose data was not supplied at the time of the addFlavor or addPromiseFlavor call. This method will only be called once for any flavor: the result will be cached.

As with addFlavor, it's OK to return data as a byte array if the flavor's representationClass calls for an InputStream: a ByteArrayInputStream will automatically be wrapped around the data.


getDataFlavorFlags

public int getDataFlavorFlags(DataFlavor flavor)
                       throws UnsupportedFlavorException
Deprecated. 
Returns the flags associated with a DataFlavor. These flags may or may not be interpreted by the specific data transfer mechanism (clipboard, drag and drop) that operates on this Transfer.
Specified by:
getDataFlavorFlags in interface FlaggedTransferable

JavaTM 2 Platform
Std. Ed. v1.3.1

Submit a bug or feature
For further API reference and developer documentation, see Java 2 SDK SE Developer Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.

Java, Java 2D, and JDBC are trademarks or registered trademarks of Sun Microsystems, Inc. in the US and other countries.
Copyright 1993-2001 Sun Microsystems, Inc. 901 San Antonio Road
Palo Alto, California, 94303, U.S.A. All Rights Reserved.