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

MidiMesssage and subclasses: .equals() not implemented

    XMLWordPrintable

    Details

    • Type: Enhancement
    • Status: Closed
    • Priority: P4
    • Resolution: Duplicate
    • Affects Version/s: 1.4.2
    • Fix Version/s: None
    • Component/s: client-libs
    • Labels:

      Description



      Name: gm110360 Date: 04/18/2003


      A DESCRIPTION OF THE REQUEST :
      The class MidiMessage and it's subclasses doesn't override
      the .equals() method of Object.
      .equals should check for the same *contents* of an object.
      So it's needed to override it at least for such important
      containers.

      JUSTIFICATION :
      Everywhere in the API's there are .equals() methods for comparing
      the content (Point, Color etc.etc.)
      But the entire sound-API is missing it, so you can't compare
      Messages (Short and Sysex-Messages) without implementing own methods.


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      Correct implementation of .equals() method - comparing the
      contents and not the pointer to the object.
      .equals compares only the reference (the default behav. of Object.equals())

      ---------- BEGIN SOURCE ----------
      /*
       * EqualTest.java
       *
       * Created on 12. April 2003, 14:13
       */
      import javax.sound.midi.*;
      /**
       *
       * @author Gerrit Gehnen
       */
      public class EqualTest {
          /**
           * @param args the command line arguments
           */
          public static void main(String[] args) {
              ShortMessage msg1,msg2;
              msg1=new ShortMessage();
              
              try{
              msg1.setMessage(ShortMessage.NOTE_ON,1,64,64);

              // Duplicate the original Message
              msg2=(ShortMessage)msg1.clone();
              
              if (msg1.equals(msg2))
                  {
                  System.out.println("OK: Is equal!");
                  System.exit(0);
              }
              else
              {
                  System.out.println("ERROR: Is not equal!");
                  System.exit(1);
              }
                      }catch (Exception e){e.printStackTrace();}
          }
          
      }

      ---------- END SOURCE ----------
      (Review ID: 184030)
      ======================================================================

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              fbomerssunw Florian Bomers (Inactive)
              Reporter:
              gmanwanisunw Girish Manwani (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: