1 package org.apache.maven.index.treeview;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.io.IOException;
23 import java.util.ArrayList;
24 import java.util.List;
25
26
27
28
29 public abstract class AbstractTreeNode
30 implements TreeNode
31 {
32
33
34
35 private String type;
36
37
38
39
40 private boolean leaf;
41
42
43
44
45 private String nodeName;
46
47
48
49
50 private String path;
51
52
53
54
55 private List<TreeNode> children;
56
57
58
59
60 private String groupId;
61
62
63
64
65 private String artifactId;
66
67
68
69
70 private String version;
71
72
73
74
75 private String repositoryId;
76
77 final private transient IndexTreeView treeView;
78
79 final private transient TreeViewRequest request;
80
81
82
83
84
85
86
87 public AbstractTreeNode( IndexTreeView tview, TreeViewRequest request )
88 {
89 this.treeView = tview;
90
91 this.request = request;
92 }
93
94
95
96
97
98
99 public Type getType()
100 {
101 return Type.valueOf( type );
102 }
103
104
105
106
107
108
109 public void setType( Type type )
110 {
111 this.type = type.name();
112 }
113
114
115
116
117
118
119 public boolean isLeaf()
120 {
121 return leaf;
122 }
123
124
125
126
127
128
129 public void setLeaf( boolean leaf )
130 {
131 this.leaf = leaf;
132 }
133
134
135
136
137
138
139 public String getNodeName()
140 {
141 return nodeName;
142 }
143
144
145
146
147
148
149 public void setNodeName( String nodeName )
150 {
151 this.nodeName = nodeName;
152 }
153
154
155
156
157
158
159 public String getPath()
160 {
161 return path;
162 }
163
164
165
166
167
168
169 public void setPath( String path )
170 {
171 this.path = path;
172 }
173
174
175
176
177
178
179 public String getGroupId()
180 {
181 return groupId;
182 }
183
184
185
186
187
188
189 public void setGroupId( String groupId )
190 {
191 this.groupId = groupId;
192 }
193
194
195
196
197
198
199 public String getArtifactId()
200 {
201 return artifactId;
202 }
203
204
205
206
207
208
209 public void setArtifactId( String artifactId )
210 {
211 this.artifactId = artifactId;
212 }
213
214
215
216
217
218
219 public String getVersion()
220 {
221 return version;
222 }
223
224
225
226
227
228
229 public void setVersion( String version )
230 {
231 this.version = version;
232 }
233
234
235
236
237
238
239 public String getRepositoryId()
240 {
241 return repositoryId;
242 }
243
244
245
246
247
248
249 public void setRepositoryId( String repositoryId )
250 {
251 this.repositoryId = repositoryId;
252 }
253
254
255
256
257
258
259
260
261 public List<TreeNode> getChildren()
262 {
263 if ( children == null && !isLeaf() )
264 {
265 children = new ArrayList<TreeNode>();
266 }
267
268 return children;
269 }
270
271
272
273
274
275
276
277 public List<TreeNode> listChildren()
278 throws IOException
279 {
280 if ( !isLeaf() && getChildren().isEmpty() && !isLeaf() )
281 {
282 children =
283 treeView.listNodes(
284 new TreeViewRequest( request.getFactory(), getPath(), request.getFieldHints(),
285 request.getArtifactInfoFilter(), request.getIndexingContext() ) ).getChildren();
286 }
287
288 return children;
289 }
290
291
292
293
294
295
296 public TreeNode findChildByPath( String path, Type type )
297 throws IOException
298 {
299 for ( TreeNode child : getChildren() )
300 {
301 if ( path.equals( child.getPath() ) && type.equals( child.getType() ) )
302 {
303 return child;
304 }
305 }
306
307 return null;
308 }
309 }