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

javax.swing.SizeSequence shoul have a getLength() method

XMLWordPrintable

    • Fix Understood
    • generic
    • generic

      Name: boT120536 Date: 02/15/2001


      C:\>java -version
      java version "1.3.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
      Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)

      javax.swing.SizeSequence should have a getLength() method or a public var.
      length which give the length of the int. array of the SizeSequence. Now in
      order to get the length, one must use getSizes().length, which affect the
      perfomence. Also it's good to have a toString() method of SizeSequence itself.
      (Review ID: 117029)
      ======================================================================
      Suggestion by java.net member leouser

      A DESCRIPTION OF THE FIX :
      BUGID 4415809: javax.swing.SizeSequence should have a getLength() method.
       FILES AFFECTED: javax.swing.SizeSequence
      JDK VERSION
      jdk-6-rc-bin-b64-linux-i586-15_dec_2005.bin

      Discusion(embeded in test case as well):
      /**
       * BUGID 4415809: javax.swing.SizeSequence should have a getLength() method.
       * This is a simple RFE to help improve performance. Ive added a getLength()
       * method that quickly returns the length of the inner array. Ive also added
       * better toString method in swing style:
       * class/guts
       * This was also requested by the RFE.
       *
       * ANTI-RATIONALE: a subclass may have added a getLength method to do this
       * work. Though if it did, it will be a somewhat useless method--> the
       * subclasser still has to go through getSizes to get the length.
       *
       * TEST STRATEGY:
       * Show that getLength returns the right value. Output the new string
       * representation.
       *
       * FILES AFFECTED: javax.swing.SizeSequence
       *
       * JDK VERSION
       * jdk-6-rc-bin-b64-linux-i586-15_dec_2005.bin
       *
       * test ran succesfully on a SUSE 7.3 Linux distribution
       *
       * Brian Harry
       * ###@###.###
       * Jan 23, 2006
       */

      UNIFIED DIFF:
      --- /home/nstuff/java6/jdk1.6.0/javax/swing/SizeSequence.java Thu Dec 15 02:17:39 2005
      +++ /home/javarefs/javax/swing/SizeSequence.java Mon Jan 23 14:32:27 2006
      @@ -5,7 +5,9 @@
        * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
        */
       
      -package javax.swing;
      +package javax.swing;
      +
      +import java.util.Arrays;
       
       /**
        * A <code>SizeSequence</code> object
      @@ -284,6 +286,15 @@
                   return getIndex(m + 1, to, position - pivot);
               }
           }
      +
      + /**
      + * Returns the number of entries.
      + *
      + * @return the number of entries
      + */
      + public int getLength(){
      + return a.length;
      + }
           
           /**
            * Returns the size of the specified entry.
      @@ -386,4 +397,11 @@
               }
               setSizes(a);
           }
      +
      + public String toString(){
      + StringBuilder sb = new StringBuilder();
      + sb.append("javax.swing.SizeSequence");
      + sb.append(Arrays.toString(a));
      + return sb.toString();
      + }
       }



      JUnit TESTCASE :
      import javax.swing.*;
      import static java.lang.System.*;
      import junit.framework.TestCase;
      import junit.textui.TestRunner;

      /**
       * BUGID 4415809: javax.swing.SizeSequence should have a getLength() method.
       * This is a simple RFE to help improve performance. Ive added a getLength()
       * method that quickly returns the length of the inner array. Ive also added
       * better toString method in swing style:
       * class/guts
       * This was also requested by the RFE.
       *
       * ANTI-RATIONALE: a subclass may have added a getLength method to do this
       * work. Though if it did, it will be a somewhat useless method--> the
       * subclasser still has to go through getSizes to get the length.
       *
       * TEST STRATEGY:
       * Show that getLength returns the right value. Output the new string
       * representation.
       *
       * FILES AFFECTED: javax.swing.SizeSequence
       *
       * JDK VERSION
       * jdk-6-rc-bin-b64-linux-i586-15_dec_2005.bin
       *
       * test ran succesfully on a SUSE 7.3 Linux distribution
       *
       * Brian Harry
       * ###@###.###
       * Jan 23, 2006
       */
      public class SSequence4415809 extends TestCase{


          public SSequence4415809(String method){
      super(method);
          }

          public void testSSequence(){
              out.println();
              out.println("Testing SizeSequence.getLength ... whooopie!");
      SizeSequence ss = new SizeSequence();
      ss.insertEntries(0, 10, 50);
      assertEquals(10, ss.getLength());
              assertEquals(10, ss.getSizes().length);
      ss.insertEntries(0,30, 4);
      assertEquals( 40, ss.getLength());
              assertEquals( 40, ss.getSizes().length);
              out.println("Is toString adequate now?");
      out.println(ss);
          }

          public static void main(String ... args){
      TestCase tc = new SSequence4415809("testSSequence");
      TestRunner.run(tc);
          }

      }


      FIX FOR BUG NUMBER:
      4415809

            peterz Peter Zhelezniakov
            bonealsunw Bret O'neal (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Imported:
              Indexed: