|
JSR-62 (Final) | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object | +--java.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)
Construct a DataFlavor that represents a Java class |
|
DataFlavor(String mimeType,
String humanPresentableName)
Construct a DataFlavor that represents a MimeType |
|
| Method Summary | |
Object |
clone()
Creates and returns a copy of this object. |
boolean |
equals(DataFlavor that)
Two DataFlavors are considered equal if and only if their MIME primary type and subtype and representation class are equal. |
boolean |
equals(Object o)
If the object is an instance of DataFlavor, representationClass and MIME type will be compared. |
String |
getHumanPresentableName()
Returns the human presentable name for the data foramt that this DataFlavor represents. |
String |
getMimeType()
Returns the MIME type string for this DataFlavor |
Class |
getRepresentationClass()
Returns the Class which objects supporting this DataFlavor will return when this DataFlavor is requested. |
int |
hashCode()
Returns hash code for this DataFlavor. |
boolean |
isMimeTypeEqual(DataFlavor dataFlavor)
Compare the mimeType of two DataFlavor objects no parameters are considered |
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)
Two DataFlavors match if their primary types, subtypes, and representation classes are all equal. |
protected String |
normalizeMimeType(String mimeType)
Deprecated. |
protected String |
normalizeMimeTypeParameter(String parameterName,
String parameterValue)
Deprecated. |
void |
readExternal(ObjectInput is)
restore this DataFlavor from an 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)
Serialize this DataFlavor |
| Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
public static final DataFlavor stringFlavor
representationClass = java.lang.String
mimeType = "application/x-java-serialized-object"
public static final DataFlavor plainTextFlavor
DataFlavor.getReaderForText(
Transferable) instead of Transferable.
getTransferData(DataFlavor.plainTextFlavor).
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()
public DataFlavor(Class representationClass,
String humanPresentableName)
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.
public DataFlavor(String mimeType,
String humanPresentableName)
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>) as above
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 thrown.humanPresentableName - 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.| Method Detail |
public String toString()
DataFlavor
and its parameters. The result String contains name of
DataFlavor class, representation class
and Mime type of this Flavor.
toString in class ObjectDataFlavorpublic String getMimeType()
public Class getRepresentationClass()
public String getHumanPresentableName()
public void setHumanPresentableName(String humanPresentableName)
public boolean equals(Object o)
true for the objects of String type.
equals in class Objecto - the reference object with which to compare.
Boolean.hashCode(),
Hashtablepublic boolean equals(DataFlavor that)
public 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 ObjectObject.equals(java.lang.Object),
Hashtablepublic boolean match(DataFlavor that)
public boolean isMimeTypeEqual(String mimeType)
DataFlavor.
Parameters are not incuded in the comparison. The comparison may involve
adding default attributes for some MIME types (such as adding
charset=US-ASCII to text/plain MIME types that have
no charset parameter specified).
mimeType - the string representation of the MIME type
DataFlavor;
false otherwise.
NullPointerException - if mimeType is nullpublic final boolean isMimeTypeEqual(DataFlavor dataFlavor)
public void writeExternal(ObjectOutput os)
throws IOException
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
readExternal in interface Externalizableis - the stream to read data from in order to restore the object
IOException - if I/O errors occur
ClassNotFoundException - If the class for an object being
restored cannot be found.
public Object clone()
throws CloneNotSupportedException
Objectwill be true, and that the expression:x.clone() != x
will be true, but these are not absolute requirements. While it is typically the case that:x.clone().getClass() == x.getClass()
will be true, this is not an absolute requirement. Copying an object will typically entail creating a new instance of its class, but it also may require copying of internal data structures as well. No constructors are called.x.clone().equals(x)
The method clone for class Object performs a specific cloning operation. First, if the class of this object does not implement the interface Cloneable, then a CloneNotSupportedException is thrown. Note that all arrays are considered to implement the interface Cloneable. Otherwise, this method creates a new instance of the class of this object and initializes all its fields with exactly the contents of the corresponding fields of this object, as if by assignment; the contents of the fields are not themselves cloned. Thus, this method performs a "shallow copy" of this object, not a "deep copy" operation.
The class Object does not itself implement the interface Cloneable, so calling the clone method on an object whose class is Object will result in throwing an exception at run time. The clone method is implemented by the class Object as a convenient, general utility for subclasses that implement the interface Cloneable, possibly also overriding the clone method, in which case the overriding definition can refer to this utility definition by the call:
super.clone()
clone in class ObjectCloneNotSupportedException - 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)
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)
|
JSR-62 (Final) | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||