JDK-4259481 : DataFlavor.selectBestTextFlavor behavior is not defined
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.3.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: solaris_2.5.1
  • CPU: sparc
  • Submitted: 1999-08-04
  • Updated: 2000-11-30
  • Resolved: 2000-11-30
Related Reports
Duplicate :  
Duplicate :  
Relates :  
Description

Name: sdC67446			Date: 08/04/99


The method:
    public static final DataFlavor
        selectBestTextFlavor(DataFlavor[] availableFlavors)
of class java.awt.datatransfer.DataFlavor
returns different "best" DataFlavors for equal arrays of
DataFlavors. See the example. 
The specification should clearly clarify how "the best (highest
fidelity) flavor" looks like.

The doc says:
--------------------------------------------------
public static final DataFlavor
    selectBestTextFlavor(DataFlavor[] availableFlavors) 

     Returns:
         the best (highest fidelity) flavor in an encoding supported
         by the JDK, or null if none can be found.

---------Test.java--------------------------------
import java.awt.datatransfer.DataFlavor;

public class Test {
    public static void main(String[] args) {
	try {
            DataFlavor df = new DataFlavor();
            DataFlavor dfs1[] = {new DataFlavor("text/plain"),
                                 DataFlavor.stringFlavor};
            DataFlavor dfs2[] = {DataFlavor.stringFlavor,
                                 new DataFlavor("text/plain")};
            System.out.println(df.selectBestTextFlavor(dfs1));
            System.out.println(df.selectBestTextFlavor(dfs2));
	} catch (Exception e) {
            e.printStackTrace();
	}
    }
}
---------Output-----------------------------------
Classic VM (build JDK-1.3-L, green threads, nojit)

Warning: JIT compiler "sunwjit" not found. Will use interpreter.
java.awt.datatransfer.DataFlavor[representationclass=java.io.InputStream;mimetype=text/plain]
java.awt.datatransfer.DataFlavor[representationclass=java.lang.String;mimetype=application/x-java-serialized-object]
--------------------------------------------------
======================================================================