1 | /* |
2 | * JTiger Unit Testing Framework for J2SE 1.5 |
3 | * Copyright (C) 2005 Tony Morris |
4 | * |
5 | * This software is licenced under the |
6 | * Common Public Licence version 1.0 |
7 | * http://www.opensource.org/licenses/cpl1.0.php |
8 | * |
9 | * You received a copy of this licence with this software. |
10 | */ |
11 | package org.jtiger.framework; |
12 | |
13 | import java.util.ListIterator; |
14 | |
15 | final class UnmodifiableListIteratorFactory |
16 | { |
17 | private UnmodifiableListIteratorFactory() |
18 | { |
19 | |
20 | } |
21 | |
22 | static <E> ListIterator<E> unmodifiableListIterator(final ListIterator<E> i) throws NullPointerException |
23 | { |
24 | if(i == null) |
25 | { |
26 | throw new NullPointerException(); |
27 | } |
28 | |
29 | return new UnmodifiableListIterator<E>(i); |
30 | } |
31 | |
32 | private static final class UnmodifiableListIterator<E> implements ListIterator<E> |
33 | { |
34 | private final ListIterator<E> i; |
35 | |
36 | UnmodifiableListIterator(final ListIterator<E> i) |
37 | { |
38 | this.i = i; |
39 | } |
40 | |
41 | public boolean hasNext() |
42 | { |
43 | return i.hasNext(); |
44 | } |
45 | |
46 | public E next() |
47 | { |
48 | return i.next(); |
49 | } |
50 | |
51 | public boolean hasPrevious() |
52 | { |
53 | return i.hasPrevious(); |
54 | } |
55 | |
56 | public E previous() |
57 | { |
58 | return i.previous(); |
59 | } |
60 | |
61 | public int nextIndex() |
62 | { |
63 | return i.nextIndex(); |
64 | } |
65 | |
66 | public int previousIndex() |
67 | { |
68 | return i.previousIndex(); |
69 | } |
70 | |
71 | public void remove() |
72 | { |
73 | throw new UnsupportedOperationException(); |
74 | } |
75 | |
76 | public void set(final E e) |
77 | { |
78 | throw new UnsupportedOperationException(); |
79 | } |
80 | |
81 | public void add(final E e) |
82 | { |
83 | throw new UnsupportedOperationException(); |
84 | } |
85 | } |
86 | } |