KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > tax > traversal > TreeNodeIterator


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 package org.netbeans.tax.traversal;
20
21 import org.netbeans.tax.TreeNode;
22 import org.netbeans.tax.InvalidStateException;
23
24 /**
25  *
26  * @author Libor Kramolis
27  * @version 0.1
28  */

29 public final class TreeNodeIterator {
30     /** Root node of this iterator. */
31     private TreeNode root;
32
33     /** Determines which node types are presented. */
34     private int whatToShow;
35
36     /** Filter to screen nodes. */
37     private TreeNodeFilter filter;
38
39     /** State of iterator. */
40     private boolean valid;
41
42
43     /** Creates new TreeNodeIterator.
44      * @param node root node
45      * @param wTS what to show
46      * @param f used filter
47      */

48     public TreeNodeIterator (TreeNode node, int wTS, TreeNodeFilter f) {
49         root = node;
50         whatToShow = wTS;
51         filter = f;
52         
53         valid = true;
54     }
55     
56     
57     /**
58      */

59     public TreeNode getRoot () {
60         return root;
61     }
62     
63     /**
64      */

65     public int getWhatToShow () {
66         return whatToShow;
67     }
68     
69     /**
70      */

71     public TreeNodeFilter getFilter () {
72         return filter;
73     }
74     
75     /**
76      */

77     public TreeNode nextNode () throws InvalidStateException {
78         if (!!! valid) {
79             throw new InvalidStateException (Util.THIS.getString ("EXC_TreeNodeIterator.nextNode"));
80         }
81         
82         if ( Util.THIS.isLoggable() ) /* then */ Util.THIS.debug ("[PENDING]: TreeNodeIterator.nextNode ()"); // NOI18N
83
return null;
84     }
85     
86     /**
87      */

88     public TreeNode previousNode () throws InvalidStateException {
89         if (!!! valid) {
90             throw new InvalidStateException (Util.THIS.getString ("EXC_TreeNodeIterator.previousNode"));
91         }
92         
93         if ( Util.THIS.isLoggable() ) /* then */ Util.THIS.debug ("[PENDING]: TreeNodeIterator.nextNode ()"); // NOI18N
94
return null;
95     }
96     
97     /**
98      */

99     public void detach () {
100         valid = false;
101     }
102     
103 }
104
Popular Tags