001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041: package org.netbeans.tax;
042:
043: import java.util.List;
044: import java.util.LinkedList;
045:
046: import org.netbeans.tax.event.TreeEventManager;
047:
048: /**
049: *
050: * @author Libor Kramolis
051: * @version 0.1
052: */
053: public abstract class TreeNodeDecl extends TreeChild {
054:
055: // /** */
056: // public static final String PROP_OWNER_DTD = "ownerDTD"; // NOI18N
057:
058: /** */
059: // private TokenList tokenList;
060: //
061: // init
062: //
063: /**
064: * Creates new TreeNodeDecl.
065: */
066: protected TreeNodeDecl() {
067: super ();
068:
069: // tokenList = new TokenList();
070: }
071:
072: /** Creates new TreeNodeDecl -- copy constructor. */
073: protected TreeNodeDecl(TreeNodeDecl nodeDecl) {
074: super (nodeDecl);
075: }
076:
077: //
078: // itself
079: //
080:
081: /**
082: */
083: public final TreeDTDRoot getOwnerDTD() {
084: TreeDocumentRoot doc = getOwnerDocument();
085:
086: if (doc instanceof TreeDTDRoot)
087: return (TreeDTDRoot) doc;
088:
089: if (doc instanceof TreeDocument)
090: return ((TreeDocument) doc).getDocumentType();
091:
092: return null;
093: }
094:
095: //
096: // Tokens
097: //
098:
099: /**
100: *
101: */
102: protected static class TokenList {
103: /** */
104: private List tokenList;
105:
106: /** */
107: // private Map tokenMap;
108:
109: public TokenList() {
110: tokenList = new LinkedList();
111: // tokenMap = new HashMap();
112: }
113:
114: public void add(Object token) {
115: tokenList.add(token);
116: }
117:
118: /* public void associate (String property, Object token) {
119: if (!!! tokenList.contains (token)) {
120: return addToken (token);
121: }
122: tokenMap.put (property, token);
123: }*/
124:
125: public void remove(Object token) {
126: tokenList.remove(token);
127: }
128:
129: public int size() {
130: return tokenList.size();
131: }
132:
133: }
134:
135: //
136: // content
137: //
138:
139: /**
140: *
141: */
142: public abstract static class Content extends TreeObject {
143:
144: /** */
145: private TreeNodeDecl nodeDecl;
146:
147: //
148: // init
149: //
150:
151: /** Creates new Content. */
152: protected Content(TreeNodeDecl nodeDecl) {
153: super ();
154:
155: this .nodeDecl = nodeDecl;
156: }
157:
158: /**
159: * Creates new Content. //??? is such content valid?
160: */
161: protected Content() {
162: this ((TreeNodeDecl) null);
163: }
164:
165: /** Creates new Content -- copy constructor. */
166: protected Content(Content content) {
167: super (content);
168:
169: this .nodeDecl = content.nodeDecl;
170: }
171:
172: //
173: // context
174: //
175:
176: /**
177: */
178: public final boolean isInContext() {
179: return (getNodeDecl() != null);
180: }
181:
182: //
183: // itself
184: //
185:
186: /**
187: */
188: public final TreeNodeDecl getNodeDecl() {
189: return nodeDecl;
190: }
191:
192: /**
193: */
194: protected void setNodeDecl(TreeNodeDecl nodeDecl) {
195: this .nodeDecl = nodeDecl;
196: }
197:
198: //
199: // event model
200: //
201:
202: /** Get assigned event manager assigned to ownerDocument. If this node does not have its one, it returns null;
203: * @return assigned event manager (may be null).
204: */
205: public final TreeEventManager getEventManager() {
206: return nodeDecl.getEventManager();
207: }
208:
209: } // end: class Content
210:
211: } // end: class TreeNodeDecl
|