Index (Frames) | Index (No Frames) | Package | Package Tree | Tree
java.awt.datatransfer

Class DataFlavor

java.lang.Object
|
+--java.awt.datatransfer.DataFlavor

All Implemented Interfaces:

Externalizable, Cloneable


public class DataFlavor

extends Object

implements Externalizable, Cloneable

This class represents a particular data format used for transferring data via the clipboard.

Author:

Field Summary

static java.awt.datatransfer.DataFlavorimageFlavor

static java.awt.datatransfer.DataFlavorjavaFileListFlavor

This is a data flavor used for transferring lists of files.
static java.lang.StringjavaJVMLocalObjectMimeType

This is the MIME type used to transfer a Java object reference within the same JVM.
static java.lang.StringjavaRemoteObjectMimeType

This is the MIME type used to transfer a link to a remote object.
static java.lang.StringjavaSerializedObjectMimeType

This is the MIME type used for transferring a serialized object.
static java.awt.datatransfer.DataFlavorplainTextFlavor

This is the data flavor used for tranferring plain text.
static java.awt.datatransfer.DataFlavorstringFlavor

This is the data flavor used for transferring Java strings.

Constructor Summary

DataFlavor()

Empty public constructor needed for externalization.
DataFlavor(java.lang.Class representationClass, java.lang.String humanPresentableName)

Initializes a new instance of DataFlavor.
DataFlavor(java.lang.String mimeType, java.lang.String humanPresentableName, java.lang.ClassLoader classLoader)

Initializes a new instance of DataFlavor with the specified MIME type and description.
DataFlavor(java.lang.String mimeType, java.lang.String humanPresentableName)

Initializes a new instance of DataFlavor with the specified MIME type and description.
DataFlavor(java.lang.String mimeType)

Initializes a new instance of DataFlavor with the specified MIME type.

Method Summary

java.lang.Objectclone()

Returns a copy of this object.
booleanequals(java.awt.datatransfer.DataFlavor flavor)

This method test the specified DataFlavor for equality against this object.
booleanequals(java.lang.Object obj)

This method test the specified Object for equality against this object.
booleanequals(java.lang.String str)

Tests whether or not the specified string is equal to the MIME type of this object.
java.lang.ClassgetDefaultRepresentationClass()

XXX - Currently returns java.io.InputStream.
java.lang.StringgetDefaultRepresentationClassAsString()

XXX - Currently returns java.io.InputStream.
java.lang.StringgetHumanPresentableName()

Returns the human presentable name for this flavor.
java.lang.StringgetMimeType()

Returns the MIME type of this flavor.
java.lang.StringgetParameter(java.lang.String paramName)

Returns the value of the named MIME type parameter, or null if the parameter does not exist.
java.lang.StringgetPrimaryType()

Returns the primary MIME type for this flavor.
java.io.ReadergetReaderForText(java.awt.datatransfer.Transferable transferable)

Creates a Reader for a given Transferable.
java.lang.ClassgetRepresentationClass()

Returns the representation class for this flavor.
java.lang.StringgetSubType()

Returns the MIME subtype for this flavor.
static java.awt.datatransfer.DataFlavorgetTextPlainUnicodeFlavor()

XXX - Currently returns plainTextFlavor.
inthashCode()

Returns the hash code for this data flavor.
booleanisFlavorJavaFileListType()

Tests whether or not this flavor represents a list of files.
booleanisFlavorRemoteObjectType()

Tests whether or not this flavor represents a remote object.
booleanisFlavorSerializedObjectType()

Tests whether or not this flavor represents a serialized object.
booleanisMimeTypeEqual(java.lang.String mimeType)

Tests the MIME type of this object for equality against the specified MIME type.
booleanisMimeTypeEqual(java.awt.datatransfer.DataFlavor flavor)

Tests the MIME type of this object for equality against the specified data flavor's MIME type
booleanisMimeTypeSerializedObject()

Tests whether or not this flavor represents a serialized object.
booleanisRepresentationClassByteBuffer()

Returns whether the representation class for this DataFlavor is
booleanisRepresentationClassCharBuffer()

Returns whether the representation class for this DataFlavor is
booleanisRepresentationClassInputStream()

Tests whether or not this flavor has a representation class of java.io.InputStream.
booleanisRepresentationClassReader()

Returns whether the representation class for this DataFlavor is
booleanisRepresentationClassRemote()

Tests whether the representation class for his flavor is remote.
booleanisRepresentationClassSerializable()

Tests whether the representation class for this flavor is serializable.
booleanmatch(java.awt.datatransfer.DataFlavor dataFlavor)

Returns true when the given DataFlavor matches this one.
java.lang.StringnormalizeMimeType(java.lang.String type)

