1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package com.ochafik.lang.jnaerator.parser;
20
21 import java.util.Collection;
22 import java.util.Iterator;
23 import java.util.List;
24 import java.util.ListIterator;
25
26 public class SemiUnmodifiableList<T> implements List<T> {
27 List<T> list;
28 List<T> getList() {
29 return list;
30 }
31 public SemiUnmodifiableList(List<T> list) {
32 this.list = list;
33 }
34 public boolean add(T o) {
35 throw new UnsupportedOperationException();
36 }
37 public void add(int index, T element) {
38 throw new UnsupportedOperationException();
39 }
40 public boolean addAll(Collection<? extends T> c) {
41 throw new UnsupportedOperationException();
42 }
43 public boolean addAll(int index, Collection<? extends T> c) {
44 throw new UnsupportedOperationException();
45 }
46 public void clear() {
47 throw new UnsupportedOperationException();
48 }
49 public boolean contains(Object o) {
50 return list.contains(o);
51 }
52 public boolean containsAll(Collection<?> c) {
53 return list.containsAll(c);
54 }
55 public T get(int index) {
56 return list.get(index);
57 }
58 public int indexOf(Object o) {
59 return list.indexOf(o);
60 }
61 public boolean isEmpty() {
62 return list.isEmpty();
63 }
64 public Iterator<T> iterator() {
65 return new Iterator<T>() {
66 Iterator<T> it = list.iterator();
67
68 public boolean hasNext() {
69 return it.hasNext();
70 }
71
72 public T next() {
73 return it.next();
74 }
75
76 public void remove() {
77 throw new UnsupportedOperationException();
78 }
79 };
80 }
81 public int lastIndexOf(Object o) {
82 return list.lastIndexOf(o);
83 }
84 public ListIterator<T> listIterator() {
85 return listIterator(0);
86 }
87 public ListIterator<T> listIterator(final int index) {
88 return new ListIterator<T>() {
89 ListIterator<T> it = list.listIterator(index);
90
91 public boolean hasNext() {
92 return it.hasNext();
93 }
94
95 public T next() {
96 return it.next();
97 }
98
99 public void remove() {
100 throw new UnsupportedOperationException();
101 }
102
103 public void add(T o) {
104 throw new UnsupportedOperationException();
105 }
106
107 public boolean hasPrevious() {
108 return it.hasPrevious();
109 }
110
111 public int nextIndex() {
112 return it.nextIndex();
113 }
114
115 public T previous() {
116 return it.previous();
117 }
118
119 public int previousIndex() {
120 return it.previousIndex();
121 }
122
123 public void set(T o) {
124 throw new UnsupportedOperationException();
125 }
126 };
127 }
128 public boolean remove(Object o) {
129 throw new UnsupportedOperationException();
130 }
131 public T remove(int index) {
132 throw new UnsupportedOperationException();
133 }
134 public boolean removeAll(Collection<?> c) {
135 throw new UnsupportedOperationException();
136 }
137 public boolean retainAll(Collection<?> c) {
138 throw new UnsupportedOperationException();
139 }
140 public T set(int index, T element) {
141 throw new UnsupportedOperationException();
142 }
143 public int size() {
144 return list.size();
145 }
146 public List<T> subList(int fromIndex, int toIndex) {
147 return new SemiUnmodifiableList<T>(list.subList(fromIndex, toIndex));
148 }
149 public Object[] toArray() {
150 return list.toArray();
151 }
152 public <U> U[] toArray(U[] a) {
153 return list.toArray(a);
154 }
155 @Override
156 public String toString() {
157 return list.toString();
158 }
159 }