DataFlavor
objects are constant and never change once
instantiated.
For information on using data transfer with Swing, see How to Use Drag and Drop and Data Transfer, a section in The Java Tutorial, for more information.
DataFlavor
. This constructor is
provided only for the purpose of supporting the
Externalizable
interface. It is not
intended for public (client) use.DataFlavor
that represents a Java class.
The returned DataFlavor
will have the following
characteristics:
representationClass = representationClass mimeType = application/x-java-serialized-object
DataFlavor
that represents a
MimeType
.
The returned DataFlavor
will have the following
characteristics:
If the mimeType
is
"application/x-java-serialized-object; class=<representation class>",
the result is the same as calling
new DataFlavor(Class:forName(<representation class>)
.
Otherwise:
representationClass = InputStream mimeType = mimeType
DataFlavor
that represents a
MimeType
.
The returned DataFlavor
will have the following
characteristics:
If the mimeType is
"application/x-java-serialized-object; class=<representation class>",
the result is the same as calling
new DataFlavor(Class:forName(<representation class>)
.
Otherwise:
representationClass = InputStream mimeType = mimeType
DataFlavor
from a mimeType
string.
The string can specify a "class=DataFlavor
with the desired
representation class. If the string does not contain "class=" parameter,
java.io.InputStream
is used as default.DataFlavor
representing a Java Image class,
where:
representationClass = java.awt.Image mimeType = "image/x-java-image"
DataFlavor
of this type/subtype and
representation class of java.util.List
is used.
Each element of the list is required/guaranteed to be of type
java.io.File
.Transferable
interface WITHIN THE SAME JVM, a DataFlavor
with this type/subtype is used, with a representationClass
equal to the type of the class/interface being passed across the
Transferable
.
The object reference returned from
Transferable.getTransferData
for a DataFlavor
with this MIME Content-Type is required to be
an instance of the representation Class of the DataFlavor
.
ACTION_LINK
operation a Mime Content Type of
application/x-java-remote-object should be used,
where the representation class of the DataFlavor
represents the type of the Remote
interface to be
transferred.DataFlavor
identifies the Java type of an object returned as a reference
from an invocation java.awt.datatransfer.getTransferData
.DataFlavor
representing plain text with Unicode
encoding, where:
representationClass = InputStream mimeType = "text/plain; charset=unicode"This
DataFlavor
has been deprecated because
(1) Its representation is an InputStream, an 8-bit based representation,
while Unicode is a 16-bit character set; and (2) The charset "unicode"
is not well-defined. "unicode" implies a particular platform's
implementation of Unicode, not a cross-platform implementation.DataFlavor
representing a Java Unicode String class,
where:
representationClass = java.lang.String mimeType = "application/x-java-serialized-object"
DataFlavor
.DataFlavor
to this DataFlavor
for
equality. Two DataFlavor
s are considered equal if and only
if their MIME primary type and subtype and representation class are
equal. Additionally, if the primary type is "text", the subtype denotes
a text flavor which supports the charset parameter, and the
representation class is not java.io.Reader
,
java.lang.String
, java.nio.CharBuffer
, or
[C
, the charset
parameter must also be equal.
If a charset is not explicitly specified for one or both
DataFlavor
s, the platform default encoding is assumed. See
selectBestTextFlavor
for a list of text flavors which
support the charset parameter.Object
to this DataFlavor
for equality. Two DataFlavor
s are considered equal if and
only if their MIME primary type and subtype and representation class are
equal. Additionally, if the primary type is "text", the subtype denotes
a text flavor which supports the charset parameter, and the
representation class is not java.io.Reader
,
java.lang.String
, java.nio.CharBuffer
, or
[C
, the charset
parameter must also be equal.
If a charset is not explicitly specified for one or both
DataFlavor
s, the platform default encoding is assumed. See
selectBestTextFlavor
for a list of text flavors which
support the charset parameter.mimeType
against the passed in
String
and representationClass
is
not considered in the comparison.
If representationClass
needs to be compared, then
equals(new DataFlavor(s))
may be used.DataFlavor
represents. This name would be localized
for different countries.DataFlavor
.DataFlavor
if paramName
equals "humanPresentableName". Otherwise
returns the MIME type value associated with paramName
.DataFlavor
.java.io.Reader
, java.lang.String
,
java.nio.CharBuffer
, [C
,
java.io.InputStream
, java.nio.ByteBuffer
,
and [B
.
Because text flavors which do not support the charset parameter are
encoded in a non-standard format, this method should not be called for
such flavors. However, in order to maintain backward-compatibility,
if this method is called for such a flavor, this method will treat the
flavor as though it supports the charset parameter and attempt to
decode it accordingly. See selectBestTextFlavor
for a list
of text flavors which do not support the charset parameter.
Class
which objects supporting this
DataFlavor
will return when this DataFlavor
is requested.DataFlavor
.DataFlavor
representing plain text with Unicode
encoding, where:
representationClass = java.io.InputStream mimeType = "text/plain; charset=<platform default Unicode encoding>"Sun's implementation for Microsoft Windows uses the encoding
utf-16le
.
Sun's implementation for Solaris and Linux uses the encoding
iso-10646-ucs-2
.DataFlavor
.
For two equal DataFlavor
s, hash codes are equal.
For the String
that matches DataFlavor.equals(String)
, it is not
guaranteed that DataFlavor
's hash code is equal
to the hash code of the String
.DataFlavor
specified represents
a list of file objects.DataFlavor
specified represents
a remote object.DataFlavor
specified represents
a serialized object.DataFlavor
is a valid text flavor for
this implementation of the Java platform. Only flavors equivalent to
DataFlavor.stringFlavor
and DataFlavor
s with
a primary MIME type of "text" can be valid text flavors.
If this flavor supports the charset parameter, it must be equivalent to
DataFlavor.stringFlavor
, or its representation must be
java.io.Reader
, java.lang.String
,
java.nio.CharBuffer
, [C
,
java.io.InputStream
, java.nio.ByteBuffer
, or
[B
. If the representation is
java.io.InputStream
, java.nio.ByteBuffer
, or
[B
, then this flavor's charset
parameter must
be supported by this implementation of the Java platform. If a charset
is not specified, then the platform default charset, which is always
supported, is assumed.
If this flavor does not support the charset parameter, its
representation must be java.io.InputStream
,
java.nio.ByteBuffer
, or [B
.
See selectBestTextFlavor
for a list of text flavors which
support the charset parameter.
mimeType
of two DataFlavor
objects. No parameters are considered.DataFlavor
.
Parameters are not included in the comparison.DataFlavor
represent a serialized object?DataFlavor
is java.nio.ByteBuffer
or a
subclass thereof.DataFlavor
is java.nio.CharBuffer
or a
subclass thereof.DataFlavor
represent a
java.io.InputStream
?DataFlavor
is java.io.Reader
or a subclass
thereof.Remote
.DataFlavor
to this DataFlavor
for
equality. Two DataFlavor
s are considered equal if and only
if their MIME primary type and subtype and representation class are
equal. Additionally, if the primary type is "text", the subtype denotes
a text flavor which supports the charset parameter, and the
representation class is not java.io.Reader
,
java.lang.String
, java.nio.CharBuffer
, or
[C
, the charset
parameter must also be equal.
If a charset is not explicitly specified for one or both
DataFlavor
s, the platform default encoding is assumed. See
selectBestTextFlavor
for a list of text flavors which
support the charset parameter.wait
methods.
The awakened thread will not be able to proceed until the current thread relinquishes the lock on this object. The awakened thread will compete in the usual manner with any other threads that might be actively competing to synchronize on this object; for example, the awakened thread enjoys no reliable privilege or disadvantage in being the next thread to lock this object.
This method should only be called by a thread that is the owner of this object's monitor. A thread becomes the owner of the object's monitor in one of three ways:
synchronized
statement
that synchronizes on the object.
Class,
by executing a
synchronized static method of that class.
Only one thread at a time can own an object's monitor.
wait
methods.
The awakened threads will not be able to proceed until the current thread relinquishes the lock on this object. The awakened threads will compete in the usual manner with any other threads that might be actively competing to synchronize on this object; for example, the awakened threads enjoy no reliable privilege or disadvantage in being the next thread to lock this object.
This method should only be called by a thread that is the owner
of this object's monitor. See the notify
method for a
description of the ways in which a thread can become the owner of
a monitor.
DataFlavor
from an array of
DataFlavor
s. Only DataFlavor.stringFlavor
, and
equivalent flavors, and flavors that have a primary MIME type of "text",
are considered for selection.
Flavors are first sorted by their MIME types in the following order:
For example, "text/sgml" will be selected over
"text/html", and DataFlavor.stringFlavor
will be chosen
over DataFlavor.plainTextFlavor
.
If two or more flavors share the best MIME type in the array, then that MIME type will be checked to see if it supports the charset parameter.
The following MIME types support, or are treated as though they support, the charset parameter:
DataFlavor
which uses that MIME type. If so, the JRE
will assume from that point on that the MIME type supports the charset
parameter and will not check again. If the parameter is not explicitly
listed, the JRE will assume from that point on that the MIME type does
not support the charset parameter and will not check again. Because
this check is performed on an arbitrarily chosen
DataFlavor
, developers must ensure that all
DataFlavor
s with a "text/<other>" MIME type specify
the charset parameter if it is supported by that MIME type. Developers
should never rely on the JRE to substitute the platform's default
charset for a "text/<other>" DataFlavor. Failure to adhere to this
restriction will lead to undefined behavior.
If the best MIME type in the array does not support the charset
parameter, the flavors which share that MIME type will then be sorted by
their representation classes in the following order:
java.io.InputStream
, java.nio.ByteBuffer
,
[B
, <all others>.
If two or more flavors share the best representation class, or if no flavor has one of the three specified representations, then one of those flavors will be chosen non-deterministically.
If the best MIME type in the array does support the charset parameter,
the flavors which share that MIME type will then be sorted by their
representation classes in the following order:
java.io.Reader
, java.lang.String
,
java.nio.CharBuffer
, [C
, <all others>.
If two or more flavors share the best representation class, and that representation is one of the four explicitly listed, then one of those flavors will be chosen non-deterministically. If, however, no flavor has one of the four specified representations, the flavors will then be sorted by their charsets. Unicode charsets, such as "UTF-16", "UTF-8", "UTF-16BE", "UTF-16LE", and their aliases, are considered best. After them, the platform default charset and its aliases are selected. "US-ASCII" and its aliases are worst. All other charsets are chosen in alphabetical order, but only charsets supported by this implementation of the Java platform will be considered.
If two or more flavors share the best charset, the flavors will then
again be sorted by their representation classes in the following order:
java.io.InputStream
, java.nio.ByteBuffer
,
[B
, <all others>.
If two or more flavors share the best representation class, or if no flavor has one of the three specified representations, then one of those flavors will be chosen non-deterministically.
DataFlavor
represents. This name would be localized
for different countries.DataFlavor
and its
parameters. The resulting String
contains the name of
the DataFlavor
class, this flavor's MIME type, and its
representation class. If this flavor has a primary MIME type of "text",
supports the charset parameter, and has an encoded representation, the
flavor's charset is also included. See selectBestTextFlavor
for a list of text flavors which support the charset parameter.
The current thread must own this object's monitor. The thread
releases ownership of this monitor and waits until another thread
notifies threads waiting on this object's monitor to wake up
either through a call to the notify
method or the
notifyAll
method. The thread then waits until it can
re-obtain ownership of the monitor and resumes execution.
As in the one argument version, interrupts and spurious wakeups are possible, and this method should always be used in a loop:
synchronized (obj) { while (<condition does not hold>) obj.wait(); ... // Perform action appropriate to condition }This method should only be called by a thread that is the owner of this object's monitor. See the
notify
method for a
description of the ways in which a thread can become the owner of
a monitor.The current thread must own this object's monitor.
This method causes the current thread (call it T) to place itself in the wait set for this object and then to relinquish any and all synchronization claims on this object. Thread T becomes disabled for thread scheduling purposes and lies dormant until one of four things happens:
A thread can also wake up without being notified, interrupted, or timing out, a so-called spurious wakeup. While this will rarely occur in practice, applications must guard against it by testing for the condition that should have caused the thread to be awakened, and continuing to wait if the condition is not satisfied. In other words, waits should always occur in loops, like this one:
synchronized (obj) { while (<condition does not hold>) obj.wait(timeout); ... // Perform action appropriate to condition }(For more information on this topic, see Section 3.2.3 in Doug Lea's "Concurrent Programming in Java (Second Edition)" (Addison-Wesley, 2000), or Item 50 in Joshua Bloch's "Effective Java Programming Language Guide" (Addison-Wesley, 2001).
If the current thread is interrupted by another thread while it is waiting, then an InterruptedException is thrown. This exception is not thrown until the lock status of this object has been restored as described above.
Note that the wait method, as it places the current thread into the wait set for this object, unlocks only this object; any other objects on which the current thread may be synchronized remain locked while the thread waits.
This method should only be called by a thread that is the owner
of this object's monitor. See the notify
method for a
description of the ways in which a thread can become the owner of
a monitor.
This method is similar to the wait
method of one
argument, but it allows finer control over the amount of time to
wait for a notification before giving up. The amount of real time,
measured in nanoseconds, is given by:
1000000*timeout+nanos
In all other respects, this method does the same thing as the method of one argument. In particular, wait(0, 0) means the same thing as wait(0).
The current thread must own this object's monitor. The thread releases ownership of this monitor and waits until either of the following two conditions has occurred:
notify
method
or the notifyAll
method.
timeout
milliseconds plus nanos
nanoseconds arguments, has
elapsed.
The thread then waits until it can re-obtain ownership of the monitor and resumes execution.
As in the one argument version, interrupts and spurious wakeups are possible, and this method should always be used in a loop:
synchronized (obj) { while (<condition does not hold>) obj.wait(timeout, nanos); ... // Perform action appropriate to condition }This method should only be called by a thread that is the owner of this object's monitor. See the
notify
method for a
description of the ways in which a thread can become the owner of
a monitor.