1 16 package org.apache.commons.collections.iterators; 17 18 import java.util.ListIterator ; 19 20 import org.apache.commons.collections.Unmodifiable; 21 22 30 public final class UnmodifiableListIterator implements ListIterator , Unmodifiable { 31 32 33 private ListIterator iterator; 34 35 42 public static ListIterator decorate(ListIterator iterator) { 43 if (iterator == null) { 44 throw new IllegalArgumentException ("ListIterator must not be null"); 45 } 46 if (iterator instanceof Unmodifiable) { 47 return iterator; 48 } 49 return new UnmodifiableListIterator(iterator); 50 } 51 52 58 private UnmodifiableListIterator(ListIterator iterator) { 59 super(); 60 this.iterator = iterator; 61 } 62 63 public boolean hasNext() { 65 return iterator.hasNext(); 66 } 67 68 public Object next() { 69 return iterator.next(); 70 } 71 72 public int nextIndex() { 73 return iterator.nextIndex(); 74 } 75 76 public boolean hasPrevious() { 77 return iterator.hasPrevious(); 78 } 79 80 public Object previous() { 81 return iterator.previous(); 82 } 83 84 public int previousIndex() { 85 return iterator.previousIndex(); 86 } 87 88 public void remove() { 89 throw new UnsupportedOperationException ("remove() is not supported"); 90 } 91 92 public void set(Object obj) { 93 throw new UnsupportedOperationException ("set() is not supported"); 94 } 95 96 public void add(Object obj) { 97 throw new UnsupportedOperationException ("add() is not supported"); 98 } 99 100 } 101 | Popular Tags |