Java Doc for DataFlavor.java in  » 6.0-JDK-Core » AWT » java » awt » datatransfer » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Home
Java Source Code / Java Documentation
1.6.0 JDK Core
2.6.0 JDK Modules
3.6.0 JDK Modules com.sun
4.6.0 JDK Modules com.sun.java
5.6.0 JDK Modules sun
6.6.0 JDK Platform
7.Ajax
8.Apache Harmony Java SE
9.Aspect oriented
10.Authentication Authorization
11.Blogger System
12.Build
13.Byte Code
14.Cache
15.Chart
16.Chat
17.Code Analyzer
18.Collaboration
19.Content Management System
20.Database Client
21.Database DBMS
22.Database JDBC Connection Pool
23.Database ORM
24.Development
25.EJB Server
26.ERP CRM Financial
27.ESB
28.Forum
29.Game
30.GIS
31.Graphic 3D
32.Graphic Library
33.Groupware
34.HTML Parser
35.IDE
36.IDE Eclipse
37.IDE Netbeans
38.Installer
39.Internationalization Localization
40.Inversion of Control
41.Issue Tracking
42.J2EE
43.J2ME
44.JBoss
45.JMS
46.JMX
47.Library
48.Mail Clients
49.Music
50.Net
51.Parser
52.PDF
53.Portal
54.Profiler
55.Project Management
56.Report
57.RSS RDF
58.Rule Engine
59.Science
60.Scripting
61.Search Engine
62.Security
63.Sevlet Container
64.Source Control
65.Swing Library
66.Template Engine
67.Test Coverage
68.Testing
69.UML
70.Web Crawler
71.Web Framework
72.Web Mail
73.Web Server
74.Web Services
75.Web Services apache cxf 2.2.6
76.Web Services AXIS2
77.Wiki Engine
78.Workflow Engines
79.XML
80.XML UI
Java Source Code / Java Documentation » 6.0 JDK Core » AWT » java.awt.datatransfer 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   java.awt.datatransfer.DataFlavor

DataFlavor
public class DataFlavor implements Externalizable,Cloneable(Code)
A DataFlavor provides meta information about data. DataFlavor is typically used to access data on the clipboard, or during a drag and drop operation.

An instance of DataFlavor encapsulates a content type as defined in RFC 2045 and RFC 2046. A content type is typically referred to as a MIME type.

A content type consists of a media type (referred to as the primary type), a subtype, and optional parameters. See RFC 2045 for details on the syntax of a MIME type.

The JRE data transfer implementation interprets the parameter "class" of a MIME type as a representation class. The representation class reflects the class of the object being transferred. In other words, the representation class is the type of object returned by Transferable.getTransferData . For example, the MIME type of DataFlavor.imageFlavor is "image/x-java-image;class=java.awt.Image" , the primary type is image , the subtype is x-java-image , and the representation class is java.awt.Image . When getTransferData is invoked with a DataFlavor of imageFlavor , an instance of java.awt.Image is returned. It's important to note that DataFlavor does no error checking against the representation class. It is up to consumers of DataFlavor , such as Transferable , to honor the representation class.
Note, if you do not specify a representation class when creating a DataFlavor , the default representation class is used. See appropriate documentation for DataFlavor 's constructors.

Also, DataFlavor instances with the "text" primary MIME type may have a "charset" parameter. Refer to RFC 2046 and DataFlavor.selectBestTextFlavor for details on "text" MIME types and the "charset" parameter.

Equality of DataFlavors is determined by the primary type, subtype, and representation class. Refer to DataFlavor.equals(DataFlavor) for details. When determining equality, any optional parameters are ignored. For example, the following produces two DataFlavors that are considered identical:

 DataFlavor flavor1 = new DataFlavor(Object.class, "X-test/test; class=<java.lang.Object>; foo=bar");
 DataFlavor flavor2 = new DataFlavor(Object.class, "X-test/test; class=<java.lang.Object>; x=y");
 // The following returns true.
 flavor1.equals(flavor2);
 
As mentioned, flavor1 and flavor2 are considered identical. As such, asking a Transferable for either DataFlavor returns the same results.

For more information on the using data transfer with Swing see the How to Use Drag and Drop and Data Transfer, section in Java Tutorial.
version:
   1.90, 05/05/07
author:
   Blake Sullivan
author:
   Laurence P. G. Cable
author:
   Jeff Dunn


Inner Class :static class TextFlavorComparator extends DataTransferer.DataFlavorComparator

Field Summary
transient  intatom
    
final public static  DataFlavorimageFlavor
    
final public static  DataFlavorjavaFileListFlavor
     To transfer a list of files to/from Java (and the underlying platform) a DataFlavor of this type/subtype and representation class of java.util.List is used.
final public static  StringjavaJVMLocalObjectMimeType
     To transfer a reference to an arbitrary Java object reference that has no associated MIME Content-type, across a 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.
final public static  StringjavaRemoteObjectMimeType
     In order to pass a live link to a Remote object via a Drag and Drop 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.
final public static  StringjavaSerializedObjectMimeType
     A MIME Content-Type of application/x-java-serialized-object represents a graph of Java object(s) that have been made persistent.
 MimeTypemimeType
    
final public static  DataFlavorplainTextFlavor
     The 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.
final public static  DataFlavorstringFlavor
    

Constructor Summary
public  DataFlavor()
     Constructs a new DataFlavor.
public  DataFlavor(Class representationClass, String humanPresentableName)
     Constructs a DataFlavor that represents a Java class.
public  DataFlavor(String mimeType, String humanPresentableName)
     Constructs a DataFlavor that represents a MimeType.
public  DataFlavor(String mimeType, String humanPresentableName, ClassLoader classLoader)
     Constructs a DataFlavor that represents a MimeType.
public  DataFlavor(String mimeType)
     Constructs a DataFlavor from a mimeType string. The string can specify a "class=" parameter to create a DataFlavor with the desired representation class.

Method Summary
public  Objectclone()
     Returns a clone of this DataFlavor.
public  booleanequals(Object o)
    

The equals comparison for the DataFlavor class is implemented as follows: Two DataFlavors are considered equal if and only if their MIME primary type and subtype and representation class are equal.

public  booleanequals(DataFlavor that)
     This method has the same behavior as DataFlavor.equals(Object) .
public  booleanequals(String s)
     Compares only the 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.
Parameters:
  s - the mimeType to compare.
final public  ClassgetDefaultRepresentationClass()
    
final public  StringgetDefaultRepresentationClassAsString()
    
public  StringgetHumanPresentableName()
     Returns the human presentable name for the data format that this DataFlavor represents.
public  StringgetMimeType()
     Returns the MIME type string for this DataFlavor.
public  StringgetParameter(String paramName)
     Returns the human presentable name for this DataFlavor if paramName equals "humanPresentableName".
public  StringgetPrimaryType()
     Returns the primary MIME type for this DataFlavor.
public  ReadergetReaderForText(Transferable transferable)
     Gets a Reader for a text flavor, decoded, if necessary, for the expected charset (encoding).
public  ClassgetRepresentationClass()
     Returns the Class which objects supporting this DataFlavor will return when this DataFlavor is requested.
public  StringgetSubType()
     Returns the sub MIME type of this DataFlavor.
final public static  DataFlavorgetTextPlainUnicodeFlavor()
     Returns a 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.
public  inthashCode()
     Returns hash code for this DataFlavor.
public  booleanisFlavorJavaFileListType()
     Returns true if the DataFlavor specified represents a list of file objects.
public  booleanisFlavorRemoteObjectType()
     Returns true if the DataFlavor specified represents a remote object.
public  booleanisFlavorSerializedObjectType()
     Returns true if the DataFlavor specified represents a serialized object.
public  booleanisFlavorTextType()
     Returns whether this DataFlavor is a valid text flavor for this implementation of the Java platform.
