commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From scolebou...@apache.org
Subject cvs commit: jakarta-commons/collections/src/java/org/apache/commons/collections/map ListOrderedMap.java
Date Mon, 07 Jun 2004 21:51:40 GMT
scolebourne    2004/06/07 14:51:39

  Modified:    collections RELEASE-NOTES.html
               collections/src/test/org/apache/commons/collections/map
                        TestAll.java
               collections/src/java/org/apache/commons/collections/map
                        ListOrderedMap.java
  Added:       collections/src/test/org/apache/commons/collections/map
                        TestListOrderedMap2.java
  Log:
  Add new public constructor to ListOrderedMap
  
  Revision  Changes    Path
  1.58      +2 -1      jakarta-commons/collections/RELEASE-NOTES.html
  
  Index: RELEASE-NOTES.html
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/RELEASE-NOTES.html,v
  retrieving revision 1.57
  retrieving revision 1.58
  diff -u -r1.57 -r1.58
  --- RELEASE-NOTES.html	7 Jun 2004 21:42:12 -0000	1.57
  +++ RELEASE-NOTES.html	7 Jun 2004 21:51:39 -0000	1.58
  @@ -63,7 +63,8 @@
   <li>InvokerTransformer - Add additional getInstance() method</li>
   <li>Reduced inter-class and inter-package dependencies, especially via *Utils classes</li>
   <li>ListOrderedSet - Add new factory method decorate(Set,List)</li>
  -<li>ListOrderedSet - Add constructor that uses a HashSet and ArrayList</li>
  +<li>ListOrderedSet - Add public constructor that uses a HashSet and ArrayList</li>
  +<li>ListOrderedMap - Add public constructor that uses a HashMap and ArrayList</li>
   </ul>
   
   <h4>Made Serializable</h4>
  
  
  
  1.19      +2 -1      jakarta-commons/collections/src/test/org/apache/commons/collections/map/TestAll.java
  
  Index: TestAll.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/map/TestAll.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- TestAll.java	30 Apr 2004 22:53:44 -0000	1.18
  +++ TestAll.java	7 Jun 2004 21:51:39 -0000	1.19
  @@ -59,6 +59,7 @@
           suite.addTest(TestLazyMap.suite());
           suite.addTest(TestLazySortedMap.suite());
           suite.addTest(TestListOrderedMap.suite());
  +        suite.addTest(TestListOrderedMap2.suite());
           suite.addTest(TestPredicatedMap.suite());
           suite.addTest(TestPredicatedSortedMap.suite());
           suite.addTest(TestTransformedMap.suite());
  
  
  
  1.1                  jakarta-commons/collections/src/test/org/apache/commons/collections/map/TestListOrderedMap2.java
  
  Index: TestListOrderedMap2.java
  ===================================================================
  /*
   *  Copyright 2004 The Apache Software Foundation
   *
   *  Licensed under the Apache License, Version 2.0 (the "License");
   *  you may not use this file except in compliance with the License.
   *  You may obtain a copy of the License at
   *
   *      http://www.apache.org/licenses/LICENSE-2.0
   *
   *  Unless required by applicable law or agreed to in writing, software
   *  distributed under the License is distributed on an "AS IS" BASIS,
   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   *  See the License for the specific language governing permissions and
   *  limitations under the License.
   */
  package org.apache.commons.collections.map;
  
  import java.util.ArrayList;
  import java.util.List;
  import java.util.Map;
  
  import junit.framework.Test;
  
  import org.apache.commons.collections.BulkTest;
  import org.apache.commons.collections.MapIterator;
  import org.apache.commons.collections.list.AbstractTestList;
  
  /**
   * Extension of {@link TestMap} for exercising the {@link ListOrderedMap}
   * implementation.
   *
   * @since Commons Collections 3.1
   * @version $Revision: 1.1 $ $Date: 2004/06/07 21:51:39 $
   * 
   * @author Henri Yandell
   * @author Stephen Colebourne
   */
  public class TestListOrderedMap2 extends AbstractTestOrderedMap {
  
      public TestListOrderedMap2(String testName) {
          super(testName);
      }
  
      public static Test suite() {
          return BulkTest.makeSuite(TestListOrderedMap2.class);
      }
  
      public static void main(String args[]) {
          String[] testCaseName = { TestListOrderedMap2.class.getName()};
          junit.textui.TestRunner.main(testCaseName);
      }
  
      public Map makeEmptyMap() {
          return new ListOrderedMap();
      }
      
      //-----------------------------------------------------------------------
      public void testGetByIndex() {
          resetEmpty();
          ListOrderedMap lom = (ListOrderedMap) map;
          try {
              lom.get(0);
          } catch (IndexOutOfBoundsException ex) {}
          try {
              lom.get(-1);
          } catch (IndexOutOfBoundsException ex) {}
          
          resetFull();
          lom = (ListOrderedMap) map;
          try {
              lom.get(-1);
          } catch (IndexOutOfBoundsException ex) {}
          try {
              lom.get(lom.size());
          } catch (IndexOutOfBoundsException ex) {}
          
          int i = 0;
          for (MapIterator it = lom.mapIterator(); it.hasNext(); i++) {
              assertSame(it.next(), lom.get(i));
          }
      }
  
      public void testGetValueByIndex() {
          resetEmpty();
          ListOrderedMap lom = (ListOrderedMap) map;
          try {
              lom.getValue(0);
          } catch (IndexOutOfBoundsException ex) {}
          try {
              lom.getValue(-1);
          } catch (IndexOutOfBoundsException ex) {}
          
          resetFull();
          lom = (ListOrderedMap) map;
          try {
              lom.getValue(-1);
          } catch (IndexOutOfBoundsException ex) {}
          try {
              lom.getValue(lom.size());
          } catch (IndexOutOfBoundsException ex) {}
          
          int i = 0;
          for (MapIterator it = lom.mapIterator(); it.hasNext(); i++) {
              it.next();
              assertSame(it.getValue(), lom.getValue(i));
          }
      }
  
      public void testIndexOf() {
          resetEmpty();
          ListOrderedMap lom = (ListOrderedMap) map;
          assertEquals(-1, lom.indexOf(getOtherKeys()));
          
          resetFull();
          lom = (ListOrderedMap) map;
          List list = new ArrayList();
          for (MapIterator it = lom.mapIterator(); it.hasNext();) {
              list.add(it.next());
          }
          for (int i = 0; i < list.size(); i++) {
              assertEquals(i, lom.indexOf(list.get(i)));
          }
      }
  
      public void testRemoveByIndex() {
          resetEmpty();
          ListOrderedMap lom = (ListOrderedMap) map;
          try {
              lom.remove(0);
          } catch (IndexOutOfBoundsException ex) {}
          try {
              lom.remove(-1);
          } catch (IndexOutOfBoundsException ex) {}
          
          resetFull();
          lom = (ListOrderedMap) map;
          try {
              lom.remove(-1);
          } catch (IndexOutOfBoundsException ex) {}
          try {
              lom.remove(lom.size());
          } catch (IndexOutOfBoundsException ex) {}
          
          List list = new ArrayList();
          for (MapIterator it = lom.mapIterator(); it.hasNext();) {
              list.add(it.next());
          }
          for (int i = 0; i < list.size(); i++) {
              Object key = list.get(i);
              Object value = lom.get(key);
              assertEquals(value, lom.remove(i));
              list.remove(i);
              assertEquals(false, lom.containsKey(key));
          }
      }
      
      public BulkTest bulkTestListView() {
          return new TestListView();
      }
      
      public class TestListView extends AbstractTestList {
          
          TestListView() {
              super("TestListView");
          }
  
          public List makeEmptyList() {
              return ((ListOrderedMap) TestListOrderedMap2.this.makeEmptyMap()).asList();
          }
          
          public List makeFullList() {
              return ((ListOrderedMap) TestListOrderedMap2.this.makeFullMap()).asList();
          }
          
          public Object[] getFullElements() {
              return TestListOrderedMap2.this.getSampleKeys();
          }
          public boolean isAddSupported() {
              return false;
          }
          public boolean isRemoveSupported() {
              return false;
          }
          public boolean isSetSupported() {
              return false;
          }
          public boolean isNullSupported() {
              return TestListOrderedMap2.this.isAllowNullKey();
          }
          public boolean isTestSerialization() {
              return false;
          }
      }
  
      public String getCompatibilityVersion() {
          return "3.1";
      }
  
  //    public void testCreate() throws Exception {
  //        resetEmpty();
  //        writeExternalFormToDisk(
  //            (java.io.Serializable) map,
  //            "D:/dev/collections/data/test/ListOrderedMap.emptyCollection.version3.1.obj");
  //        resetFull();
  //        writeExternalFormToDisk(
  //            (java.io.Serializable) map,
  //            "D:/dev/collections/data/test/ListOrderedMap.fullCollection.version3.1.obj");
  //    }
  }
  
  
  
  1.16      +12 -1     jakarta-commons/collections/src/java/org/apache/commons/collections/map/ListOrderedMap.java
  
  Index: ListOrderedMap.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/map/ListOrderedMap.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- ListOrderedMap.java	9 Apr 2004 10:36:01 -0000	1.15
  +++ ListOrderedMap.java	7 Jun 2004 21:51:39 -0000	1.16
  @@ -23,6 +23,7 @@
   import java.util.AbstractSet;
   import java.util.ArrayList;
   import java.util.Collection;
  +import java.util.HashMap;
   import java.util.Iterator;
   import java.util.List;
   import java.util.ListIterator;
  @@ -82,6 +83,16 @@
       }
   
       //-----------------------------------------------------------------------
  +    /**
  +     * Constructs a new empty <code>ListOrderedMap</code> that decorates
  +     * a <code>HashMap</code>.
  +     * 
  +     * @since Commons Collections 3.1
  +     */
  +    public ListOrderedMap() {
  +        this(new HashMap());
  +    }
  +
       /**
        * Constructor that wraps (not copies).
        * 
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message