APIdia Launch Partner
Top Description Fields Constructors Methods
javafx.scene.input

public Class DataFormat

extends Object
Class Inheritance
Imports
java.util.Arrays, .Collections, .HashSet, .Iterator, .Set, com.sun.javafx.util.WeakReferenceQueue, javafx.beans.NamedArg

Data format identifier used as means of identifying the data stored on a clipboard/dragboard.
Since
JavaFX 2.0

Field Summary

Modifier and TypeField and Description
private static final WeakReferenceQueue<DataFormat>
DATA_FORMAT_LIST

A static cache of all DataFormats created and currently in use.

private static final DataFormat
DRAG_IMAGE

Data format used internally, represents dragged image.

private static final DataFormat
DRAG_IMAGE_OFFSET

Data format used internally, represents offset in the dragged image.

public static final DataFormat
FILES

Represents a List of Files.

public static final DataFormat
HTML

Represents an HTML formatted string.

private final Set<String>
identifier

A set of identifiers, typically mime types, for this DataFormat.

public static final DataFormat
IMAGE

A special platform specific image type, such as is commonly used on the clipboard and interoperates widely with other applications.

public static final DataFormat
PLAIN_TEXT

Represents a plain text string.

public static final DataFormat
RTF

Represents an RTF formatted string

public static final DataFormat
URL

Represents a URL, encoded as a String

Constructor Summary

AccessConstructor and Description
public
DataFormat(String...
The set of ids used to represent this DataFormat on the clipboard.
ids
)

Create a new DataFormat, specifying the set of ids that are associated with this data format.

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if this object is equal to the obj argument; false otherwise.
equals
(Object
the reference object with which to compare.
obj
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

public final Set<String>

Returns:

an unmodifiable set that is never null.
getIdentifiers
()

Gets the unmodifiable set of identifiers for this DataFormat.

public int

Returns:

a hash code for this DataFormat object.
hashCode
()

Overrides java.lang.Object.hashCode.

Returns a hash code for this DataFormat object.

public static DataFormat

Returns:

The matching DataFormat
lookupMimeType
(String
If null or the empty string, then null is returned.
mimeType
)

Looks for the DataFormat which has been previously created with the given mime type as one of its ids.

public String

Returns:

a string representation of this DataFormat object.
toString
()

Overrides java.lang.Object.toString.

Returns a string representation of this DataFormat object.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

DATA_FORMAT_LISTback to summary
private static final WeakReferenceQueue<DataFormat> DATA_FORMAT_LIST

A static cache of all DataFormats created and currently in use. This is needed by the underlying implementation, such that, given a mime type, we can determine the associated DataFormat. The OS level is going to supply us with a mime type (or other string based key), and we need to be able to map this back to the FX DataFormat.

DRAG_IMAGEback to summary
private static final DataFormat DRAG_IMAGE

Data format used internally, represents dragged image. Making this a private field prevents user from creating this DataFormat and breaking our drag view implementation.

DRAG_IMAGE_OFFSETback to summary
private static final DataFormat DRAG_IMAGE_OFFSET

Data format used internally, represents offset in the dragged image. Making this a private field prevents user from creating this DataFormat and breaking our drag view implementation.

FILESback to summary
public static final DataFormat FILES

Represents a List of Files.

HTMLback to summary
public static final DataFormat HTML

Represents an HTML formatted string.

identifierback to summary
private final Set<String> identifier

A set of identifiers, typically mime types, for this DataFormat. In most cases this will be a single String.

IMAGEback to summary
public static final DataFormat IMAGE

A special platform specific image type, such as is commonly used on the clipboard and interoperates widely with other applications. For example, on Mac this might ultimately be a TIFF while on Windows it might be a DIB (device independent bitmap).

PLAIN_TEXTback to summary
public static final DataFormat PLAIN_TEXT

Represents a plain text string.

RTFback to summary
public static final DataFormat RTF

Represents an RTF formatted string

URLback to summary
public static final DataFormat URL

Represents a URL, encoded as a String

Constructor Detail

DataFormatback to summary
public DataFormat(String... ids)

Create a new DataFormat, specifying the set of ids that are associated with this data format. Typically the ids are one or more mime types. For each id, any data associated with this DataFormat will be registered on the clipboard. For example, suppose I had the following:

DataFormat fmt = new DataFormat("text/foo", "text/bar");
    Clipboard clipboard = Clipboard.getSystemClipboard();
    ClipboardContent content = new ClipboardContent();
    content.put(fmt, "Hello");
    clipboard.setContent(content);
With the above code, if I were to look on the clipboard, I'd find the String "Hello" listed both for "text/foo" and "text/bar" on the clipboard.

Note that the ids may be subject to platform restrictions in some cases. For instance, Swing requires a mime type so if an id is not of the "type/subtype" format it won't be possible to drag data of this type from/to javafx.embed.swing.JFXPanel.

Parameters
ids:String[]

The set of ids used to represent this DataFormat on the clipboard.

Exceptions
IllegalArgumentException:
if one of the given mime types is already assigned to another DataFormat.

Method Detail

equalsback to summary
public boolean equals(Object obj)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

Parameters
obj:Object

the reference object with which to compare.

Returns:boolean

true if this object is equal to the obj argument; false otherwise.

Annotations
@Override
getIdentifiersback to summary
public final Set<String> getIdentifiers()

Gets the unmodifiable set of identifiers for this DataFormat.

Returns:Set<String>

an unmodifiable set that is never null.

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code for this DataFormat object.

Returns:int

a hash code for this DataFormat object.

Annotations
@Override
lookupMimeTypeback to summary
public static DataFormat lookupMimeType(String mimeType)

Looks for the DataFormat which has been previously created with the given mime type as one of its ids.

Parameters
mimeType:String

If null or the empty string, then null is returned.

Returns:DataFormat

The matching DataFormat

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Returns a string representation of this DataFormat object.

Returns:String

a string representation of this DataFormat object.

Annotations
@Override