public  booleanisMimeTypeEqual(String mimeType)
     Returns whether the string representation of the MIME type passed in is equivalent to the MIME type of this DataFlavor.
final public  booleanisMimeTypeEqual(DataFlavor dataFlavor)
     Compares the mimeType of two DataFlavor objects.
public  booleanisMimeTypeSerializedObject()
    
public  booleanisRepresentationClassByteBuffer()
     Returns whether the representation class for this DataFlavor is java.nio.ByteBuffer or a subclass thereof.
public  booleanisRepresentationClassCharBuffer()
     Returns whether the representation class for this DataFlavor is java.nio.CharBuffer or a subclass thereof.
public  booleanisRepresentationClassInputStream()
    
public  booleanisRepresentationClassReader()
     Returns whether the representation class for this DataFlavor is java.io.Reader or a subclass thereof.
public  booleanisRepresentationClassRemote()
     Returns true if the representation class is Remote.
public  booleanisRepresentationClassSerializable()
     Returns true if the representation class can be serialized.
public  booleanmatch(DataFlavor that)
     Identical to DataFlavor.equals(DataFlavor) .
protected  StringnormalizeMimeType(String mimeType)
     Called for each MIME type string to give DataFlavor subtypes the opportunity to change how the normalization of MIME types is accomplished.
protected  StringnormalizeMimeTypeParameter(String parameterName, String parameterValue)
     Called on 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.
public synchronized  voidreadExternal(ObjectInput is)
     Restores this DataFlavor from a Serialized state.
final public static  DataFlavorselectBestTextFlavor(DataFlavor[] availableFlavors)
     Selects the best text DataFlavor from an array of DataFlavors.
public  voidsetHumanPresentableName(String humanPresentableName)
     Sets the human presentable name for the data format that this DataFlavor represents.
public  StringtoString()
     String representation of this DataFlavor and its parameters.
final protected static  ClasstryToLoadClass(String className, ClassLoader fallback)
     Tries to load a class from: the bootstrap loader, the system loader, the context loader (if one is present) and finally the loader specified.
public synchronized  voidwriteExternal(ObjectOutput os)
     Serializes this DataFlavor.

Field Detail
atom
transient int atom(Code)



imageFlavor
final public static DataFlavor imageFlavor(Code)
The DataFlavor representing a Java Image class, where:
 representationClass = java.awt.Image
 mimeType            = "image/x-java-image"
 



javaFileListFlavor
final public static DataFlavor javaFileListFlavor(Code)
To transfer a list of files to/from Java (and the underlying platform) a 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.



javaJVMLocalObjectMimeType
final public static String javaJVMLocalObjectMimeType(Code)
To transfer a reference to an arbitrary Java object reference that has no associated MIME Content-type, across a 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.




javaRemoteObjectMimeType
final public static String javaRemoteObjectMimeType(Code)
In order to pass a live link to a Remote object via a Drag and Drop 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.



javaSerializedObjectMimeType
final public static String javaSerializedObjectMimeType(Code)
A MIME Content-Type of application/x-java-serialized-object represents a graph of Java object(s) that have been made persistent. The representation class associated with this DataFlavor identifies the Java type of an object returned as a reference from an invocation java.awt.datatransfer.getTransferData.



mimeType
MimeType mimeType(Code)



plainTextFlavor
final public static DataFlavor plainTextFlavor(Code)
The 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.



stringFlavor
final public static DataFlavor stringFlavor(Code)
The DataFlavor representing a Java Unicode String class, where:
 representationClass = java.lang.String
 mimeType           = "application/x-java-serialized-object"        
 




Constructor Detail
DataFlavor
public DataFlavor()(Code)
Constructs a new DataFlavor. This constructor is provided only for the purpose of supporting the Externalizable interface. It is not intended for public (client) use.
since:
   1.2



DataFlavor
public DataFlavor(Class representationClass, String humanPresentableName)(Code)
Constructs a DataFlavor that represents a Java class.

