net.sourceforge.pmd.lang.ast

## Interface Node

- All Known Subinterfaces:
    EcmascriptNode<T>, JavaNode, JspNode, XmlNode
  All Known Implementing Classes:
    AbstractEcmascriptNode, AbstractInfixEcmascriptNode, AbstractJavaAccessNode, AbstractJavaAccessTypeNode, AbstractJavaNode, AbstractJavaTypeNode, AbstractJspNode, AbstractNode, ASTAdditiveExpression, ASTAllocationExpression, ASTAndExpression, ASTAnnotation, ASTAnnotationMethodDeclaration, ASTAnnotationTypeBody, ASTAnnotationTypeDeclaration, ASTAnnotationTypeMemberDeclaration, ASTArgumentList, ASTArguments, ASTArrayComprehension, ASTArrayComprehensionLoop, ASTArrayDimsAndInits, ASTArrayInitializer, ASTArrayLiteral, ASTAssertStatement, ASTAssignment, ASTAssignmentOperator, ASTAstRoot, ASTAttribute, ASTAttributeValue, ASTBlock, ASTBlock, ASTBlockStatement, ASTBooleanLiteral, ASTBreakStatement, ASTBreakStatement, ASTCastExpression, ASTCatchClause, ASTCatchStatement, ASTCData, ASTClassOrInterfaceBody, ASTClassOrInterfaceBodyDeclaration, ASTClassOrInterfaceDeclaration, ASTClassOrInterfaceType, ASTComment, ASTCommentTag, ASTCompilationUnit, ASTCompilationUnit, ASTConditionalAndExpression, ASTConditionalExpression, ASTConditionalExpression, ASTConditionalOrExpression, ASTConstructorDeclaration, ASTContent, ASTContinueStatement, ASTContinueStatement, ASTDeclaration, ASTDefaultValue, ASTDoctypeDeclaration, ASTDoctypeExternalId, ASTDoLoop, ASTDoStatement, ASTElement, ASTElementGet, ASTElExpression, ASTEmptyExpression, ASTEmptyStatement, ASTEnumBody, ASTEnumConstant, ASTEnumDeclaration, ASTEqualityExpression, ASTExclusiveOrExpression, ASTExplicitConstructorInvocation, ASTExpression, ASTExpressionStatement, ASTExtendsList, ASTFieldDeclaration, ASTFinallyStatement, ASTForInit, ASTForInLoop, ASTForLoop, ASTFormalParameter, ASTFormalParameters, ASTForStatement, ASTForUpdate, ASTFunctionCall, ASTFunctionNode, ASTHtmlScript, ASTIfStatement, ASTIfStatement, ASTImplementsList, ASTImportDeclaration, ASTInclusiveOrExpression, ASTInfixExpression, ASTInitializer, ASTInstanceOfExpression, ASTJspComment, ASTJspDeclaration, ASTJspDeclarations, ASTJspDirective, ASTJspDirectiveAttribute, ASTJspDocument, ASTJspExpression, ASTJspExpressionInAttribute, ASTJspScriptlet, ASTKeywordLiteral, ASTLabel, ASTLabeledStatement, ASTLabeledStatement, ASTLetNode, ASTLiteral, ASTLocalVariableDeclaration, ASTMarkerAnnotation, ASTMemberSelector, ASTMemberValue, ASTMemberValueArrayInitializer, ASTMemberValuePair, ASTMemberValuePairs, ASTMethodDeclaration, ASTMethodDeclarator, ASTMultiplicativeExpression, ASTName, ASTName, ASTNameList, ASTNewExpression, ASTNormalAnnotation, ASTNullLiteral, ASTNumberLiteral, ASTObjectLiteral, ASTObjectProperty, ASTPackageDeclaration, ASTParenthesizedExpression, ASTPostfixExpression, ASTPreDecrementExpression, ASTPreIncrementExpression, ASTPrimaryExpression, ASTPrimaryPrefix, ASTPrimarySuffix, ASTPrimitiveType, ASTPropertyGet, ASTReferenceType, ASTRegExpLiteral, ASTRelationalExpression, ASTResource, ASTResources, ASTResourceSpecification, ASTResultType, ASTReturnStatement, ASTReturnStatement, ASTRSIGNEDSHIFT, ASTRUNSIGNEDSHIFT, ASTScope, ASTShiftExpression, ASTSingleMemberAnnotation, ASTStatement, ASTStatementExpression, ASTStatementExpressionList, ASTStringLiteral, ASTSwitchCase, ASTSwitchLabel, ASTSwitchStatement, ASTSwitchStatement, ASTSynchronizedStatement, ASTText, ASTThrowStatement, ASTThrowStatement, ASTTryStatement, ASTTryStatement, ASTType, ASTTypeArgument, ASTTypeArguments, ASTTypeBound, ASTTypeDeclaration, ASTTypeParameter, ASTTypeParameters, ASTUnaryExpression, ASTUnaryExpression, ASTUnaryExpressionNotPlusMinus, ASTUnparsedText, ASTValueBinding, ASTVariableDeclaration, ASTVariableDeclarator, ASTVariableDeclaratorId, ASTVariableInitializer, ASTVariableInitializer, ASTWhileLoop, ASTWhileStatement, ASTWildcardBounds, ASTWithStatement, ASTXmlDotQuery, ASTXmlExpression, ASTXmlMemberGet, ASTXmlString, Comment, DummyJavaNode, FormalComment, JavadocElement, MultiLineComment, SingleLineComment

      public interface Node

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `List<? extends Node>` | `findChildNodesWithXPath(String xpathString)` Returns all the nodes matching the xpath expression.
    `<T> List<T>` | `findChildrenOfType(Class<T> childType)` Traverses the children to find all the instances of type childType.
    `<T> List<T>` | `findDescendantsOfType(Class<T> targetType)` Traverses down the tree to find all the descendant instances of type descendantType.
    `<T> void` | `findDescendantsOfType(Class<T> targetType, List<T> results, boolean crossFindBoundaries)` Traverses down the tree to find all the descendant instances of type descendantType.
    `Document` | `getAsDocument()` Get a DOM Document which contains Elements and Attributes representative of this Node and it's children.
    `int` | `getBeginColumn()`
    `int` | `getBeginLine()`
    `DataFlowNode` | `getDataFlowNode()`
    `int` | `getEndColumn()`
    `int` | `getEndLine()`
    `<T> T` | `getFirstChildOfType(Class<T> childType)` Traverses the children to find the first instance of type childType.
    `<T> T` | `getFirstDescendantOfType(Class<T> descendantType)` Traverses down the tree to find the first descendant instance of type descendantType.
    `<T> T` | `getFirstParentOfType(Class<T> parentType)`
    `String` | `getImage()`
    `Node` | `getNthParent(int n)`
    `<T> List<T>` | `getParentsOfType(Class<T> parentType)`
    `Object` | `getUserData()` Get the user data associated with this node.
    `boolean` | `hasDescendantMatchingXPath(String xpathString)` Checks whether at least one descendant matches the xpath expression.
    `<T> boolean` | `hasDescendantOfType(Class<T> type)` Finds if this node contains a descendant of the given type.
    `boolean` | `hasImageEqualTo(String image)`
    `boolean` | `isFindBoundary()`
    `void` | `jjtAddChild(Node child, int index)` This method tells the node to add its argument to the node's list of children.
    `void` | `jjtClose()` This method is called after all the child nodes have been added.
    `Node` | `jjtGetChild(int index)` This method returns a child node.
    `int` | `jjtGetId()`
    `int` | `jjtGetNumChildren()` Return the number of children the node has.
    `Node` | `jjtGetParent()`
    `void` | `jjtOpen()` This method is called after the node has been made the current node.
    `void` | `jjtSetParent(Node parent)` This pair of methods are used to inform the node of its parent.
    `void` | `setDataFlowNode(DataFlowNode dataFlowNode)`
    `void` | `setImage(String image)`
    `void` | `setUserData(Object userData)` Set the user data associated with this node.

