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