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:
042: /* Generated By:JJTree: Do not edit this line. SimpleNode.java */
043:
044: package org.netbeans.modules.debugger.jpda.expr;
045:
046: import java.util.*;
047:
048: class SimpleNode implements Node {
049: protected Node parent;
050: protected Node[] children;
051: protected int id;
052:
053: public SimpleNode(int i) {
054: id = i;
055: }
056:
057: public void jjtOpen() {
058: }
059:
060: public void jjtClose() {
061: }
062:
063: public void jjtSetParent(Node n) {
064: parent = n;
065: }
066:
067: public Node jjtGetParent() {
068: return parent;
069: }
070:
071: public void jjtAddChild(Node n, int i) {
072: if (children == null) {
073: children = new Node[i + 1];
074: } else if (i >= children.length) {
075: Node c[] = new Node[i + 1];
076: System.arraycopy(children, 0, c, 0, children.length);
077: children = c;
078: }
079: children[i] = n;
080: }
081:
082: public Node jjtGetChild(int i) {
083: return children[i];
084: }
085:
086: public int jjtGetNumChildren() {
087: return (children == null) ? 0 : children.length;
088: }
089:
090: /** Accept the visitor. **/
091: public Object jjtAccept(JavaParserVisitor visitor, Object data) {
092: return visitor.visit(this , data);
093: }
094:
095: /* You can override these two methods in subclasses of SimpleNode to
096: customize the way the node appears when the tree is dumped. If
097: your output uses more than one line you should override
098: toString(String), otherwise overriding toString() is probably all
099: you need to do. */
100:
101: public String toString() {
102: return JavaParserTreeConstants.jjtNodeName[id];
103: }
104:
105: public String toString(String prefix) {
106: return prefix + toString();
107: }
108:
109: /* Override this method if you want to customize how the node dumps
110: out its children. */
111:
112: public void dump(String prefix) {
113: System.out.println(toString(prefix));
114: if (children != null) {
115: for (int i = 0; i < children.length; ++i) {
116: SimpleNode n = (SimpleNode) children[i];
117: if (n != null) {
118: n.dump(prefix + " ");
119: }
120: }
121: }
122: }
123:
124: /*
125: The following section contains code that was added to this class after it was generated by javacc preprocessor.
126: */
127: private Map<String, Object> attributes;
128:
129: // or <String, List<Object>>
130:
131: public Object[] getAttributes(String name) {
132: if (attributes == null)
133: return null;
134: List attrs = getAttributeList(name);
135: return attrs.toArray();
136: }
137:
138: public void addAttribute(String name, Object value) {
139: getAttributeList(name).add(value);
140: }
141:
142: public void setAttribute(String name, Object value) {
143: getAttributeMap().put(name, value);
144: }
145:
146: public Object getAttribute(String name) {
147: return (attributes == null) ? null : attributes.get(name);
148: }
149:
150: private Map<String, Object> getAttributeMap() {
151: if (attributes == null) {
152: attributes = new HashMap<String, Object>();
153: }
154: return attributes;
155: }
156:
157: private List<Object> getAttributeList(String name) {
158: getAttributeMap();
159: List<Object> list = (List<Object>) attributes.get(name);
160: if (list == null) {
161: list = new ArrayList<Object>();
162: attributes.put(name, list);
163: }
164: return list;
165: }
166:
167: public int jjtGetID() {
168: return id;
169: }
170: }
|