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.tree2;
20  
21  import javax.faces.component.NamingContainer;
22  import java.io.Serializable;
23  
24  
25  /**
26   * Model class for the tree component.  It provides random access to nodes in a tree
27   * made up of instances of the {@link TreeNode} class.
28   *
29   * @author Sean Schofield
30   * @version $Revision: 472638 $ $Date: 2006-11-08 15:54:13 -0500 (Wed, 08 Nov 2006) $
31   */
32  public interface TreeModel extends Serializable
33  {
34      /**
35       * Separator char to be used in node path generation.
36       */
37      public final static String SEPARATOR = String.valueOf(NamingContainer.SEPARATOR_CHAR);
38  
39  
40  
41      /**
42       * Gets an array of String containing the ID's of all of the {@link TreeNode}s in the path to
43       * the specified node.  The path information will be an array of <code>String</code> objects
44       * representing node ID's. The array will starting with the ID of the root node and end with
45       * the ID of the specified node.
46       *
47       * @param nodeId The id of the node for whom the path information is needed.
48       * @return String[]
49       */
50      public String[] getPathInformation(String nodeId);
51  
52      /**
53       * Indicates whether or not the specified {@link TreeNode} is the last child in the <code>List</code>
54       * of children.  If the node id provided corresponds to the root node, this returns <code>true</code>.
55       *
56       * @param nodeId The ID of the node to check
57       * @return boolean
58       */
59      public boolean isLastChild(String nodeId);
60  
61      public TreeNode getNodeById(String nodeId);
62      //public String getNodeId(TreeNode node);
63  
64      public void setTreeState(TreeState state);
65      public TreeState getTreeState();
66  
67      /**
68       * Gets the TreeWalker associated with the model.  Allows the user to customize the manner in which nodes
69       * are walked by the renderer.
70       *
71       * @return TreeWalker
72       */
73      public TreeWalker getTreeWalker();
74  
75  }