APIdia Launch Partner
Top Description Fields Constructors Methods
javax.swing.plaf.basic

pack-priv Class BasicTransferable

extends Object
implements Transferable, UIResource
Class Inheritance
All Implemented Interfaces
javax.swing.plaf.UIResource, java.awt.datatransfer.Transferable
Known Direct Subclasses
javax.swing.plaf.basic.BasicFileChooserUI.FileTransferHandler.FileTransferable, javax.swing.plaf.basic.BasicTextUI.TextTransferHandler.TextTransferable
Imports
sun.datatransfer.DataFlavorUtil, java.io.*, java.awt.datatransfer.*, javax.swing.plaf.UIResource

A transferable implementation for the default data transfer of some Swing components.
Author
Timothy Prinzing

Field Summary

Modifier and TypeField and Description
protected String
private static DataFlavor[]
protected String
private static DataFlavor[]
private static DataFlavor[]

Constructor Summary

AccessConstructor and Description
public
BasicTransferable(String plainData, String htmlData)

Method Summary

Modifier and TypeMethod and Description
private InputStream
protected String
getHTMLData()

Fetch the data in a text/html format

protected String
getPlainData()

Fetch the data in a text/plain format.

protected Object
protected DataFlavor[]
getRicherFlavors()

Some subclasses will have flavors that are more descriptive than HTML or plain text.

public Object
getTransferData(DataFlavor
the requested flavor for the data
flavor
)

Implements java.awt.datatransfer.Transferable.getTransferData.

Returns an object which represents the data to be transferred.

public DataFlavor[]

Returns:

an array of data flavors in which this data can be transferred
getTransferDataFlavors
()

Implements java.awt.datatransfer.Transferable.getTransferDataFlavors.

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).

public boolean

Returns:

boolean indicating whether or not the data flavor is supported
isDataFlavorSupported
(DataFlavor
the requested flavor for the data
flavor
)

Implements java.awt.datatransfer.Transferable.isDataFlavorSupported.

Returns whether or not the specified data flavor is supported for this object.

protected boolean

Returns:

boolean indicating whether or not the data flavor is supported
isHTMLFlavor
(DataFlavor
the requested flavor for the data
flavor
)

Returns whether or not the specified data flavor is an HTML flavor that is supported.

protected boolean
isHTMLSupported()

Should the HTML flavors be offered?

protected boolean

Returns:

boolean indicating whether or not the data flavor is supported
isPlainFlavor
(DataFlavor
the requested flavor for the data
flavor
)

Returns whether or not the specified data flavor is an plain flavor that is supported.

protected boolean
isPlainSupported()

Should the plain text flavors be offered?

protected boolean
protected boolean

Returns:

boolean indicating whether or not the data flavor is supported
isStringFlavor
(DataFlavor
the requested flavor for the data
flavor
)

Returns whether or not the specified data flavor is a String flavor that is supported.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

htmlDataback to summary
protected String htmlData
htmlFlavorsback to summary
private static DataFlavor[] htmlFlavors
plainDataback to summary
protected String plainData
plainFlavorsback to summary
private static DataFlavor[] plainFlavors
stringFlavorsback to summary
private static DataFlavor[] stringFlavors

Constructor Detail

BasicTransferableback to summary
public BasicTransferable(String plainData, String htmlData)

Method Detail

createInputStreamback to summary
private InputStream createInputStream(DataFlavor flavor, String data) throws IOException, UnsupportedFlavorException
getHTMLDataback to summary
protected String getHTMLData()

Fetch the data in a text/html format

getPlainDataback to summary
protected String getPlainData()

Fetch the data in a text/plain format.

getRicherDataback to summary
protected Object getRicherData(DataFlavor flavor) throws UnsupportedFlavorException
getRicherFlavorsback to summary
protected DataFlavor[] getRicherFlavors()

Some subclasses will have flavors that are more descriptive than HTML or plain text. If this method returns a non-null value, it will be placed at the start of the array of supported flavors.

getTransferDataback to summary
public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException

Implements java.awt.datatransfer.Transferable.getTransferData.

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.

Parameters
flavor:DataFlavor

the requested flavor for the data

Exceptions
UnsupportedFlavorException:
if the requested data flavor is not supported.
IOException:
if the data is no longer available in the requested flavor.
See Also
DataFlavor#getRepresentationClass
getTransferDataFlavorsback to summary
public DataFlavor[] getTransferDataFlavors()

Implements java.awt.datatransfer.Transferable.getTransferDataFlavors.

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).

Returns:DataFlavor[]

an array of data flavors in which this data can be transferred

isDataFlavorSupportedback to summary
public boolean isDataFlavorSupported(DataFlavor flavor)

Implements java.awt.datatransfer.Transferable.isDataFlavorSupported.

Returns whether or not the specified data flavor is supported for this object.

Parameters
flavor:DataFlavor

the requested flavor for the data

Returns:boolean

boolean indicating whether or not the data flavor is supported

isHTMLFlavorback to summary
protected boolean isHTMLFlavor(DataFlavor flavor)

Returns whether or not the specified data flavor is an HTML flavor that is supported.

Parameters
flavor:DataFlavor

the requested flavor for the data

Returns:boolean

boolean indicating whether or not the data flavor is supported

isHTMLSupportedback to summary
protected boolean isHTMLSupported()

Should the HTML flavors be offered? If so, the method getHTMLData should be implemented to provide something reasonable.

isPlainFlavorback to summary
protected boolean isPlainFlavor(DataFlavor flavor)

Returns whether or not the specified data flavor is an plain flavor that is supported.

Parameters
flavor:DataFlavor

the requested flavor for the data

Returns:boolean

boolean indicating whether or not the data flavor is supported

isPlainSupportedback to summary
protected boolean isPlainSupported()

Should the plain text flavors be offered? If so, the method getPlainData should be implemented to provide something reasonable.

isRicherFlavorback to summary
protected boolean isRicherFlavor(DataFlavor flavor)
isStringFlavorback to summary
protected boolean isStringFlavor(DataFlavor flavor)

Returns whether or not the specified data flavor is a String flavor that is supported.

Parameters
flavor:DataFlavor

the requested flavor for the data

Returns:boolean

boolean indicating whether or not the data flavor is supported