Coverage Report - org.apache.commons.collections.primitives.adapters.AbstractListCharList
 
Classes in this File Line Coverage Branch Coverage Complexity
AbstractListCharList
100%
27/27
100%
10/10
1.643
 
 1  
 /*
 2  
  * Licensed to the Apache Software Foundation (ASF) under one or more
 3  
  * contributor license agreements.  See the NOTICE file distributed with
 4  
  * this work for additional information regarding copyright ownership.
 5  
  * The ASF licenses this file to You under the Apache License, Version 2.0
 6  
  * (the "License"); you may not use this file except in compliance with
 7  
  * the License.  You may obtain a copy of the License at
 8  
  *
 9  
  *     http://www.apache.org/licenses/LICENSE-2.0
 10  
  *
 11  
  * Unless required by applicable law or agreed to in writing, software
 12  
  * distributed under the License is distributed on an "AS IS" BASIS,
 13  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
  * See the License for the specific language governing permissions and
 15  
  * limitations under the License.
 16  
  */
 17  
 package org.apache.commons.collections.primitives.adapters;
 18  
 
 19  
 import java.util.Collection;
 20  
 import java.util.List;
 21  
 
 22  
 import org.apache.commons.collections.primitives.CharCollection;
 23  
 import org.apache.commons.collections.primitives.CharIterator;
 24  
 import org.apache.commons.collections.primitives.CharList;
 25  
 import org.apache.commons.collections.primitives.CharListIterator;
 26  
 
 27  
 /**
 28  
  *
 29  
  * @since Commons Primitives 1.0
 30  
  * @version $Revision: 480462 $ $Date: 2006-11-29 03:15:00 -0500 (Wed, 29 Nov 2006) $
 31  
  * @author Rodney Waldhoff 
 32  
  */
 33  547
 abstract class AbstractListCharList extends AbstractCollectionCharCollection implements CharList {
 34  
 
 35  
     public void add(int index, char element) {
 36  53
         getList().add(index,new Character(element));
 37  37
     }
 38  
 
 39  
     public boolean addAll(int index, CharCollection collection) {
 40  3
         return getList().addAll(index,CharCollectionCollection.wrap(collection));
 41  
     }
 42  
 
 43  
     public char get(int index) {
 44  15046
         return ((Character)getList().get(index)).charValue();
 45  
     }
 46  
 
 47  
     public int indexOf(char element) {
 48  64
         return getList().indexOf(new Character(element));
 49  
     }
 50  
 
 51  
     public int lastIndexOf(char element) {
 52  64
         return getList().lastIndexOf(new Character(element));
 53  
     }
 54  
 
 55  
     /**
 56  
      * {@link ListIteratorCharListIterator#wrap wraps} the 
 57  
      * {@link CharList CharList} 
 58  
      * returned by my underlying 
 59  
      * {@link CharListIterator CharListIterator},
 60  
      * if any.
 61  
      */
 62  
     public CharListIterator listIterator() {
 63  982
         return ListIteratorCharListIterator.wrap(getList().listIterator());
 64  
     }
 65  
 
 66  
     /**
 67  
      * {@link ListIteratorCharListIterator#wrap wraps} the 
 68  
      * {@link CharList CharList} 
 69  
      * returned by my underlying 
 70  
      * {@link CharListIterator CharListIterator},
 71  
      * if any.
 72  
      */
 73  
     public CharListIterator listIterator(int index) {
 74  109
         return ListIteratorCharListIterator.wrap(getList().listIterator(index));
 75  
     }
 76  
 
 77  
     public char removeElementAt(int index) {
 78  100
         return ((Character)getList().remove(index)).charValue();
 79  
     }
 80  
 
 81  
     public char set(int index, char element) {
 82  50
         return ((Character)getList().set(index,new Character(element))).charValue();
 83  
     }
 84  
 
 85  
     public CharList subList(int fromIndex, int toIndex) {
 86  166
         return ListCharList.wrap(getList().subList(fromIndex,toIndex));
 87  
     }
 88  
 
 89  
     public boolean equals(Object obj) {
 90  36
         if(obj instanceof CharList) {
 91  33
             CharList that = (CharList)obj;
 92  33
             if(this == that) {
 93  3
                 return true;
 94  30
             } else if(this.size() != that.size()) {
 95  4
                 return false;            
 96  
             } else {
 97  26
                 CharIterator thisiter = iterator();
 98  26
                 CharIterator thatiter = that.iterator();
 99  138
                 while(thisiter.hasNext()) {
 100  114
                     if(thisiter.next() != thatiter.next()) {
 101  2
                         return false;
 102  
                     }
 103  
                 }
 104  24
                 return true;
 105  
             }
 106  
         } else {
 107  3
             return false;
 108  
         }
 109  
     }
 110  
         
 111  
     public int hashCode() {
 112  938
         return getList().hashCode();
 113  
     }
 114  
     
 115  
     final protected Collection getCollection() {
 116  8894
         return getList();
 117  
     }
 118  
     
 119  
     abstract protected List getList();
 120  
 }