1 19 package bak.pcj.adapter; 20 21 import bak.pcj.Adapter; 22 import bak.pcj.list.AbstractLongList; 23 import bak.pcj.list.LongListIterator; 24 import bak.pcj.util.Exceptions; 25 26 import java.util.List ; 27 28 63 public class ListToLongListAdapter extends AbstractLongList { 64 65 66 protected List list; 67 68 82 public ListToLongListAdapter(List list) { 83 this(list, false); 84 } 85 86 110 public ListToLongListAdapter(List list, boolean validate) { 111 super(); 112 if (list == null) 113 Exceptions.nullArgument("list"); 114 this.list = list; 115 if (validate) 116 evalidate(); 117 } 118 119 public void add(int index, long v) 120 { list.add(index, new Long (v)); } 121 122 public long get(int index) 123 { return ((Long )list.get(index)).longValue(); } 124 125 public LongListIterator listIterator(int index) 126 { return new ListIteratorToLongListIteratorAdapter(list.listIterator(index)); } 127 128 public long removeElementAt(int index) 129 { return ((Long )(list.remove(index))).longValue(); } 130 131 public long set(int index, long v) 132 { return ((Long )list.set(index, new Long (v))).longValue(); } 133 134 public int size() 135 { return list.size(); } 136 137 146 public boolean validate() 147 { return Adapter.isLongAdaptable(list); } 148 149 158 public void evalidate() { 159 if (!validate()) 160 Exceptions.cannotAdapt("list"); 161 } 162 163 } | Popular Tags |