1 | /* This file was generated by SableCC (http://www.sablecc.org/). */ |
2 | |
3 | package uk.co.zonetora.fj.ast.node; |
4 | |
5 | import java.util.*; |
6 | |
7 | public class TypedLinkedList extends LinkedList |
8 | { |
9 | Cast cast; |
10 | |
11 | public TypedLinkedList() |
12 | { |
13 | super(); |
14 | |
15 | cast = NoCast.instance; |
16 | } |
17 | |
18 | public TypedLinkedList(Collection c) |
19 | { |
20 | super(); |
21 | cast = NoCast.instance; |
22 | this.addAll(c); |
23 | } |
24 | |
25 | public TypedLinkedList(Cast cast) |
26 | { |
27 | super(); |
28 | |
29 | this.cast = cast; |
30 | } |
31 | |
32 | public TypedLinkedList(Collection c, Cast cast) |
33 | { |
34 | super(); |
35 | this.cast = cast; |
36 | this.addAll(c); |
37 | } |
38 | |
39 | public Cast getCast() |
40 | { |
41 | return cast; |
42 | } |
43 | |
44 | public void add(int index, Object element) |
45 | { |
46 | super.add(index, cast.cast(element)); |
47 | } |
48 | |
49 | public boolean add(Object o) |
50 | { |
51 | return super.add(cast.cast(o)); |
52 | } |
53 | |
54 | public boolean addAll(Collection c) |
55 | { |
56 | for(Iterator i = c.iterator(); i.hasNext(); ) |
57 | { |
58 | super.add(cast.cast(i.next())); |
59 | } |
60 | return true; |
61 | } |
62 | |
63 | public boolean addAll(int index, Collection c) |
64 | { |
65 | int pos = index; |
66 | for(Iterator i = c.iterator(); i.hasNext(); ) |
67 | { |
68 | super.add(pos++, cast.cast(i.next())); |
69 | } |
70 | return true; |
71 | } |
72 | |
73 | public void addFirst(Object o) |
74 | { |
75 | super.addFirst(cast.cast(o)); |
76 | } |
77 | |
78 | public void addLast(Object o) |
79 | { |
80 | super.addLast(cast.cast(o)); |
81 | } |
82 | |
83 | public ListIterator listIterator(int index) |
84 | { |
85 | return new TypedLinkedListIterator(super.listIterator(index)); |
86 | } |
87 | |
88 | private class TypedLinkedListIterator implements ListIterator |
89 | { |
90 | ListIterator iterator; |
91 | |
92 | TypedLinkedListIterator(ListIterator iterator) |
93 | { |
94 | this.iterator = iterator; |
95 | } |
96 | |
97 | public boolean hasNext() |
98 | { |
99 | return iterator.hasNext(); |
100 | } |
101 | |
102 | public Object next() |
103 | { |
104 | return iterator.next(); |
105 | } |
106 | |
107 | public boolean hasPrevious() |
108 | { |
109 | return iterator.hasPrevious(); |
110 | } |
111 | |
112 | public Object previous() |
113 | { |
114 | return iterator.previous(); |
115 | } |
116 | |
117 | public int nextIndex() |
118 | { |
119 | return iterator.nextIndex(); |
120 | } |
121 | |
122 | public int previousIndex() |
123 | { |
124 | return iterator.previousIndex(); |
125 | } |
126 | |
127 | public void remove() |
128 | { |
129 | iterator.remove(); |
130 | } |
131 | |
132 | public void set(Object o) |
133 | { |
134 | iterator.set(cast.cast(o)); |
135 | } |
136 | |
137 | public void add(Object o) |
138 | { |
139 | iterator.add(cast.cast(o)); |
140 | } |
141 | } |
142 | } |