This method exists for backward compatibility.
java.lang.StringnormalizeMimeTypeParameter(java.lang.String name, java.lang.String value)

This method exists for backward compatibility.
voidreadExternal(java.io.ObjectInput stream)

De-serialize this class.
static java.awt.datatransfer.DataFlavorselectBestTextFlavor(java.awt.datatransfer.DataFlavor availableFlavors)

Selects the best supported text flavor on this implementation.
voidsetHumanPresentableName(java.lang.String humanPresentableName)

Sets the human presentable name to the specified value.
java.lang.StringtoString()

Returns a string representation of this DataFlavor.
static java.lang.ClasstryToLoadClass(java.lang.String className, java.lang.ClassLoader classLoader)

This method attempts to load the named class.
voidwriteExternal(java.io.ObjectOutput stream)

Serialize this class.

Field Details

imageFlavor

public static final DataFlavor imageFlavor


javaFileListFlavor

public static final DataFlavor javaFileListFlavor

This is a data flavor used for transferring lists of files. The representation type is a java.util.List, with each element of the list being a java.io.File.


javaJVMLocalObjectMimeType

public static final String javaJVMLocalObjectMimeType

This is the MIME type used to transfer a Java object reference within the same JVM. The representation class is the class of the object being transferred.


javaRemoteObjectMimeType

public static final String javaRemoteObjectMimeType

This is the MIME type used to transfer a link to a remote object. The representation class is the type of object being linked to.


javaSerializedObjectMimeType

public static final String javaSerializedObjectMimeType

This is the MIME type used for transferring a serialized object. The representation class is the type of object be deserialized.


plainTextFlavor

public static final DataFlavor plainTextFlavor

This is the data flavor used for tranferring plain text. The MIME type is "text/plain; charset=unicode". The representation class is java.io.InputStream.


stringFlavor

public static final DataFlavor stringFlavor

This is the data flavor used for transferring Java strings. The MIME type is "application/x-java-serialized-object" and the representation class is java.lang.String.


Constructor Details

DataFlavor

public DataFlavor()

Empty public constructor needed for externalization. Should not be used for normal instantiation.


DataFlavor

public DataFlavor(java.lang.Class representationClass, java.lang.String humanPresentableName)

Initializes a new instance of DataFlavor. The class and human readable name are specified, the MIME type will be "application/x-java-serialized-object". If the human readable name is not specified (null) then the human readable name will be the same as the MIME type.

Parameters:


DataFlavor

public DataFlavor(java.lang.String mimeType)

Initializes a new instance of DataFlavor with the specified MIME type. This type can have a "class=" parameter to specify the representation class, and then the class must exist or an exception will be thrown. If there is no "class=" parameter then the representation class will be java.io.InputStream. This is the same as calling new DataFlavor(mimeType, null).

Parameters:

Throws:


DataFlavor

public DataFlavor(java.lang.String mimeType, java.lang.String humanPresentableName)

Initializes a new instance of DataFlavor with the specified MIME type and description. If the MIME type has a "class=" parameter then the representation class will be the class name specified. Otherwise the class defaults to java.io.InputStream. If the human readable name is not specified (null) then the human readable name will be the same as the MIME type. This is the same as calling new DataFlavor(mimeType, humanPresentableName, null).

Parameters:

Throws:


DataFlavor

public DataFlavor(java.lang.String mimeType, java.lang.String humanPresentableName, java.lang.ClassLoader classLoader)

Initializes a new instance of DataFlavor with the specified MIME type and description. If the MIME type has a "class=" parameter then the representation class will be the class name specified. Otherwise the class defaults to java.io.InputStream. If the human readable name is not specified (null) then the human readable name will be the same as the MIME type.

Parameters:

Throws:


Method Details

clone

public Object clone()

Returns a copy of this object.

Returns:

Throws:


equals

public boolean equals(java.awt.datatransfer.DataFlavor flavor)

This method test the specified DataFlavor for equality against this object. This will be true if the MIME type and representation type are the equal.

Parameters:

Returns:


equals

public boolean equals(java.lang.Object obj)

This method test the specified Object for equality against this object. This will be true if the following conditions are met:

Parameters:

Returns:


equals

public boolean equals(java.lang.String str)

Tests whether or not the specified string is equal to the MIME type of this object.

Parameters:

Returns:


getDefaultRepresentationClass

public final Class getDefaultRepresentationClass()

XXX - Currently returns java.io.InputStream.

Since:

getDefaultRepresentationClassAsString

public final String getDefaultRepresentationClassAsString()

XXX - Currently returns java.io.InputStream.


getHumanPresentableName

public String getHumanPresentableName()

Returns the human presentable name for this flavor.

Returns:


getMimeType

public String getMimeType()

Returns the MIME type of this flavor.

Returns:


getParameter

