| JavaDoq: AbstractNode.java |
01
02 /*
03 * Descripter 1.0 - Java Script Engines
04 * Copyright (C) 2010-2015 Jianjun Liu (J.J.Liu)
05 *
06 * This program is free software: you can redistribute it and/or modify
07 * it under the terms of the GNU Affero General Public License as published by
08 * the Free Software Foundation, either version 3 of the License, or
09 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Affero General Public License for more details.
15 *
16 * You should have received a copy of the GNU Affero General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19 package org.descripter.js.parse;
20
21 /**
22 * <p>An abstract base class for JJTree nodes.</p>
23 *
24 * @author <a href="mailto:jianjunliu@126.com">J.J.Liu (Jianjun Liu)</a> at <a href="http://www.descripter.org" target="_blank">http://www.descripter.org</a>
25 * @since Descripter 1.0
26 */
27 public abstract class AbstractNode extends SimpleNode
28 {
29 /**
30 * <p>Constructs a {@link AbstractNode} without a JJTreeParser.</p>
31 * @param i The id.
32 * @since Descripter 1.0
33 */
34 protected AbstractNode(int i) {
35 super(i);
36 }
37
38 /**
39 * <p>Constructs a {@link AbstractNode} with a JSParser.</p>
40 * @param p The JSParser
41 * @param i The id.
42 * @since Descripter 1.0
43 */
44 protected AbstractNode(JSParser p, int i) {
45 super(p, i);
46 }
47
48 /**
49 * <p>The first token of this node.</p>
50 * @since Descripter 1.0
51 */
52 public Token firstToken;
53 /**
54 * <p>The last token of this node.</p>
55 * @since Descripter 1.0
56 */
57 public Token lastToken;
58
59 /**
60 * <p>Accepts children.</p>
61 * @param visitor The visitor
62 * @param data The data argument
63 * @return An array of results.
64 * @since Descripter 1.0
65 **/
66 public final Object[] acceptChildren(JSParserVisitor visitor, Object data) {
67 int n = jjtGetNumChildren();
68 Object[] list = new Object[n];
69 for (int i = 0; i < n; ++i) {
70 list[i] = getChild(i).jjtAccept(visitor, data);
71 }
72 return list;
73 }
74
75 /**
76 * <p>Gets a child node.</p>
77 * @param i The index of the node to get.
78 * @return The {@link AbstractNode}.
79 * @since Descripter 1.0
80 **/
81 public final AbstractNode getChild(int i) {
82 return (AbstractNode)jjtGetChild(i);
83 }
84 }
| JavaDoq: AbstractNode.java |