Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
java.awt.datatransfer.DataFlavor
Field Summary | |
static DataFlavor |
|
static DataFlavor |
|
static String |
|
static String |
|
static String |
|
static DataFlavor |
|
static DataFlavor |
|
Constructor Summary | |
| |
| |
| |
| |
|
Method Summary | |
Object |
|
boolean |
|
boolean | |
boolean | |
Class |
|
String |
|
String |
|
String |
|
String |
|
String |
|
Reader |
|
Class |
|
String |
|
static DataFlavor |
|
int |
|
boolean |
|
boolean |
|
boolean |
|
boolean |
|
boolean |
|
boolean |
|
boolean |
|
boolean |
|
boolean |
|
boolean |
|
boolean |
|
boolean |
|
boolean |
|
boolean |
|
protected String |
|
protected String |
|
void |
|
static DataFlavor |
|
void |
|
String |
|
protected static Class |
|
void |
|
Methods inherited from class java.lang.Object | |
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
public static final DataFlavor imageFlavor
This is an image flavor used for transferring images. The representation type is ajava.awt.Image
.
public static final DataFlavor javaFileListFlavor
This is a data flavor used for transferring lists of files. The representation type is ajava.util.List
, with each element of the list being ajava.io.File
.
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.
- Field Value:
- "application/x-java-jvm-local-objectref"
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.
- Field Value:
- "application/x-java-remote-object"
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.
- Field Value:
- "application/x-java-serialized-object"
public static final DataFlavor plainTextFlavor
Deprecated. The charset unicode is platform specific and InputStream deals with bytes not chars. Use
getRederForText()
.This is the data flavor used for tranferring plain text. The MIME type is "text/plain; charset=unicode". The representation class isjava.io.InputStream
.
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 isjava.lang.String
.
public DataFlavor()
Empty public constructor needed for externalization. Should not be used for normal instantiation.
public DataFlavor(Class representationClass, String humanPresentableName)
Initializes a new instance ofDataFlavor
. 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:
representationClass
- The representation class for this object.humanPresentableName
- The display name of the object.
public DataFlavor(String mimeType) throws ClassNotFoundException
Initializes a new instance ofDataFlavor
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 bejava.io.InputStream
. This is the same as callingnew DataFlavor(mimeType, null)
.
- Parameters:
mimeType
- The MIME type for this flavor.
- Throws:
IllegalArgumentException
- If a class is not specified in the MIME type.ClassNotFoundException
- If the class cannot be loaded.
public DataFlavor(String mimeType, String humanPresentableName)
Initializes a new instance ofDataFlavor
with the specified MIME type and description. If the MIME type has a "class=<rep class>" parameter then the representation class will be the class name specified. Otherwise the class defaults tojava.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 callingnew DataFlavor(mimeType, humanPresentableName, null)
.
- Parameters:
mimeType
- The MIME type for this flavor.humanPresentableName
- The display name of this flavor.
- Throws:
IllegalArgumentException
- If the representation class specified cannot be loaded.
public DataFlavor(String mimeType, String humanPresentableName, ClassLoader classLoader) throws ClassNotFoundException
Initializes a new instance ofDataFlavor
with the specified MIME type and description. If the MIME type has a "class=<rep class>" parameter then the representation class will be the class name specified. Otherwise the class defaults tojava.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:
mimeType
- The MIME type for this flavor.humanPresentableName
- The display name of this flavor.classLoader
- The class loader for finding classes if the default class loaders do not work.
- Throws:
IllegalArgumentException
- If the representation class specified cannot be loaded.ClassNotFoundException
- If the class is not loaded.
public Object clone() throws CloneNotSupportedException
Returns a copy of this object.
- Returns:
- A copy of this object.
- Throws:
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.
public boolean equals(DataFlavor flavor)
This method test the specifiedDataFlavor
for equality against this object. This will be true if the MIME type and representation class are the equal. If the primary type is 'text' then also the value of the charset parameter is compared. In such a case when the charset parameter isn't given then the charset is assumed to be equal to the default charset of the platform. All other parameters are ignored.
- Parameters:
flavor
- TheDataFlavor
to test against.
- Returns:
true
if the flavor is equal to this object,false
otherwise.
public boolean equals(Object obj)
This method test the specifiedObject
for equality against this object. This will be true if the following conditions are met:
- The object is not
null
.- The object is an instance of
DataFlavor
.- The object's MIME type and representation class are equal to this object's.
- Parameters:
obj
- TheObject
to test against.
- Returns:
true
if the flavor is equal to this object,false
otherwise.
public boolean equals(String str)
Deprecated. Not compatible with
hashCode()
. UseisMimeTypeEqual()
Tests whether or not the specified string is equal to the MIME type of this object.
- Parameters:
str
- The string to test against.
- Returns:
true
if the string is equal to this object's MIME type,false
otherwise.
public final Class getDefaultRepresentationClass()
XXX - Currently returnsjava.io.InputStream
.
- Since:
- 1.3
public final String getDefaultRepresentationClassAsString()
XXX - Currently returnsjava.io.InputStream
.
public String getHumanPresentableName()
Returns the human presentable name for this flavor.
- Returns:
- The human presentable name for this flavor.
public String getMimeType()
Returns the MIME type of this flavor.
- Returns:
- The MIME type for this flavor.
public String getParameter(String paramName)
Returns the value of the named MIME type parameter, ornull
if the parameter does not exist.
- Parameters:
paramName
- The name of the paramter.
- Returns:
- The value of the parameter.
public String getPrimaryType()
Returns the primary MIME type for this flavor.
- Returns:
- The primary MIME type for this flavor.
public Reader getReaderForText(Transferable transferable) throws UnsupportedFlavorException, IOException
Creates aReader
for a givenTransferable
. If the representation class is a (subclass of)Reader
then an instance of the representation class is returned. If the representatation class is aString
then aStringReader
is returned. And if the representation class is a (subclass of)InputStream
and the primary MIME type is "text" then aInputStreamReader
for the correct charset encoding is returned.
- Parameters:
transferable
- TheTransferable
for which a textReader
is requested.
- Throws:
IllegalArgumentException
- If the representation class is not one of the seven listed above or the Transferable has null data.NullPointerException
- If the Transferable is null.UnsupportedFlavorException
- when the transferable doesn't support thisDataFlavor
. Or if the representable class isn't a (subclass of)Reader
,String
,InputStream
and/or the primary MIME type isn't "text".IOException
- when any IOException occurs.
public Class getRepresentationClass()
Returns the representation class for this flavor.
- Returns:
- The representation class for this flavor.
public String getSubType()
Returns the MIME subtype for this flavor.
- Returns:
- The MIME subtype for this flavor.
public static final DataFlavor getTextPlainUnicodeFlavor()
XXX - Currently returnsplainTextFlavor
.
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.
public boolean isFlavorJavaFileListType()
Tests whether or not this flavor represents a list of files.
- Returns:
true
if this flavor represents a list of files,false
otherwise.
public boolean isFlavorRemoteObjectType()
Tests whether or not this flavor represents a remote object.
- Returns:
true
if this flavor represents a remote object,false
otherwise.
public boolean isFlavorSerializedObjectType()
Tests whether or not this flavor represents a serialized object.
- Returns:
true
if this flavor represents a serialized object,false
otherwise.
public boolean isFlavorTextType()
Returns whether thisDataFlavor
is a valid text flavor for this implementation of the Java platform. Only flavors equivalent toDataFlavor.stringFlavor
andDataFlavor
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 bejava.io.Reader
,java.lang.String
,java.nio.CharBuffer
,java.io.InputStream
orjava.nio.ByteBuffer
, If the representation isjava.io.InputStream
orjava.nio.ByteBuffer
, then this flavor'scharset
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
.See
selectBestTextFlavor
for a list of text flavors which support the charset parameter.
- Returns:
true
if thisDataFlavor
is a valid text flavor as described above;false
otherwise
- Since:
- 1.4
- See Also:
selectBestTextFlavor(DataFlavor[])
public final boolean isMimeTypeEqual(DataFlavor flavor)
Tests the MIME type of this object for equality against the specified data flavor's MIME type
- Parameters:
flavor
- The flavor to test against.
- Returns:
true
if the flavor's MIME type is equal to this object's MIME type,false
otherwise.
public boolean isMimeTypeEqual(String mimeType)
Tests the MIME type of this object for equality against the specified MIME type. Ignores parameters.
- Parameters:
mimeType
- The MIME type to test against.
- Returns:
true
if the MIME type is equal to this object's MIME type (ignoring parameters),false
otherwise.
- Throws:
NullPointerException
- If mimeType is null.
public boolean isMimeTypeSerializedObject()
Tests whether or not this flavor represents a serialized object.
- Returns:
true
if this flavor represents a serialized object,false
otherwise.
public boolean isRepresentationClassByteBuffer()
Returns whether the representation class for this DataFlavor is
- Since:
- 1.4
- See Also:
or a subclass thereof.
public boolean isRepresentationClassCharBuffer()
Returns whether the representation class for this DataFlavor is
- Since:
- 1.4
- See Also:
or a subclass thereof.
public boolean isRepresentationClassInputStream()
Tests whether or not this flavor has a representation class ofjava.io.InputStream
.
- Returns:
true
if the representation class of this flavor isjava.io.InputStream
,false
otherwise.
public boolean isRepresentationClassReader()
Returns whether the representation class for this DataFlavor is
- Since:
- 1.4
- See Also:
or a subclass thereof.
public boolean isRepresentationClassRemote()
Tests whether the representation class for his flavor is remote.
- Returns:
true
if the representation class is remote,false
otherwise.
public boolean isRepresentationClassSerializable()
Tests whether the representation class for this flavor is serializable.
- Returns:
true
if the representation class is serializable,false
otherwise.
public boolean match(DataFlavor dataFlavor)
Returnstrue
when the givenDataFlavor
matches this one.
protected String normalizeMimeType(String type)
Deprecated.
This method exists for backward compatibility. It simply returns the MIME type string unchanged.
- Parameters:
type
- The MIME type.
- Returns:
- The MIME type.
protected String normalizeMimeTypeParameter(String name, String value)
Deprecated.
This method exists for backward compatibility. It simply returns the same name/value pair passed in.
- Parameters:
name
- The parameter name.value
- The parameter value.
- Returns:
- The name/value pair.
public void readExternal(ObjectInput stream) throws IOException, ClassNotFoundException
De-serialize this class.
- Specified by:
- readExternal in interface Externalizable
- Parameters:
stream
- TheObjectInput
stream to deserialize from.
- Throws:
IOException
- If an error ocurs.ClassNotFoundException
- If the class for an object being restored cannot be found.
public static final DataFlavor selectBestTextFlavor(DataFlavor[] availableFlavors)
Selects the best supported text flavor on this implementation. Returnsnull
when none of the given flavors is liked. TheDataFlavor
returned the first data flavor in the array that has either a representation class which is (a subclass of)Reader
orString
, or has a representation class which is (a subclass of)InputStream
and has a primary MIME type of "text" and has an supported encoding.
public void setHumanPresentableName(String humanPresentableName)
Sets the human presentable name to the specified value.
- Parameters:
humanPresentableName
- The new display name.
public String toString()
Returns a string representation of this DataFlavor. Including the representation class name, MIME type and human presentable name.
protected static final Class tryToLoadClass(String className, ClassLoader classLoader) throws ClassNotFoundException
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:
className
- The name of the class to load.classLoader
- The class loader to use if all others fail, which may benull
.
- Throws:
ClassNotFoundException
- If the class cannot be loaded.
public void writeExternal(ObjectOutput stream) throws IOException
Serialize this class.
- Specified by:
- writeExternal in interface Externalizable
- Parameters:
stream
- TheObjectOutput
stream to serialize to.
- Throws:
IOException
- If an error occurs.