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

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

    Details

    • Subcomponent:
    • Resolved In Build:
      1.2.2
    • CPU:
      sparc
    • OS:
      solaris_2.5

      Description



      Name: sdC67446 Date: 09/24/98


      The doc for java.awt.datatransfer.DataFlavor
      methods isMimeTypeEqual(DataFlavor),
              isMimeTypeEqual(String),
              equals(Object),
              equals(DataFlavor) and
              equals(String)
      doesn't specify the behaviour if class instance and input param have
      distinctions in MIME parameters. Currently all methods ignore all of
      MIME parameters. The spec should be updated.

      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

      public boolean equals(java.lang.Object o)
            Returns:
                  if the objects are equal
            Overrides:
                  equals in class java.lang.Object

      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

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

      public class Test {
          public static void main(String[] args) {
              String sampleMimeType1 = "application/postscript;I_AM=GOOD";
              String sampleMimeType2 = "application/postscript;I_AM=BAD";
      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("isMimeTypeEqual:");
      System.out.println(df1.isMimeTypeEqual(df2));
      System.out.println(df1.isMimeTypeEqual(sampleMimeType2));
      System.out.println("equals:");
      System.out.println(df1.equals((Object)df2));
      System.out.println(df1.equals(df2));
      System.out.println(df1.equals(sampleMimeType2));
          }
      }
      ---------Output-----------------------------------
      isMimeTypeEqual:
      true
      true
      equals:
      true
      true
      true
      --------------------------------------------------
      ======================================================================

        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved:
                Imported:
                Indexed: