KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > tax > TreeNodeDecl


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;
20
21 import java.util.List JavaDoc;
22 import java.util.LinkedList JavaDoc;
23
24 import org.netbeans.tax.event.TreeEventManager;
25
26 /**
27  *
28  * @author Libor Kramolis
29  * @version 0.1
30  */

31 public abstract class TreeNodeDecl extends TreeChild {
32
33     // /** */
34
// public static final String PROP_OWNER_DTD = "ownerDTD"; // NOI18N
35

36     /** */
37     // private TokenList tokenList;
38

39     //
40
// init
41
//
42

43     /**
44      * Creates new TreeNodeDecl.
45      */

46     protected TreeNodeDecl () {
47         super ();
48
49         // tokenList = new TokenList();
50
}
51     
52     
53     /** Creates new TreeNodeDecl -- copy constructor. */
54     protected TreeNodeDecl (TreeNodeDecl nodeDecl) {
55         super (nodeDecl);
56     }
57     
58     
59     //
60
// itself
61
//
62

63     /**
64      */

65     public final TreeDTDRoot getOwnerDTD () {
66         TreeDocumentRoot doc = getOwnerDocument ();
67         
68         if (doc instanceof TreeDTDRoot)
69             return (TreeDTDRoot)doc;
70         
71         if (doc instanceof TreeDocument)
72             return ((TreeDocument)doc).getDocumentType ();
73         
74         return null;
75     }
76     
77     
78     
79     //
80
// Tokens
81
//
82

83     /**
84      *
85      */

86     protected static class TokenList {
87         /** */
88         private List JavaDoc tokenList;
89         
90         /** */
91         // private Map tokenMap;
92

93         
94         public TokenList () {
95             tokenList = new LinkedList JavaDoc ();
96             // tokenMap = new HashMap();
97
}
98         
99         
100         public void add (Object JavaDoc token) {
101             tokenList.add (token);
102         }
103         
104 /* public void associate (String property, Object token) {
105             if (!!! tokenList.contains (token)) {
106                 return addToken (token);
107             }
108             tokenMap.put (property, token);
109         }*/

110         
111         public void remove (Object JavaDoc token) {
112             tokenList.remove (token);
113         }
114         
115         public int size () {
116             return tokenList.size ();
117         }
118         
119     }
120     
121     
122     //
123
// content
124
//
125

126     /**
127      *
128      */

129     public abstract static class Content extends TreeObject {
130         
131         /** */
132         private TreeNodeDecl nodeDecl;
133         
134         //
135
// init
136
//
137

138         /** Creates new Content. */
139         protected Content (TreeNodeDecl nodeDecl) {
140             super ();
141             
142             this.nodeDecl = nodeDecl;
143         }
144         
145         /**
146          * Creates new Content. //??? is such content valid?
147          */

148         protected Content () {
149             this ((TreeNodeDecl)null);
150         }
151         
152         /** Creates new Content -- copy constructor. */
153         protected Content (Content content) {
154             super (content);
155             
156             this.nodeDecl = content.nodeDecl;
157         }
158         
159         
160         //
161
// context
162
//
163

164         /**
165          */

166         public final boolean isInContext () {
167             return ( getNodeDecl () != null );
168         }
169         
170         
171         //
172
// itself
173
//
174

175         /**
176          */

177         public final TreeNodeDecl getNodeDecl () {
178             return nodeDecl;
179         }
180         
181         /**
182          */

183         protected void setNodeDecl (TreeNodeDecl nodeDecl) {
184             this.nodeDecl = nodeDecl;
185         }
186         
187         //
188
// event model
189
//
190

191         /** Get assigned event manager assigned to ownerDocument. If this node does not have its one, it returns null;
192          * @return assigned event manager (may be null).
193          */

194         public final TreeEventManager getEventManager () {
195             return nodeDecl.getEventManager ();
196         }
197         
198     } // end: class Content
199

200 } // end: class TreeNodeDecl
201
Popular Tags