Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4259481

DataFlavor.selectBestTextFlavor behavior is not defined

XMLWordPrintable

    • sparc
    • solaris_2.5.1



      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]
      --------------------------------------------------
      ======================================================================

            prssunw Prs Prs (Inactive)
            dsvsunw Dsv Dsv (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: