1
2
3
4 package net.sourceforge.pmd.lang.jsp.ast;
5
6 import net.sourceforge.pmd.lang.ast.AbstractNode;
7
8 public class AbstractJspNode extends AbstractNode implements JspNode {
9
10 protected JspParser parser;
11
12 public AbstractJspNode(int id) {
13 super(id);
14 }
15
16 public AbstractJspNode(JspParser parser, int id) {
17 super(id);
18 this.parser = parser;
19 }
20
21 public void jjtOpen() {
22 if (beginLine == -1 && parser.token.next != null) {
23 beginLine = parser.token.next.beginLine;
24 beginColumn = parser.token.next.beginColumn;
25 }
26 }
27
28 public void jjtClose() {
29 if (beginLine == -1 && (children == null || children.length == 0)) {
30 beginColumn = parser.token.beginColumn;
31 }
32 if (beginLine == -1) {
33 beginLine = parser.token.beginLine;
34 }
35 endLine = parser.token.endLine;
36 endColumn = parser.token.endColumn;
37 }
38
39
40
41
42 public Object jjtAccept(JspParserVisitor visitor, Object data) {
43 return visitor.visit(this, data);
44 }
45
46
47
48
49 public Object childrenAccept(JspParserVisitor visitor, Object data) {
50 if (children != null) {
51 for (int i = 0; i < children.length; ++i) {
52 ((JspNode) children[i]).jjtAccept(visitor, data);
53 }
54 }
55 return data;
56 }
57
58 public String toString() {
59 return JspParserTreeConstants.jjtNodeName[id];
60 }
61 }