1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| |
7 |
| |
8 |
| package org.dom4j.tree; |
9 |
| |
10 |
| import java.util.AbstractList; |
11 |
| import java.util.Collection; |
12 |
| import java.util.Iterator; |
13 |
| import java.util.List; |
14 |
| |
15 |
| import org.dom4j.IllegalAddException; |
16 |
| import org.dom4j.Node; |
17 |
| |
18 |
| |
19 |
| |
20 |
| |
21 |
| |
22 |
| |
23 |
| |
24 |
| |
25 |
| |
26 |
| |
27 |
| |
28 |
| |
29 |
| |
30 |
| |
31 |
| public class ContentListFacade extends AbstractList { |
32 |
| |
33 |
| private List branchContent; |
34 |
| |
35 |
| |
36 |
| private AbstractBranch branch; |
37 |
| |
38 |
5000
| public ContentListFacade(AbstractBranch branch, List branchContent) {
|
39 |
5000
| this.branch = branch;
|
40 |
5000
| this.branchContent = branchContent;
|
41 |
| } |
42 |
| |
43 |
0
| public boolean add(Object object) {
|
44 |
0
| branch.childAdded(asNode(object));
|
45 |
| |
46 |
0
| return branchContent.add(object);
|
47 |
| } |
48 |
| |
49 |
6
| public void add(int index, Object object) {
|
50 |
6
| branch.childAdded(asNode(object));
|
51 |
6
| branchContent.add(index, object);
|
52 |
| } |
53 |
| |
54 |
1
| public Object set(int index, Object object) {
|
55 |
1
| branch.childAdded(asNode(object));
|
56 |
| |
57 |
1
| return branchContent.set(index, object);
|
58 |
| } |
59 |
| |
60 |
0
| public boolean remove(Object object) {
|
61 |
0
| branch.childRemoved(asNode(object));
|
62 |
| |
63 |
0
| return branchContent.remove(object);
|
64 |
| } |
65 |
| |
66 |
0
| public Object remove(int index) {
|
67 |
0
| Object object = branchContent.remove(index);
|
68 |
| |
69 |
0
| if (object != null) {
|
70 |
0
| branch.childRemoved(asNode(object));
|
71 |
| } |
72 |
| |
73 |
0
| return object;
|
74 |
| } |
75 |
| |
76 |
0
| public boolean addAll(Collection collection) {
|
77 |
0
| int count = branchContent.size();
|
78 |
| |
79 |
0
| for (Iterator iter = collection.iterator(); iter.hasNext(); count++) {
|
80 |
0
| add(iter.next());
|
81 |
| } |
82 |
| |
83 |
0
| return count == branchContent.size();
|
84 |
| } |
85 |
| |
86 |
0
| public boolean addAll(int index, Collection collection) {
|
87 |
0
| int count = branchContent.size();
|
88 |
| |
89 |
0
| for (Iterator iter = collection.iterator(); iter.hasNext(); count--) {
|
90 |
0
| add(index++, iter.next());
|
91 |
| } |
92 |
| |
93 |
0
| return count == branchContent.size();
|
94 |
| } |
95 |
| |
96 |
0
| public void clear() {
|
97 |
0
| for (Iterator iter = iterator(); iter.hasNext();) {
|
98 |
0
| Object object = iter.next();
|
99 |
0
| branch.childRemoved(asNode(object));
|
100 |
| } |
101 |
| |
102 |
0
| branchContent.clear();
|
103 |
| } |
104 |
| |
105 |
0
| public boolean removeAll(Collection c) {
|
106 |
0
| for (Iterator iter = c.iterator(); iter.hasNext();) {
|
107 |
0
| Object object = iter.next();
|
108 |
0
| branch.childRemoved(asNode(object));
|
109 |
| } |
110 |
| |
111 |
0
| return branchContent.removeAll(c);
|
112 |
| } |
113 |
| |
114 |
5168
| public int size() {
|
115 |
5168
| return branchContent.size();
|
116 |
| } |
117 |
| |
118 |
0
| public boolean isEmpty() {
|
119 |
0
| return branchContent.isEmpty();
|
120 |
| } |
121 |
| |
122 |
0
| public boolean contains(Object o) {
|
123 |
0
| return branchContent.contains(o);
|
124 |
| } |
125 |
| |
126 |
0
| public Object[] toArray() {
|
127 |
0
| return branchContent.toArray();
|
128 |
| } |
129 |
| |
130 |
0
| public Object[] toArray(Object[] a) {
|
131 |
0
| return branchContent.toArray(a);
|
132 |
| } |
133 |
| |
134 |
0
| public boolean containsAll(Collection c) {
|
135 |
0
| return branchContent.containsAll(c);
|
136 |
| } |
137 |
| |
138 |
13434
| public Object get(int index) {
|
139 |
13434
| return branchContent.get(index);
|
140 |
| } |
141 |
| |
142 |
3
| public int indexOf(Object o) {
|
143 |
3
| return branchContent.indexOf(o);
|
144 |
| } |
145 |
| |
146 |
0
| public int lastIndexOf(Object o) {
|
147 |
0
| return branchContent.lastIndexOf(o);
|
148 |
| } |
149 |
| |
150 |
7
| protected Node asNode(Object object) {
|
151 |
7
| if (object instanceof Node) {
|
152 |
7
| return (Node) object;
|
153 |
| } else { |
154 |
0
| throw new IllegalAddException(
|
155 |
| "This list must contain instances of " |
156 |
| + "Node. Invalid type: " + object); |
157 |
| } |
158 |
| } |
159 |
| |
160 |
3
| protected List getBackingList() {
|
161 |
3
| return branchContent;
|
162 |
| } |
163 |
| } |
164 |
| |
165 |
| |
166 |
| |
167 |
| |
168 |
| |
169 |
| |
170 |
| |
171 |
| |
172 |
| |
173 |
| |
174 |
| |
175 |
| |
176 |
| |
177 |
| |
178 |
| |
179 |
| |
180 |
| |
181 |
| |
182 |
| |
183 |
| |
184 |
| |
185 |
| |
186 |
| |
187 |
| |
188 |
| |
189 |
| |
190 |
| |
191 |
| |
192 |
| |
193 |
| |
194 |
| |
195 |
| |
196 |
| |
197 |
| |
198 |
| |
199 |
| |
200 |
| |