The returned DataFlavor will have the following characteristics:

 representationClass = representationClass
 mimeType            = application/x-java-serialized-object        
 

Parameters:
  representationClass - the class used to transfer data in this flavor
Parameters:
  humanPresentableName - the human-readable string used to identify this flavor; if this parameter is nullthen the value of the the MIME Content Type is used
exception:
  NullPointerException - if representationClass is null



DataFlavor
public DataFlavor(String mimeType, String humanPresentableName)(Code)
Constructs a 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         
 

Parameters:
  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 successfullyloaded, then an IllegalArgumentExceptionis thrown
Parameters:
  humanPresentableName - the human-readable string used to identify this flavor; if this parameter is nullthen the value of the the MIME Content Type is used
exception:
  IllegalArgumentException - if mimeType isinvalid or if the class is not successfully loaded
exception:
  NullPointerException - if mimeType is null



DataFlavor
public DataFlavor(String mimeType, String humanPresentableName, ClassLoader classLoader) throws ClassNotFoundException(Code)
Constructs a 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         
 

Parameters:
  mimeType - the string used to identify the MIME type for this flavor
Parameters:
  humanPresentableName - the human-readable string used to identify this flavor
Parameters:
  classLoader - the class loader to use
exception:
  ClassNotFoundException - if the class is not loaded
exception:
  IllegalArgumentException - if mimeType isinvalid
exception:
  NullPointerException - if mimeType is null



DataFlavor
public DataFlavor(String mimeType) throws ClassNotFoundException(Code)
Constructs a DataFlavor from a mimeType string. The string can specify a "class=" parameter to create a DataFlavor with the desired representation class. If the string does not contain "class=" parameter, java.io.InputStream is used as default.
Parameters:
  mimeType - the string used to identify the MIME type for this flavor;if the class specified by "class=" parameter is notsuccessfully loaded, then anClassNotFoundException is thrown
exception:
  ClassNotFoundException - if the class is not loaded
exception:
  IllegalArgumentException - if mimeType isinvalid
exception:
  NullPointerException - if mimeType is null




Method Detail
clone
public Object clone() throws CloneNotSupportedException(Code)
Returns a clone of this DataFlavor. a clone of this DataFlavor



equals
public boolean equals(Object o)(Code)

The equals comparison for the DataFlavor class is implemented as follows: 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, java.nio.CharBuffer, 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. See selectBestTextFlavor for a list of text flavors which support the charset parameter.
Parameters:
  o - the Object to compare with this true if that is equivalent to thisDataFlavor; false otherwise
See Also:   DataFlavor.selectBestTextFlavor




equals
public boolean equals(DataFlavor that)(Code)
This method has the same behavior as DataFlavor.equals(Object) . The only difference being that it takes a DataFlavor instance as a parameter.
Parameters:
  that - the DataFlavor to compare withthis true if that is equivalent to thisDataFlavor; false otherwise
See Also:   DataFlavor.selectBestTextFlavor



equals
public boolean equals(String s)(Code)
Compares only the 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.
Parameters:
  s - the mimeType to compare. true if the String (MimeType) is equal; false otherwise or if s is null



getDefaultRepresentationClass
final public Class getDefaultRepresentationClass()(Code)



getDefaultRepresentationClassAsString
final public String getDefaultRepresentationClassAsString()(Code)



getHumanPresentableName
public String getHumanPresentableName()(Code)
Returns the human presentable name for the data format that this DataFlavor represents. This name would be localized for different countries. the human presentable name for the data format that thisDataFlavor represents



getMimeType
public String getMimeType()(Code)
Returns the MIME type string for this DataFlavor. the MIME type string for this flavor



getParameter
public String getParameter(String paramName)(Code)
Returns the human presentable name for this DataFlavor if paramName equals "humanPresentableName". Otherwise returns the MIME type value associated with paramName.
Parameters:
  paramName - the parameter name requested the value of the name parameter, or nullif there is no associated value



