Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
ITreeDataModel |
|
| 1.0;1 |
1 | // Copyright 2004, 2005 The Apache Software Foundation | |
2 | // | |
3 | // Licensed under the Apache License, Version 2.0 (the "License"); | |
4 | // you may not use this file except in compliance with the License. | |
5 | // You may obtain a copy of the License at | |
6 | // | |
7 | // http://www.apache.org/licenses/LICENSE-2.0 | |
8 | // | |
9 | // Unless required by applicable law or agreed to in writing, software | |
10 | // distributed under the License is distributed on an "AS IS" BASIS, | |
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
12 | // See the License for the specific language governing permissions and | |
13 | // limitations under the License. | |
14 | ||
15 | package org.apache.tapestry.contrib.tree.model; | |
16 | ||
17 | import java.util.Iterator; | |
18 | ||
19 | /** | |
20 | * The interface that defines a suitable data model for a | |
21 | * <code>TreeView component</code>. | |
22 | * | |
23 | * @author ceco | |
24 | */ | |
25 | public interface ITreeDataModel | |
26 | { | |
27 | ||
28 | /** | |
29 | * Returns the root node of the tree. | |
30 | */ | |
31 | Object getRoot(); | |
32 | ||
33 | /** | |
34 | * Returns the number of children of parent node. | |
35 | * | |
36 | * @param objParent | |
37 | * is the parent object whose nr of children are sought | |
38 | */ | |
39 | int getChildCount(Object objParent); | |
40 | ||
41 | /** | |
42 | * Get an iterator to the Collection of children belonging to the parent | |
43 | * node object. | |
44 | * | |
45 | * @param objParent | |
46 | * is the parent object whose children are requested | |
47 | */ | |
48 | Iterator getChildren(Object objParent); | |
49 | ||
50 | /** | |
51 | * Get the actual node object based on some identifier (for example an UUID). | |
52 | * | |
53 | * @param objUniqueKey | |
54 | * is the unique identifier of the node object being retrieved | |
55 | * @return the instance of the node object identified by the key | |
56 | */ | |
57 | Object getObject(Object objUniqueKey); | |
58 | ||
59 | /** | |
60 | * Get the unique identifier (UUID) of the node object with a certain parent | |
61 | * node. | |
62 | * | |
63 | * @param objTarget | |
64 | * is the Object whose identifier is required | |
65 | * @param objParentUniqueKey | |
66 | * is the unique id of the parent of objTarget | |
67 | * @return the unique identifier of objTarget | |
68 | */ | |
69 | Object getUniqueKey(Object objTarget, Object objParentUniqueKey); | |
70 | ||
71 | /** | |
72 | * Get the unique identifier of the parent of an object. | |
73 | * | |
74 | * @param objChildUniqueKey | |
75 | * is the identifier of the Object for which the parent | |
76 | * identifier is sought | |
77 | * @return the identifier (possibly UUID) of the parent of objChildUniqueKey | |
78 | */ | |
79 | Object getParentUniqueKey(Object objChildUniqueKey); | |
80 | ||
81 | /** | |
82 | * Check to see (on the basis of some node object identifier) whether the | |
83 | * parent node is indeed the parent of the object. | |
84 | * | |
85 | * @param objChildUniqueKey | |
86 | * is the identifier of the object whose parent is being checked | |
87 | * @param objParentUniqueKey | |
88 | * is the identifier of the parent which is to be checked against | |
89 | */ | |
90 | boolean isAncestorOf(Object objChildUniqueKey, Object objParentUniqueKey); | |
91 | ||
92 | } |