1 package com.xtremelabs.robolectric.shadows; 2 3 import android.util.SparseArray; 4 import android.util.SparseIntArray; 5 6 import com.xtremelabs.robolectric.internal.Implementation; 7 import com.xtremelabs.robolectric.internal.Implements; 8 import com.xtremelabs.robolectric.internal.RealObject; 9 10 @Implements(SparseIntArray.class) 11 public class ShadowSparseIntArray { 12 13 private SparseArray<Integer> sparseArray = new SparseArray<Integer>(); 14 15 @RealObject 16 private SparseIntArray realObject; 17 18 @Implementation get( int key )19 public int get( int key ){ 20 return get( key, 0 ); 21 } 22 23 @Implementation get(int key, int valueIfKeyNotFound)24 public int get(int key, int valueIfKeyNotFound){ 25 return sparseArray.get( key, valueIfKeyNotFound ); 26 } 27 28 @Implementation put( int key, int value )29 public void put( int key, int value ){ 30 sparseArray.put( key, value ); 31 } 32 33 @Implementation size()34 public int size() { 35 return sparseArray.size(); 36 } 37 38 @Implementation indexOfValue( int value )39 public int indexOfValue( int value ) { 40 return sparseArray.indexOfValue( value ); 41 } 42 43 @Implementation keyAt( int index )44 public int keyAt( int index ){ 45 return sparseArray.keyAt( index ); 46 } 47 48 @Implementation valueAt( int index )49 public int valueAt( int index ){ 50 return sparseArray.valueAt( index ); 51 } 52 53 @Implementation 54 @Override clone()55 public SparseIntArray clone() { 56 SparseIntArray clone = new SparseIntArray(); 57 for (int i = 0, length = size(); i < length; i++) { 58 clone.put( keyAt(i), valueAt(i) ); 59 } 60 return clone; 61 } 62 } 63