public String getParameter(java.lang.String paramName)

Returns the value of the named MIME type parameter, or null if the parameter does not exist.

Parameters:

Returns:


getPrimaryType

public String getPrimaryType()

Returns the primary MIME type for this flavor.

Returns:


getReaderForText

public Reader getReaderForText(java.awt.datatransfer.Transferable transferable)

Creates a Reader for a given Transferable. If the representation class is a (subclass of) Reader then an instance of the representation class is returned. If the representatation class is a String then a StringReader is returned. And if the representation class is a (subclass of) InputStream and the primary MIME type is "text" then a InputStreamReader for the correct charset encoding is returned.

Parameters:

Throws:


getRepresentationClass

public Class getRepresentationClass()

Returns the representation class for this flavor.

Returns:


getSubType

public String getSubType()

Returns the MIME subtype for this flavor.

Returns:


getTextPlainUnicodeFlavor

public static final DataFlavor getTextPlainUnicodeFlavor()

XXX - Currently returns plainTextFlavor.


hashCode

public int hashCode()

Returns the hash code for this data flavor. The hash code is based on the (lower case) mime type and the representation class.


isFlavorJavaFileListType

public boolean isFlavorJavaFileListType()

Tests whether or not this flavor represents a list of files.

Returns:


isFlavorRemoteObjectType

public boolean isFlavorRemoteObjectType()

Tests whether or not this flavor represents a remote object.

Returns:


isFlavorSerializedObjectType

public boolean isFlavorSerializedObjectType()

Tests whether or not this flavor represents a serialized object.

Returns:


isMimeTypeEqual

public boolean isMimeTypeEqual(java.awt.datatransfer.DataFlavor flavor)

Tests the MIME type of this object for equality against the specified data flavor's MIME type

Parameters:

Returns:


isMimeTypeEqual

public boolean isMimeTypeEqual(java.lang.String mimeType)

Tests the MIME type of this object for equality against the specified MIME type.

Parameters:

Returns:

Throws:


isMimeTypeSerializedObject

public boolean isMimeTypeSerializedObject()

Tests whether or not this flavor represents a serialized object.

Returns:


isRepresentationClassByteBuffer

public boolean isRepresentationClassByteBuffer()

Returns whether the representation class for this DataFlavor is

Since:See Also:


isRepresentationClassCharBuffer

public boolean isRepresentationClassCharBuffer()

Returns whether the representation class for this DataFlavor is

Since:See Also:


isRepresentationClassInputStream

public boolean isRepresentationClassInputStream()

Tests whether or not this flavor has a representation class of java.io.InputStream.


isRepresentationClassReader

public boolean isRepresentationClassReader()

Returns whether the representation class for this DataFlavor is

Since:See Also:


isRepresentationClassRemote

public boolean isRepresentationClassRemote()

Tests whether the representation class for his flavor is remote.

Returns:


isRepresentationClassSerializable

public boolean isRepresentationClassSerializable()

Tests whether the representation class for this flavor is serializable.


match

public boolean match(java.awt.datatransfer.DataFlavor dataFlavor)

Returns true when the given DataFlavor matches this one.

Parameters:


normalizeMimeType

protected String normalizeMimeType(java.lang.String type)

This method exists for backward compatibility. It simply returns the MIME type string unchanged.

Parameters:

Returns:


normalizeMimeTypeParameter

protected String normalizeMimeTypeParameter(java.lang.String name, java.lang.String value)

This method exists for backward compatibility. It simply returns the same name/value pair passed in.

Parameters:

Returns:


readExternal

public void readExternal(java.io.ObjectInput stream)

De-serialize this class.

Parameters:

Throws:


selectBestTextFlavor

public static final DataFlavor selectBestTextFlavor(java.awt.datatransfer.DataFlavor availableFlavors)

Selects the best supported text flavor on this implementation. Returns null when none of the given flavors is liked. The DataFlavor returned the first data flavor in the array that has either a representation class which is (a subclass of) Reader or String, or has a representation class which is (a subclass of) InputStream and has a primary MIME type of "text" and has an supported encoding.

Parameters:


setHumanPresentableName

public void setHumanPresentableName(java.lang.String humanPresentableName)

Sets the human presentable name to the specified value.

Parameters:


toString

public String toString()

Returns a string representation of this DataFlavor. Including the representation class name, MIME type and human presentable name.


tryToLoadClass

protected static final Class tryToLoadClass(java.lang.String className, java.lang.ClassLoader classLoader)

This method attempts to load the named class. The following class loaders are searched in order: the bootstrap class loader, the system class loader, the context class loader (if it exists), and the specified fallback class loader.

Parameters:

Throws:


writeExternal

public void writeExternal(java.io.ObjectOutput stream)

Serialize this class.

Parameters:

Throws: