View Javadoc

    1   /**
    2    * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
    3    */
    4   package net.sourceforge.pmd.lang.ecmascript.ast;
    5
    6   import org.mozilla.javascript.ast.SwitchCase;
    7
    8   public class ASTSwitchCase extends AbstractEcmascriptNode<SwitchCase> {
    9       public ASTSwitchCase(SwitchCase switchCase) {
    10  	super(switchCase);
    11      }
    12
    13      /**
    14       * Accept the visitor.
    15       */
    16      public Object jjtAccept(EcmascriptParserVisitor visitor, Object data) {
    17  	return visitor.visit(this, data);
    18      }
    19
    20      public boolean isDefault() {
    21  	return node.isDefault();
    22      }
    23
    24      public EcmascriptNode getExpression() {
    25  	if (!isDefault()) {
    26  	    return (EcmascriptNode) jjtGetChild(0);
    27  	} else {
    28  	    return null;
    29  	}
    30      }
    31
    32      public int getNumStatements() {
    33  	// TODO Tell Rhino folks about null Statements, should be empty List?
    34  	return node.getStatements() != null ? node.getStatements().size() : 0;
    35      }
    36
    37      public EcmascriptNode getStatement(int index) {
    38  	if (!isDefault()) {
    39  	    index++;
    40  	}
    41  	return (EcmascriptNode) jjtGetChild(index);
    42      }
    43  }