commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rwaldh...@apache.org
Subject cvs commit: jakarta-commons/collections/src/test/org/apache/commons/collections/primitives TestCharList.java
Date Wed, 16 Apr 2003 19:03:40 GMT
rwaldhoff    2003/04/16 12:03:40

  Modified:    collections/src/java/org/apache/commons/collections/primitives/adapters
                        ListCharList.java
               collections/src/java/org/apache/commons/collections/primitives
                        RandomAccessCharList.java
               collections/src/test/org/apache/commons/collections/primitives
                        TestCharList.java
  Log:
  a more useful CharList.toString implementation
  
  Revision  Changes    Path
  1.2       +7 -2      jakarta-commons/collections/src/java/org/apache/commons/collections/primitives/adapters/ListCharList.java
  
  Index: ListCharList.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/primitives/adapters/ListCharList.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ListCharList.java	16 Apr 2003 18:32:39 -0000	1.1
  +++ ListCharList.java	16 Apr 2003 19:03:39 -0000	1.2
  @@ -107,6 +107,11 @@
           _list = list;     
       }
       
  +    public String toString() {
  +        // could cache these like StringBuffer does
  +        return new String(toArray());
  +    }
  +
       protected List getList() {
           return _list;
       }
  
  
  
  1.2       +4 -12     jakarta-commons/collections/src/java/org/apache/commons/collections/primitives/RandomAccessCharList.java
  
  Index: RandomAccessCharList.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/primitives/RandomAccessCharList.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- RandomAccessCharList.java	16 Apr 2003 18:32:39 -0000	1.1
  +++ RandomAccessCharList.java	16 Apr 2003 19:03:39 -0000	1.2
  @@ -203,16 +203,8 @@
       }
       
       public String toString() {
  -        StringBuffer buf = new StringBuffer();
  -        buf.append("[");
  -        for(CharIterator iter = iterator(); iter.hasNext();) {
  -            buf.append(iter.next());
  -            if(iter.hasNext()) {
  -                buf.append(", ");
  -            }
  -        }
  -        buf.append("]");
  -        return buf.toString();
  +        // could cache these like StringBuffer does
  +        return new String(toArray());
       }
       
       // protected utilities
  
  
  
  1.2       +10 -2     jakarta-commons/collections/src/test/org/apache/commons/collections/primitives/TestCharList.java
  
  Index: TestCharList.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/primitives/TestCharList.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TestCharList.java	16 Apr 2003 18:32:40 -0000	1.1
  +++ TestCharList.java	16 Apr 2003 19:03:39 -0000	1.2
  @@ -422,4 +422,12 @@
           }
       }
   
  +    public void testCharListToString() throws Exception {
  +        String expected = "The quick brown fox jumped over the lazy dogs.";
  +        CharList list = makeEmptyCharList();
  +        for(int i=0;i<expected.length();i++) {
  +            list.add(expected.charAt(i));
  +        }
  +        assertEquals(expected,list.toString());
  +    }
   }
  
  
  

---------------------------------------------------------------------
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