getPrimaryType
public String getPrimaryType()(Code)
Returns the primary MIME type for this DataFlavor. the primary MIME type of this DataFlavor



getReaderForText
public Reader getReaderForText(Transferable transferable) throws UnsupportedFlavorException, IOException(Code)
Gets a Reader for a text flavor, decoded, if necessary, for the expected charset (encoding). The supported representation classes are 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.
Parameters:
  transferable - the Transferable whose data will berequested in this flavor a Reader to read the Transferable'sdata
exception:
  IllegalArgumentException - if the representation classis not one of the seven listed above
exception:
  IllegalArgumentException - if the Transferablehas null data
exception:
  NullPointerException - if the Transferable is null
exception:
  UnsupportedEncodingException - if this flavor's representationis java.io.InputStream,java.nio.ByteBuffer, or [B andthis flavor's encoding is not supported by thisimplementation of the Java platform
exception:
  UnsupportedFlavorException - if the Transferabledoes not support this flavor
exception:
  IOException - if the data cannot be read because of anI/O error
See Also:   DataFlavor.selectBestTextFlavor
since:
   1.3




getRepresentationClass
public Class getRepresentationClass()(Code)
Returns the Class which objects supporting this DataFlavor will return when this DataFlavor is requested. the Class which objects supporting thisDataFlavor will return when this DataFlavoris requested



getSubType
public String getSubType()(Code)
Returns the sub MIME type of this DataFlavor. the Sub MIME type of this DataFlavor



getTextPlainUnicodeFlavor
final public static DataFlavor getTextPlainUnicodeFlavor()(Code)
Returns a 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. a DataFlavor representing plain textwith Unicode encoding
since:
   1.3



hashCode
public int hashCode()(Code)
Returns hash code for this 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. a hash code for this DataFlavor



isFlavorJavaFileListType
public boolean isFlavorJavaFileListType()(Code)
Returns true if the DataFlavor specified represents a list of file objects. true if the DataFlavor specified representsa List of File objects



isFlavorRemoteObjectType
public boolean isFlavorRemoteObjectType()(Code)
Returns true if the DataFlavor specified represents a remote object. true if the DataFlavor specified representsa Remote Object



isFlavorSerializedObjectType
public boolean isFlavorSerializedObjectType()(Code)
Returns true if the DataFlavor specified represents a serialized object. true if the DataFlavor specified representsa Serialized Object



isFlavorTextType
public boolean isFlavorTextType()(Code)
Returns whether this DataFlavor is a valid text flavor for this implementation of the Java platform. Only flavors equivalent to DataFlavor.stringFlavor and DataFlavors 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. true if this DataFlavor is a validtext flavor as described above; false otherwise
See Also:   DataFlavor.selectBestTextFlavor
since:
   1.4




isMimeTypeEqual
public boolean isMimeTypeEqual(String mimeType)(Code)
Returns whether the string representation of the MIME type passed in is equivalent to the MIME type of this DataFlavor. Parameters are not included in the comparison.
Parameters:
  mimeType - the string representation of the MIME type true if the string representation of the MIME type passed in isequivalent to the MIME type of this DataFlavor;false otherwise
throws:
  NullPointerException - if mimeType is null



isMimeTypeEqual
final public boolean isMimeTypeEqual(DataFlavor dataFlavor)(Code)
Compares the mimeType of two DataFlavor objects. No parameters are considered.
Parameters:
  dataFlavor - the DataFlavor to be compared true if the MimeTypes are equal,otherwise false



isMimeTypeSerializedObject
public boolean isMimeTypeSerializedObject()(Code)
Does the DataFlavor represent a serialized object?



isRepresentationClassByteBuffer
public boolean isRepresentationClassByteBuffer()(Code)
Returns whether the representation class for this DataFlavor is java.nio.ByteBuffer or a subclass thereof.
since:
   1.4



isRepresentationClassCharBuffer
public boolean isRepresentationClassCharBuffer()(Code)
Returns whether the representation class for this DataFlavor is java.nio.CharBuffer or a subclass thereof.
since:
   1.4



isRepresentationClassInputStream
public boolean isRepresentationClassInputStream()(Code)
Does the DataFlavor represent a java.io.InputStream?



isRepresentationClassReader
public boolean isRepresentationClassReader()(Code)
Returns whether the representation class for this DataFlavor is java.io.Reader or a subclass thereof.
since:
   1.4



isRepresentationClassRemote
public boolean isRepresentationClassRemote()(Code)
Returns true if the representation class is Remote. true if the representation class is Remote



isRepresentationClassSerializable
public boolean isRepresentationClassSerializable()(Code)
Returns true if the representation class can be serialized. true if the representation class can be serialized



match
public boolean match(DataFlavor that)(Code)
Identical to DataFlavor.equals(DataFlavor) .
Parameters:
  that - the DataFlavor to compare withthis true if that is equivalent to thisDataFlavor; false otherwise
See Also:   DataFlavor.selectBestTextFlavor
since:
   1.3



normalizeMimeType
protected String normalizeMimeType(String mimeType)(Code)
Called for each MIME type string to give 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.



normalizeMimeTypeParameter
protected String normalizeMimeTypeParameter(String parameterName, String parameterValue)(Code)
Called on 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.




readExternal
public synchronized void readExternal(ObjectInput is) throws IOException, ClassNotFoundException(Code)
Restores this DataFlavor from a Serialized state.



selectBestTextFlavor
final public static DataFlavor selectBestTextFlavor(DataFlavor[] availableFlavors)(Code)
Selects the best text DataFlavor from an array of DataFlavors. 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:

  • "text/sgml"
  • "text/xml"
  • "text/html"
  • "text/rtf"
  • "text/enriched"
  • "text/richtext"
  • "text/uri-list"
  • "text/tab-separated-values"
  • "text/t140"
  • "text/rfc822-headers"
  • "text/parityfec"
  • "text/directory"
  • "text/css"
  • "text/calendar"
  • "application/x-java-serialized-object"
  • "text/plain"
  • "text/<other>"

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:

  • "text/sgml"
  • "text/xml"
  • "text/html"
  • "text/enriched"
  • "text/richtext"
  • "text/uri-list"
  • "text/directory"
  • "text/css"
  • "text/calendar"
  • "application/x-java-serialized-object"
  • "text/plain"
The following MIME types do not support, or are treated as though they do not support, the charset parameter:
  • "text/rtf"
  • "text/tab-separated-values"
  • "text/t140"
  • "text/rfc822-headers"
  • "text/parityfec"
For "text/<other>" MIME types, the first time the JRE needs to determine whether the MIME type supports the charset parameter, it will check whether the parameter is explicitly listed in an arbitrarily chosen 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 DataFlavors 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.
Parameters:
  availableFlavors - an array of available DataFlavors the best (highest fidelity) flavor according to the rulesspecified above, or null,if availableFlavors is null,has zero length, or contains no text flavors
since:
   1.3




setHumanPresentableName
public void setHumanPresentableName(String humanPresentableName)(Code)
Sets the human presentable name for the data format that this DataFlavor represents. This name would be localized for different countries.
Parameters:
  humanPresentableName - the new human presentable name



toString
public String toString()(Code)
String representation of this 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. string representation of this DataFlavor
See Also:   DataFlavor.selectBestTextFlavor



tryToLoadClass
final protected static Class tryToLoadClass(String className, ClassLoader fallback) throws ClassNotFoundException(Code)
Tries to load a class from: the bootstrap loader, the system loader, the context loader (if one is present) and finally the loader specified.
Parameters:
  className - the name of the class to be loaded
Parameters:
  fallback - the fallback loader the class loaded
exception:
  ClassNotFoundException - if class is not found



writeExternal
public synchronized void writeExternal(ObjectOutput os) throws IOException(Code)
Serializes this DataFlavor.



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.