View Javadoc

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