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

java.awt.datatransfer.DataFlavor.equals(String) works wrong

    XMLWordPrintable

Details

    • sparc
    • solaris_2.5

    Description



      Name: sdC67446 Date: 09/22/98


      There is inconsistency in the behaviour of equals(DataFlavor) and
      equals(String). These methods return different value for identical
      input param. In detail, equals(String) ignores 'representationClass'
      definition.

      The doc says:
      --------------------------------------------------
      public boolean equals(DataFlavor dataFlavor)

            Returns:
                  if the DataFlavors represent the same type.

      public boolean equals(java.lang.String s)

            Returns:
                  if the String (MimeType) is equal

      The test:
      -----------------Test.java------------------------
      import java.awt.datatransfer.*;

      public class Test {
          public static void main(String[] args) {
              String sampleMimeType1 = "application/postscript;class=java.awt.datatransfer.DataFlavor";
              String sampleMimeType2 = "application/postscript;class=java.awt.datatransfer.Clipboard";
      DataFlavor df1 = null;
      DataFlavor df2 = null;
      try {
      df1 = new DataFlavor(sampleMimeType1);
      df2 = new DataFlavor(sampleMimeType2);
      } catch (ClassNotFoundException e) {
      System.out.println("unexpected exception: "+e);
      }
      System.out.println(df1.equals(df2));
      System.out.println(df1.equals(sampleMimeType2));
          }
      }
      ---------Output-----------------------------------
      false
      true
      --------------------------------------------------
      ======================================================================

      Attachments

        Activity

          People

            xdengsunw Xianfa Deng (Inactive)
            sdmitriesunw Sergei Dmitriev (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: