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

unclear doc for java.awt.datatransfer.DataFlavor.isMimeTypeEqual

XMLWordPrintable

    • beta
    • sparc
    • solaris_2.5



      Name: sdC67446 Date: 09/23/98


      The specification for
      java.awt.datatransfer.DataFlavor.isMimeTypeEqual(String mimeType) and
      java.awt.datatransfer.DataFlavor.isMimeTypeEqual(DataFlavor dataFlavor)
      doesn't specify behavior if input param == null.
      Currently methods throw NullPointerException.
      Should be fixed for consistency.

      The doc says:
      -------------------------------------------------------------
      public boolean isMimeTypeEqual(java.lang.String mimeType)

            Is the string representation of the MIME type passed
            in equivalent to the MIME type of this DataFlavor.
            This may involve adding default attributes for some
            MIME types (like adding charset=US-ASCII to
            text/plain MIME types that have no charset parameter specified)

      public final boolean isMimeTypeEqual(DataFlavor dataFlavor)

            Returns:
                  if the MimeTypes are equal

      The test demonstrating the bug:
      ------------------------------------------------------------

      import java.awt.datatransfer.*;

      public class Test {

          public static void main(String[] args) {
      DataFlavor df = new DataFlavor();

      try {
      System.out.println(df.isMimeTypeEqual((DataFlavor)null));
      } catch (Exception e) {
      System.out.println(e);
      }

      try {
      System.out.println(df.isMimeTypeEqual((String)null));
      } catch (Exception e) {
      System.out.println(e);
      }
          };
      }
      Test output:
      ------------------------------------------------------------
      java.lang.NullPointerException
      java.lang.NullPointerException
      ------------------------------------------------------------

      ======================================================================

            sharonz Sharon Zakhour (Inactive)
            sdmitriesunw Sergei Dmitriev (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: