001 package com.mockrunner.mock.connector.cci; 002 003 import java.util.ArrayList; 004 import java.util.Collection; 005 import java.util.Iterator; 006 import java.util.List; 007 import java.util.ListIterator; 008 009 import javax.resource.cci.IndexedRecord; 010 011 import com.mockrunner.base.NestedApplicationException; 012 013 /** 014 * Mock implementation of <code>IndexedRecord</code>. 015 */ 016 public class MockIndexedRecord extends MockRecord implements IndexedRecord 017 { 018 private List backingList; 019 020 public MockIndexedRecord() 021 { 022 this("MockrunnerGenericIndexedRecord"); 023 } 024 025 public MockIndexedRecord(String name) 026 { 027 this(name, name); 028 } 029 030 public MockIndexedRecord(String name, String description) 031 { 032 super(name, description); 033 backingList = new ArrayList(); 034 } 035 036 public int size() 037 { 038 return backingList.size(); 039 } 040 041 public boolean isEmpty() 042 { 043 return backingList.isEmpty(); 044 } 045 046 public boolean contains(Object object) 047 { 048 return backingList.contains(object); 049 } 050 051 public Iterator iterator() 052 { 053 return backingList.iterator(); 054 } 055 056 public Object[] toArray() 057 { 058 return backingList.toArray(); 059 } 060 061 public Object[] toArray(Object[] object) 062 { 063 return backingList.toArray(object); 064 } 065 066 public boolean add(Object object) 067 { 068 return backingList.add(object); 069 } 070 071 public boolean remove(Object object) 072 { 073 return backingList.remove(object); 074 } 075 076 public boolean containsAll(Collection collection) 077 { 078 return backingList.containsAll(collection); 079 } 080 081 public boolean addAll(Collection collection) 082 { 083 return backingList.addAll(collection); 084 } 085 086 public boolean addAll(int index, Collection collection) 087 { 088 return backingList.addAll(index, collection); 089 } 090 091 public boolean removeAll(Collection collection) 092 { 093 return backingList.removeAll(collection); 094 } 095 096 public boolean retainAll(Collection collection) 097 { 098 return backingList.retainAll(collection); 099 } 100 101 public void clear() 102 { 103 backingList.clear(); 104 } 105 106 public Object get(int index) 107 { 108 return backingList.get(index); 109 } 110 111 public Object set(int index, Object object) 112 { 113 return backingList.set(index, object); 114 } 115 116 public void add(int index, Object object) 117 { 118 backingList.add(index, object); 119 } 120 121 public Object remove(int index) 122 { 123 return backingList.remove(index); 124 } 125 126 public int indexOf(Object object) 127 { 128 return backingList.indexOf(object); 129 } 130 131 public int lastIndexOf(Object object) 132 { 133 return backingList.lastIndexOf(object); 134 } 135 136 public ListIterator listIterator() 137 { 138 return backingList.listIterator(); 139 } 140 141 public ListIterator listIterator(int index) 142 { 143 return backingList.listIterator(index); 144 } 145 146 public List subList(int fromIndex, int toIndex) 147 { 148 return backingList.subList(fromIndex, toIndex); 149 } 150 151 public boolean equals(Object object) 152 { 153 if(!super.equals(object)) return false; 154 MockIndexedRecord other = (MockIndexedRecord)object; 155 return backingList.equals(other.backingList); 156 } 157 158 public int hashCode() 159 { 160 return super.hashCode() * 31 + backingList.hashCode(); 161 } 162 163 public String toString() 164 { 165 return super.toString() + "\n" + backingList.toString(); 166 } 167 168 public Object clone() 169 { 170 try 171 { 172 MockIndexedRecord clone = (MockIndexedRecord)super.clone(); 173 clone.backingList = new ArrayList(this.backingList); 174 return clone; 175 } 176 catch(Exception exc) 177 { 178 throw new NestedApplicationException(exc); 179 } 180 } 181 }