|
JSR 216 (Maintenance Release) | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectjava.awt.datatransfer.DataFlavor
Each instance represents the opaque concept of a data format as would appear on a clipboard, during drag and drop, or in a file system.
DataFlavor objects are constant and never change once
instantiated.
| Field Summary | |
static DataFlavor |
plainTextFlavor
Deprecated. as of 1.3. Use DataFlavor.getReaderForText(
Transferable) instead of Transferable.
getTransferData(DataFlavor.plainTextFlavor). |
static DataFlavor |
stringFlavor
The DataFlavor representing a Java Unicode String class,
where:
|
| Constructor Summary | |
DataFlavor()
Constructs a new DataFlavor. |
|
DataFlavor(Class representationClass,
String humanPresentableName)
Constructs a DataFlavor that represents a Java class. |
|
DataFlavor(String mimeType,
String humanPresentableName)
Constructs a DataFlavor that represents a
MimeType. |
|
| Method Summary | |
Object |
clone()
Returns a clone of this DataFlavor. |
boolean |
equals(DataFlavor that)
Tests a DataFlavor to this DataFlavor for
equality. |
boolean |
equals(Object o)
Tests an arbitrary Object to this DataFlavor
for equality. |
String |
getHumanPresentableName()
Returns the human presentable name for the data format that this DataFlavor represents. |
String |
getMimeType()
Returns the MIME type string for this DataFlavor. |
String |
getPrimaryType()
Returns the primary MIME type for this DataFlavor. |
Class |
getRepresentationClass()
Returns the Class which objects supporting this
DataFlavor will return when this DataFlavor
is requested. |
String |
getSubType()
Returns the sub MIME type of this DataFlavor. |
int |
hashCode()
Returns hash code for this DataFlavor. |
boolean |
isMimeTypeEqual(DataFlavor dataFlavor)
Compares the mimeType of two DataFlavor
objects. |
boolean |
isMimeTypeEqual(String mimeType)
Returns whether the string representation of the MIME type passed in is equivalent to the MIME type of this DataFlavor. |
boolean |
match(DataFlavor that)
Tests a DataFlavor to this DataFlavor for
equality. |
protected String |
normalizeMimeType(String mimeType)
Deprecated. |
protected String |
normalizeMimeTypeParameter(String parameterName,
String parameterValue)
Deprecated. |
void |
readExternal(ObjectInput is)
Restores this DataFlavor from a Serialized state. |
void |
setHumanPresentableName(String humanPresentableName)
Sets the human presentable name for the data format that this DataFlavor represents. |
String |
toString()
String representation of this DataFlavor and its
parameters. |
void |
writeExternal(ObjectOutput os)
Serializes this DataFlavor. |
| Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
public static final DataFlavor stringFlavor
DataFlavor representing a Java Unicode String class,
where:
representationClass = java.lang.String
mimeType = "application/x-java-serialized-object"
public static final DataFlavor plainTextFlavor
DataFlavor.getReaderForText(
Transferable) instead of Transferable.
getTransferData(DataFlavor.plainTextFlavor).
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.
| Constructor Detail |
public DataFlavor()
DataFlavor. This constructor is
provided only for the purpose of supporting the
Externalizable interface. It is not
intended for public (client) use.
public DataFlavor(Class representationClass,
String humanPresentableName)
DataFlavor that represents a Java class.
The returned DataFlavor will have the following
characteristics:
representationClass = representationClass
mimeType = application/x-java-serialized-object
representationClass - the class used to transfer data in this flavorhumanPresentableName - the human-readable string used to identify
this flavor; if this parameter is null
then the value of the the MIME Content Type is used
NullPointerException - if representationClass is null
public DataFlavor(String mimeType,
String humanPresentableName)
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
mimeType - the string used to identify the MIME type for this flavor;
if the the mimeType does not specify a
"class=" parameter, or if the class is not successfully
loaded, then an IllegalArgumentException
is thrownhumanPresentableName - the human-readable string used to identify
this flavor; if this parameter is null
then the value of the the MIME Content Type is used
IllegalArgumentException - if mimeType is
invalid or if the class is not successfully loaded
NullPointerException - if mimeType is null| Method Detail |
public String toString()
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.
toString in class ObjectDataFlavorpublic String getMimeType()
DataFlavor.
public Class getRepresentationClass()
Class which objects supporting this
DataFlavor will return when this DataFlavor
is requested.
Class which objects supporting this
DataFlavor will return when this DataFlavor
is requestedpublic String getHumanPresentableName()
DataFlavor represents. This name would be localized
for different countries.
DataFlavor representspublic String getPrimaryType()
DataFlavor.
DataFlavorpublic String getSubType()
DataFlavor.
DataFlavorpublic void setHumanPresentableName(String humanPresentableName)
DataFlavor represents. This name would be localized
for different countries.
humanPresentableName - the new human presentable namepublic boolean equals(Object o)
Object to this DataFlavor
for equality. Two DataFlavors 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, or
[C, the charset parameter must also be equal.
If a charset is not explicitly specified for one or both
DataFlavors, the platform default encoding is assumed.
equals in class Objecto - the Object to compare with this
true if that is equivalent to this
DataFlavor; false otherwiseObject.hashCode(),
Hashtablepublic boolean equals(DataFlavor that)
DataFlavor to this DataFlavor for
equality. Two DataFlavors 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, or
[C, the charset parameter must also be equal.
If a charset is not explicitly specified for one or both
DataFlavors, the platform default encoding is assumed.
that - the DataFlavor to compare with
this
true if that is equivalent to this
DataFlavor; false otherwisepublic int hashCode()
DataFlavor.
For two equal DataFlavors, 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.
hashCode in class ObjectDataFlavorObject.equals(java.lang.Object),
Hashtablepublic boolean match(DataFlavor that)
DataFlavor to this DataFlavor for
equality. Two DataFlavors 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, or
[C, the charset parameter must also be equal.
If a charset is not explicitly specified for one or both
DataFlavors, the platform default encoding is assumed.
that - the DataFlavor to compare with
this
true if that is equivalent to this
DataFlavor; false otherwisepublic boolean isMimeTypeEqual(String mimeType)
DataFlavor.
Parameters are not included in the comparison.
mimeType - the string representation of the MIME type
DataFlavor;
false otherwise
NullPointerException - if mimeType is nullpublic final boolean isMimeTypeEqual(DataFlavor dataFlavor)
mimeType of two DataFlavor
objects. No parameters are considered.
dataFlavor - the DataFlavor to be compared
MimeTypes are equal,
otherwise false
public void writeExternal(ObjectOutput os)
throws IOException
DataFlavor.
writeExternal in interface Externalizableos - the stream to write the object to
IOException - Includes any I/O exceptions that may occur
public void readExternal(ObjectInput is)
throws IOException,
ClassNotFoundException
DataFlavor from a Serialized state.
readExternal in interface Externalizableis - the stream to read data from in order to restore the object
ClassNotFoundException - If the class for an object being
restored cannot be found.
IOException - if I/O errors occur
public Object clone()
throws CloneNotSupportedException
DataFlavor.
clone in class ObjectDataFlavor
CloneNotSupportedException - if the object's class does not
support the Cloneable interface. Subclasses
that override the clone method can also
throw this exception to indicate that an instance cannot
be cloned.Cloneable
protected String normalizeMimeTypeParameter(String parameterName,
String parameterValue)
DataFlavor for every MIME Type parameter
to allow DataFlavor subclasses to handle special
parameters like the text/plain charset
parameters, whose values are case insensitive. (MIME type parameter
values are supposed to be case sensitive.
This method is called for each parameter name/value pair and should
return the normalized representation of the parameterValue.
This method is never invoked by this implementation from 1.1 onwards.
protected String normalizeMimeType(String mimeType)
DataFlavor subtypes
the opportunity to change how the normalization of MIME types is
accomplished. One possible use would be to add default
parameter/value pairs in cases where none are present in the MIME
type string passed in.
This method is never invoked by this implementation from 1.1 onwards.
|
JSR 216 (Maintenance Release) | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||