Coverage Report - org.webslinger.collections.objectArrayWrapper
 
Classes in this File Line Coverage Branch Coverage Complexity
objectArrayWrapper
42%
5/12
0%
0/1
0
 
 1  
 package org.webslinger.collections;
 2  
 
 3  
 import java.util.AbstractList;
 4  
 
 5  
 /**
 6  
  * Utility class used to make a Object array look like a list.  This class is
 7  
  * part of the wrapper collection.
 8  
  * @deprecated Use {@link java.util.Arrays#asList(Object[])}
 9  
  * @author Adam Heath <a href="mailto:doogie@brainfood.com">doogie@brainfood.com</a>
 10  
  */
 11  
 public class objectArrayWrapper extends AbstractList<Object> {
 12  
     /** the wrapped array */
 13  
     protected Object[] array;
 14  
 
 15  
     /**
 16  
      * Wraps an array to make it look like a list.
 17  
      * @param array The array to wrap.
 18  
      * @throws ClassCastException if array is not actually an array. 
 19  
      */
 20  0
     public objectArrayWrapper(Object array) {
 21  0
         if (!(array instanceof Object[])) throw new ClassCastException(array + " is not an array!");
 22  0
         this.array = (Object[]) array;
 23  0
     }
 24  
 
 25  
     /**
 26  
      * Wraps an array to make it look like a list.
 27  
      * @param array The array to wrap.
 28  
      */
 29  2
     public objectArrayWrapper(Object[] array) {
 30  2
         this.array = (Object[]) array.clone();
 31  2
     }
 32  
 
 33  
     /**
 34  
      * Returns the element at the specified position in the {@link
 35  
      * #array}.
 36  
      * @param i index of element to return.
 37  
      * @throws IndexOutOfBoundsException if the index if out of range (i
 38  
      * &lt; 0 || i &gt; {@link #array}.length).  
 39  
      * @return the element at the specified position in the {@link
 40  
      * #array}.
 41  
      */
 42  
     public Object get(int i) {
 43  2
         return array[i];
 44  
     }
 45  
 
 46  
     /**
 47  
      * Replaces the element at the specified position in this list with
 48  
      * the specified element
 49  
      * @param i index of element to replace.
 50  
      * @param o object to be stored at the specified position.
 51  
      * @throws IllegalArgumentException if some aspect of the specified
 52  
      * element prevents it from being added to the {@link #array}.
 53  
      * @throws IndexOutOfBoundsException if the index if out of range (i
 54  
      * &lt; 0 || i &gt; {@link #array}.length).  
 55  
      * @return the element previously at the specified position.
 56  
      */
 57  
     public Object set(int i, Object o) {
 58  0
         Object old = array[i];
 59  0
         array[i] = o;
 60  0
         return old;
 61  
     }
 62  
 
 63  
     /**
 64  
      * Returns the number of elements in the {@link #array}.
 65  
      * @return the number of elements in the {@link #array}.
 66  
      */
 67  
     public int size() {
 68  6
         return array.length;
 69  
     }
 70  
 }