- - ### Method Detail

    - #### jjtOpen

          void jjtOpen()

      This method is called after the node has been made the current node. It indicates that child nodes can now be added to it.

    - #### jjtClose

          void jjtClose()

      This method is called after all the child nodes have been added.

    - #### jjtSetParent

          void jjtSetParent(Node parent)

      This pair of methods are used to inform the node of its parent.

    - #### jjtGetParent

          Node jjtGetParent()

    - #### jjtAddChild

          void jjtAddChild(Node child,
                         int index)

      This method tells the node to add its argument to the node's list of children.

    - #### jjtGetChild

          Node jjtGetChild(int index)

      This method returns a child node. The children are numbered from zero, left to right.
      Parameters:
        `index` - the child index. Must be nonnegative and less than `jjtGetNumChildren()`.

    - #### jjtGetNumChildren

          int jjtGetNumChildren()

      Return the number of children the node has.

    - #### jjtGetId

          int jjtGetId()

    - #### getImage

          String getImage()

    - #### setImage

          void setImage(String image)

    - #### hasImageEqualTo

          boolean hasImageEqualTo(String image)

    - #### getBeginLine

          int getBeginLine()

    - #### getBeginColumn

          int getBeginColumn()

    - #### getEndLine

          int getEndLine()

    - #### getEndColumn

          int getEndColumn()

    - #### getDataFlowNode

          DataFlowNode getDataFlowNode()

    - #### setDataFlowNode

          void setDataFlowNode(DataFlowNode dataFlowNode)

    - #### isFindBoundary

          boolean isFindBoundary()

    - #### getNthParent

          Node getNthParent(int n)

    - #### getFirstParentOfType

          <T> T getFirstParentOfType(Class<T> parentType)

    - #### getParentsOfType

          <T> List<T> getParentsOfType(Class<T> parentType)

    - #### findChildrenOfType

          <T> List<T> findChildrenOfType(Class<T> childType)

      Traverses the children to find all the instances of type childType.
      Parameters:
        `childType` - class which you want to find.
      Returns:
        List of all children of type childType. Returns an empty list if none found.
      See Also:
        `if traversal of the entire tree is needed.`

    - #### findDescendantsOfType

          <T> List<T> findDescendantsOfType(Class<T> targetType)

      Traverses down the tree to find all the descendant instances of type descendantType.
      Parameters:
        `targetType` - class which you want to find.
      Returns:
        List of all children of type targetType. Returns an empty list if none found.

    - #### findDescendantsOfType

          <T> void findDescendantsOfType(Class<T> targetType,
                                       List<T> results,
                                       boolean crossFindBoundaries)

      Traverses down the tree to find all the descendant instances of type descendantType.
      Parameters:
        `targetType` - class which you want to find.
        `results` - list to store the matching descendants
        `crossFindBoundaries` - if `false`, recursion stops for nodes for which `isFindBoundary()` is `true`

    - #### getFirstChildOfType

          <T> T getFirstChildOfType(Class<T> childType)

      Traverses the children to find the first instance of type childType.
      Parameters:
        `childType` - class which you want to find.
      Returns:
        Node of type childType. Returns `null` if none found.
      See Also:
        `if traversal of the entire tree is needed.`

    - #### getFirstDescendantOfType

          <T> T getFirstDescendantOfType(Class<T> descendantType)

      Traverses down the tree to find the first descendant instance of type descendantType.
      Parameters:
        `descendantType` - class which you want to find.
      Returns:
        Node of type descendantType. Returns `null` if none found.

    - #### hasDescendantOfType

          <T> boolean hasDescendantOfType(Class<T> type)

      Finds if this node contains a descendant of the given type.
      Parameters:
        `type` - the node type to search
      Returns:
        `true` if there is at least one descendant of the given type

    - #### findChildNodesWithXPath

          List<? extends Node> findChildNodesWithXPath(String xpathString)
                                                       throws org.jaxen.JaxenException

      Returns all the nodes matching the xpath expression.
      Parameters:
        `xpathString` - the expression to check
      Returns:
        List of all matching nodes. Returns an empty list if none found.
      Throws:
        `org.jaxen.JaxenException`

    - #### hasDescendantMatchingXPath

          boolean hasDescendantMatchingXPath(String xpathString)

      Checks whether at least one descendant matches the xpath expression.
      Parameters:
        `xpathString` - the expression to check
      Returns:
        true if there is a match

    - #### getAsDocument

          Document getAsDocument()

      Get a DOM Document which contains Elements and Attributes representative of this Node and it's children. Essentially a DOM tree representation of the Node AST, thereby allowing tools which can operate upon DOM to also indirectly operate on the AST.

    - #### getUserData

          Object getUserData()

      Get the user data associated with this node. By default there is no data, unless it has been set via `setUserData(Object)`.
      Returns:
        The user data set on this node.

    - #### setUserData

          void setUserData(Object userData)

      Set the user data associated with this node.

      PMD itself will never set user data onto a node. Nor should any Rule implementation, as the AST nodes are shared between concurrently executing Rules (i.e. it is not thread-safe).

      This API is most useful for external applications looking to leverage PMD's robust support for AST structures, in which case application specific annotations on the AST nodes can be quite useful.

      Parameters:
        `userData` - The data to set on this node.

Copyright © 2002-2013 InfoEther. All Rights Reserved.