1 4 package com.tc.util; 5 6 import com.tc.object.SerializationUtil; 7 import com.tc.object.bytecode.ManagerUtil; 8 9 import java.util.List ; 10 import java.util.ListIterator ; 11 12 public class ListIteratorWrapper implements ListIterator { 13 14 private final List list; 15 private final ListIterator realIterator; 16 private Object current; 17 private int currentIndex; 18 19 public ListIteratorWrapper(List list, ListIterator realIterator) { 20 this.list = list; 21 this.realIterator = realIterator; 22 this.currentIndex = -1; 23 } 24 25 public void add(Object arg0) { 26 ManagerUtil.checkWriteAccess(list); 27 currentIndex = nextIndex(); 28 realIterator.add(arg0); 29 current = arg0; 30 ManagerUtil.logicalInvoke(list, SerializationUtil.ADD_AT_SIGNATURE, 31 new Object [] { new Integer (currentIndex), arg0 }); 32 } 33 34 public boolean hasNext() { 35 return realIterator.hasNext(); 36 } 37 38 public boolean hasPrevious() { 39 return realIterator.hasPrevious(); 40 } 41 42 public Object next() { 43 currentIndex = nextIndex(); 44 current = realIterator.next(); 45 return current; 46 } 47 48 public int nextIndex() { 49 return realIterator.nextIndex(); 50 } 51 52 public Object previous() { 53 currentIndex = previousIndex(); 54 current = realIterator.previous(); 55 return current; 56 } 57 58 public int previousIndex() { 59 return realIterator.previousIndex(); 60 } 61 62 public void remove() { 63 ManagerUtil.checkWriteAccess(list); 64 realIterator.remove(); 65 ManagerUtil.logicalInvoke(list, SerializationUtil.REMOVE_AT_SIGNATURE, new Object [] { new Integer (currentIndex) }); 66 } 67 68 public void set(Object arg0) { 69 ManagerUtil.checkWriteAccess(list); 70 realIterator.set(arg0); 71 current = arg0; 72 ManagerUtil.logicalInvoke(list, SerializationUtil.SET_SIGNATURE, 73 new Object [] { new Integer (currentIndex), current }); 74 } 75 76 } 77 | Popular Tags |