Coverage Report - org.webslinger.collections.floatArrayWrapper
 
Classes in this File Line Coverage Branch Coverage Complexity
floatArrayWrapper
0%
0/14
0%
0/2
0
 
 1  
 package org.webslinger.collections;
 2  
 
 3  
 import java.util.AbstractList;
 4  
 
 5  
 /**
 6  
  * Utility class used to make a float 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  0
 public class floatArrayWrapper extends AbstractList<Float> {
 12  
     /** the wrapped array */
 13  
     protected float[] 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 floatArrayWrapper(Object array) {
 21  0
         if (!(array instanceof float[])) throw new ClassCastException(array + " is not an array!");
 22  0
         this.array = (float[]) 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  0
     public floatArrayWrapper(float[] array) {
 30  0
         this.array = (float[]) array.clone();
 31  0
     }
 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 Float get(int i) {
 43  0
         return new Float(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 ClassCastException if the class of the specified element
 52  
      * prevents it from being added to the {@link #array}. 
 53  
      * @throws NullPointerException if the specified element is null and
 54  
      * the {@link #array} does not support null elements. 
 55  
      * @throws IllegalArgumentException if some aspect of the specified
 56  
      * element prevents it from being added to the {@link #array}.
 57  
      * @throws IndexOutOfBoundsException if the index if out of range (i
 58  
      * &lt; 0 || i &gt; {@link #array}.length).  
 59  
      * @return the element previously at the specified position.
 60  
      */
 61  
     public Float set(int i, Float o) {
 62  0
         if (!(o instanceof Float)) throw new ClassCastException("not a float");
 63  0
         float old = array[i];
 64  0
         array[i] = o.floatValue();
 65  0
         return new Float(old);
 66  
     }
 67  
 
 68  
     /**
 69  
      * Returns the number of elements in the {@link #array}.
 70  
      * @return the number of elements in the {@link #array}.
 71  
      */
 72  
     public int size() {
 73  0
         return array.length;
 74  
     }
 75  
 }