View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.myfaces.custom.tree;
20  
21  import java.util.Iterator;
22  
23  /**
24   * Defines the requirements for an object that can be used as a tree node for
25   * {@link HtmlTree}. (inspired by javax.swing.tree.TreeNode).
26   *
27   * @author <a href="mailto:oliver@rossmueller.com">Oliver Rossmueller </a>
28   * @version $Revision: 472638 $ $Date: 2006-11-08 15:54:13 -0500 (Wed, 08 Nov 2006) $
29   */
30  public interface TreeNode
31  {
32  
33      /**
34       * @return Gets the user object of this node.
35       */
36      Object getUserObject();
37  
38      /**
39       * Answer the child at the given index.
40       */
41      TreeNode getChildAt(int childIndex);
42  
43      /**
44       * Answer the number of children this node contains.
45       */
46      int getChildCount();
47  
48      /**
49       * Answer the parent of this node.
50       */
51      TreeNode getParent();
52  
53      /**
54       * Answer the index of the given node in this node's children.
55       */
56      int getIndex(TreeNode node);
57  
58      /**
59       * Answer true if this node allows children.
60       */
61      boolean getAllowsChildren();
62  
63      /**
64       * Answer true if this is a leaf node.
65       */
66      boolean isLeaf();
67  
68      /**
69       * Answer the children of the receiver. The base collection is unmodifyable.
70       */
71      Iterator children();
72  
73  }