1 19 package bak.pcj.adapter; 20 21 import bak.pcj.list.ByteList; 22 import bak.pcj.list.ByteListIterator; 23 import bak.pcj.util.Exceptions; 24 25 import java.util.AbstractList ; 26 import java.util.ListIterator ; 27 import java.util.Collection ; 28 import java.util.AbstractCollection ; 29 30 43 public class ByteListToListAdapter extends AbstractList { 44 45 46 protected ByteList list; 47 48 58 public ByteListToListAdapter(ByteList list) { 59 if (list == null) 60 Exceptions.nullArgument("list"); 61 this.list = list; 62 } 63 64 109 public boolean addAll(int index, Collection c) { 110 if (index > size() || index < 0) 111 Exceptions.indexOutOfBounds(index, 0, size()); 112 return super.addAll(index, c); 113 } 114 115 143 public void add(int index, Object o) { 144 if (o == null) 145 Exceptions.nullElementNotAllowed(); 146 list.add(index, ((Byte )o).byteValue() ); 147 } 148 149 162 public Object get(int index) 163 { return new Byte (list.get(index)); } 164 165 178 public ListIterator listIterator(int index) 179 { return new ByteListIteratorToListIteratorAdapter(list.listIterator(index)); } 180 181 198 public Object remove(int index) 199 { return new Byte (list.removeElementAt(index)); } 200 201 227 public boolean removeAll(Collection c) { 228 if (c == null) 229 Exceptions.nullArgument("collection"); 230 return super.removeAll(c); 231 } 232 233 260 public boolean retainAll(Collection c) { 261 if (c == null) 262 Exceptions.nullArgument("collection"); 263 return super.retainAll(c); 264 } 265 266 292 public Object set(int index, Object o) { 293 if (o == null) 294 Exceptions.nullElementNotAllowed(); 295 return new Byte (list.set(index, ((Byte )o).byteValue())); 296 } 297 298 305 public int size() 306 { return list.size(); } 307 308 309 } | Popular Tags |