public class DataFormat
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private static <any> |
DATA_FORMAT_LIST
A static cache of all DataFormats created and currently in use.
|
private static DataFormat |
DRAG_IMAGE
Data format used internally, represents dragged image.
|
private static DataFormat |
DRAG_IMAGE_OFFSET
Data format used internally, represents offset in the dragged image.
|
static DataFormat |
FILES
Represents a List of Files.
|
static DataFormat |
HTML
Represents an HTML formatted string.
|
private java.util.Set<java.lang.String> |
identifier
A set of identifiers, typically mime types, for this DataFormat.
|
static DataFormat |
IMAGE
A special platform specific image type, such as is commonly used
on the clipboard and interoperates widely with other applications.
|
static DataFormat |
PLAIN_TEXT
Represents a plain text string.
|
static DataFormat |
RTF
Represents an RTF formatted string
|
static DataFormat |
URL
Represents a URL, encoded as a String
|
Constructor and Description |
---|
DataFormat(java.lang.String... ids)
Create a new DataFormat, specifying the set of ids that are associated with
this data format.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object obj)
Indicates whether some other object is "equal to" this one.
|
java.util.Set<java.lang.String> |
getIdentifiers()
Gets the unmodifiable set of identifiers for this DataFormat.
|
int |
hashCode()
Returns a hash code for this
DataFormat object. |
static DataFormat |
lookupMimeType(java.lang.String mimeType)
Looks for the DataFormat which has been previously created with
the given mime type as one of its ids.
|
java.lang.String |
toString()
Returns a string representation of this
DataFormat object. |
private static final <any> DATA_FORMAT_LIST
public static final DataFormat PLAIN_TEXT
public static final DataFormat HTML
public static final DataFormat RTF
public static final DataFormat URL
public static final DataFormat IMAGE
public static final DataFormat FILES
private static final DataFormat DRAG_IMAGE
private static final DataFormat DRAG_IMAGE_OFFSET
private final java.util.Set<java.lang.String> identifier
public DataFormat(java.lang.String... ids)
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
.
ids
- The set of ids used to represent this DataFormat on the clipboard.java.lang.IllegalArgumentException
- if one of the given mime types is already
assigned to another DataFormat.public final java.util.Set<java.lang.String> getIdentifiers()
public java.lang.String toString()
DataFormat
object.toString
in class java.lang.Object
DataFormat
object.public int hashCode()
DataFormat
object.hashCode
in class java.lang.Object
DataFormat
object.public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
obj
- the reference object with which to compare.true
if this object is equal to the obj
argument; false
otherwise.public static DataFormat lookupMimeType(java.lang.String mimeType)
mimeType
- If null or the empty string, then null is returned.