- java.lang.Object
-
- com.sun.source.util.SimpleTreeVisitor<R,P>
-
- Type Parameters:
R
- the return type of this visitor's methods. UseVoid
for visitors that do not need to return results.P
- the type of the additional parameter to this visitor's methods. UseVoid
for visitors that do not need an additional parameter.
- All Implemented Interfaces:
TreeVisitor<R,P>
public class SimpleTreeVisitor<R,P> extends Object implements TreeVisitor<R,P>
A simple visitor for tree nodes.- Since:
- 1.6
-
-
Field Summary
Fields Modifier and Type Field Description protected R
DEFAULT_VALUE
The default value, returned by thedefault action
.
-
Constructor Summary
Constructors Modifier Constructor Description protected
SimpleTreeVisitor()
Creates a visitor, with a DEFAULT_VALUE ofnull
.protected
SimpleTreeVisitor(R defaultValue)
Creates a visitor, with a specified DEFAULT_VALUE.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected R
defaultAction(Tree node, P p)
The default action, used by all visit methods that are not overridden.R
visit(Tree node, P p)
Invokes the appropriate visit method specific to the type of the node.R
visit(Iterable<? extends Tree> nodes, P p)
Invokes the appropriate visit method on each of a sequence of nodes.R
visitAnnotatedType(AnnotatedTypeTree node, P p)
Visits an AnnotatedTypeTree node.R
visitAnnotation(AnnotationTree node, P p)
Visits an AnnotatedTree node.R
visitArrayAccess(ArrayAccessTree node, P p)
Visits an ArrayAccessTree node.R
visitArrayType(ArrayTypeTree node, P p)
Visits an ArrayTypeTree node.R
visitAssert(AssertTree node, P p)
Visits an AssertTree node.R
visitAssignment(AssignmentTree node, P p)
Visits an AssignmentTree node.R
visitBinary(BinaryTree node, P p)
Visits a BinaryTree node.R
visitBlock(BlockTree node, P p)
Visits a BlockTree node.R
visitBreak(BreakTree node, P p)
Visits a BreakTree node.R
visitCase(CaseTree node, P p)
Visits a CaseTree node.R
visitCatch(CatchTree node, P p)
Visits a CatchTree node.R
visitClass(ClassTree node, P p)
Visits a ClassTree node.R
visitCompilationUnit(CompilationUnitTree node, P p)
Visits a CompilationUnitTree node.R
visitCompoundAssignment(CompoundAssignmentTree node, P p)
Visits a CompoundAssignmentTree node.R
visitConditionalExpression(ConditionalExpressionTree node, P p)
Visits a ConditionalExpressionTree node.R
visitContinue(ContinueTree node, P p)
Visits a ContinueTree node.R
visitDoWhileLoop(DoWhileLoopTree node, P p)
Visits a DoWhileTree node.R
visitEmptyStatement(EmptyStatementTree node, P p)
Visits an EmptyStatementTree node.R
visitEnhancedForLoop(EnhancedForLoopTree node, P p)
Visits an EnhancedForLoopTree node.R
visitExpressionStatement(ExpressionStatementTree node, P p)
Visits an ExpressionStatementTree node.R
visitForLoop(ForLoopTree node, P p)
Visits a ForLoopTree node.R
visitIdentifier(IdentifierTree node, P p)
Visits an IdentifierTree node.R
visitIf(IfTree node, P p)
Visits an IfTree node.R
visitImport(ImportTree node, P p)
Visits an ImportTree node.R
visitInstanceOf(InstanceOfTree node, P p)
Visits an InstanceOfTree node.R
visitIntersectionType(IntersectionTypeTree node, P p)
Visits an IntersectionTypeTree node.R
visitLabeledStatement(LabeledStatementTree node, P p)
Visits a LabeledStatementTree node.R
visitLambdaExpression(LambdaExpressionTree node, P p)
Visits a LambdaExpressionTree node.R
visitLiteral(LiteralTree node, P p)
Visits a LiteralTree node.R
visitMemberReference(MemberReferenceTree node, P p)
Visits a MemberReferenceTree node.R
visitMemberSelect(MemberSelectTree node, P p)
Visits a MemberSelectTree node.R
visitMethod(MethodTree node, P p)
Visits a MethodTree node.R
visitMethodInvocation(MethodInvocationTree node, P p)
Visits a MethodInvocationTree node.R
visitModifiers(ModifiersTree node, P p)
Visits a ModifiersTree node.R
visitNewArray(NewArrayTree node, P p)
Visits a NewArrayTree node.R
visitNewClass(NewClassTree node, P p)
Visits a NewClassTree node.R
visitOther(Tree node, P p)
Visits an unknown type of Tree node.R
visitPackage(PackageTree node, P p)
Visits a PackageTree node.R
visitParameterizedType(ParameterizedTypeTree node, P p)
Visits a ParameterizedTypeTree node.R
visitParenthesized(ParenthesizedTree node, P p)
Visits a ParenthesizedTree node.R
visitPrimitiveType(PrimitiveTypeTree node, P p)
Visits a PrimitiveTypeTree node.R
visitReturn(ReturnTree node, P p)
Visits a ReturnTree node.R
visitSwitch(SwitchTree node, P p)
Visits a SwitchTree node.R
visitSynchronized(SynchronizedTree node, P p)
Visits a SynchronizedTree node.R
visitThrow(ThrowTree node, P p)
Visits a ThrowTree node.R
visitTry(TryTree node, P p)
Visits a TryTree node.R
visitTypeCast(TypeCastTree node, P p)
Visits a TypeCastTree node.R
visitTypeParameter(TypeParameterTree node, P p)
Visits a TypeParameterTree node.R
visitUnary(UnaryTree node, P p)
Visits a UnaryTree node.R
visitUnionType(UnionTypeTree node, P p)
Visits a UnionTypeTree node.R
visitVariable(VariableTree node, P p)
Visits a VariableTree node.R
visitWhileLoop(WhileLoopTree node, P p)
Visits a WhileLoopTree node.R
visitWildcard(WildcardTree node, P p)
Visits a WildcardTypeTree node.-
Methods declared in class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods declared in interface com.sun.source.tree.TreeVisitor
visitErroneous, visitExports, visitModule, visitOpens, visitProvides, visitRequires, visitUses
-
-
-
-
Field Detail
DEFAULT_VALUE
protected final R DEFAULT_VALUE
The default value, returned by thedefault action
.
-
Constructor Detail
SimpleTreeVisitor
protected SimpleTreeVisitor()
Creates a visitor, with a DEFAULT_VALUE ofnull
.
SimpleTreeVisitor
protected SimpleTreeVisitor(R defaultValue)
Creates a visitor, with a specified DEFAULT_VALUE.- Parameters:
defaultValue
- the default value to be returned by the default action.
-
Method Detail
defaultAction
protected R defaultAction(Tree node, P p)
The default action, used by all visit methods that are not overridden.- Parameters:
node
- the node being visitedp
- the parameter value passed to the visit method- Returns:
- the result value to be returned from the visit method
visit
public final R visit(Tree node, P p)
Invokes the appropriate visit method specific to the type of the node.- Parameters:
node
- the node on which to dispatchp
- a parameter to be passed to the appropriate visit method- Returns:
- the value returns from the appropriate visit method
visit
public final R visit(Iterable<? extends Tree> nodes, P p)
Invokes the appropriate visit method on each of a sequence of nodes.- Parameters:
nodes
- the nodes on which to dispatchp
- a parameter value to be passed to each appropriate visit method- Returns:
- the value return from the last of the visit methods, or null if none were called.
visitCompilationUnit
public R visitCompilationUnit(CompilationUnitTree node, P p)
Visits a CompilationUnitTree node. This implementation callsdefaultAction
.- Specified by:
visitCompilationUnit
in interfaceTreeVisitor<R,P>
- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
-
the result of
defaultAction
visitPackage
public R visitPackage(PackageTree node, P p)
Visits a PackageTree node. This implementation callsdefaultAction
.- Specified by:
visitPackage
in interfaceTreeVisitor<R,P>
- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
-
the result of
defaultAction
visitImport
public R visitImport(ImportTree node, P p)
Visits an ImportTree node. This implementation callsdefaultAction
.- Specified by:
visitImport
in interfaceTreeVisitor<R,P>
- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
-
the result of
defaultAction
visitClass
public R visitClass(ClassTree node, P p)
Visits a ClassTree node. This implementation callsdefaultAction
.- Specified by:
visitClass
in interfaceTreeVisitor<R,P>
- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
-
the result of
defaultAction
visitMethod
public R visitMethod(MethodTree node, P p)
Visits a MethodTree node. This implementation callsdefaultAction
.- Specified by:
visitMethod
in interfaceTreeVisitor<R,P>
- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
-
the result of
defaultAction
visitVariable
public R visitVariable(VariableTree node, P p)
Visits a VariableTree node. This implementation callsdefaultAction
.- Specified by:
visitVariable
in interfaceTreeVisitor<R,P>
- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
-
the result of
defaultAction
visitEmptyStatement
public R visitEmptyStatement(EmptyStatementTree node, P p)
Visits an EmptyStatementTree node. This implementation callsdefaultAction
.- Specified by:
visitEmptyStatement
in interfaceTreeVisitor<R,P>
- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
-
the result of
defaultAction
visitBlock
public R visitBlock(BlockTree node, P p)
Visits a BlockTree node. This implementation callsdefaultAction
.- Specified by:
visitBlock
in interfaceTreeVisitor<R,P>
- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
-
the result of
defaultAction
visitDoWhileLoop
public R visitDoWhileLoop(DoWhileLoopTree node, P p)
Visits a DoWhileTree node. This implementation callsdefaultAction
.- Specified by:
visitDoWhileLoop
in interfaceTreeVisitor<R,P>
- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
-
the result of
defaultAction
visitWhileLoop
public R visitWhileLoop(WhileLoopTree node, P p)
Visits a WhileLoopTree node. This implementation callsdefaultAction
.- Specified by:
visitWhileLoop
in interfaceTreeVisitor<R,P>
- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
-
the result of
defaultAction
visitForLoop
public R visitForLoop(ForLoopTree node, P p)
Visits a ForLoopTree node. This implementation callsdefaultAction
.- Specified by:
visitForLoop
in interfaceTreeVisitor<R,P>
- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
-
the result of
defaultAction
visitEnhancedForLoop
public R visitEnhancedForLoop(EnhancedForLoopTree node, P p)
Visits an EnhancedForLoopTree node. This implementation callsdefaultAction
.- Specified by:
visitEnhancedForLoop
in interfaceTreeVisitor<R,P>
- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
-
the result of
defaultAction
visitLabeledStatement
public R visitLabeledStatement(LabeledStatementTree node, P p)
Visits a LabeledStatementTree node. This implementation callsdefaultAction
.- Specified by:
visitLabeledStatement
in interfaceTreeVisitor<R,P>
- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
-
the result of
defaultAction
visitSwitch
public R visitSwitch(SwitchTree node, P p)
Visits a SwitchTree node. This implementation callsdefaultAction
.- Specified by:
visitSwitch
in interfaceTreeVisitor<R,P>
- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
-
the result of
defaultAction
visitCase
public R visitCase(CaseTree node, P p)
Visits a CaseTree node. This implementation callsdefaultAction
.- Specified by:
visitCase
in interfaceTreeVisitor<R,P>
- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
-
the result of
defaultAction
visitSynchronized
public R visitSynchronized(SynchronizedTree node, P p)
Visits a SynchronizedTree node. This implementation callsdefaultAction
.- Specified by:
visitSynchronized
in interfaceTreeVisitor<R,P>
- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
-
the result of
defaultAction
visitTry
public R visitTry(TryTree node, P p)
Visits a TryTree node. This implementation callsdefaultAction
.- Specified by:
visitTry
in interfaceTreeVisitor<R,P>
- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
-
the result of
defaultAction
visitCatch
public R visitCatch(CatchTree node, P p)
Visits a CatchTree node. This implementation callsdefaultAction
.- Specified by:
visitCatch
in interfaceTreeVisitor<R,P>
- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
-
the result of
defaultAction
visitConditionalExpression
public R visitConditionalExpression(ConditionalExpressionTree node, P p)
Visits a ConditionalExpressionTree node. This implementation callsdefaultAction
.- Specified by:
visitConditionalExpression
in interfaceTreeVisitor<R,P>
- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
-
the result of
defaultAction
visitIf
public R visitIf(IfTree node, P p)
Visits an IfTree node. This implementation callsdefaultAction
.- Specified by:
visitIf
in interfaceTreeVisitor<R,P>
- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
-
the result of
defaultAction
visitExpressionStatement
public R visitExpressionStatement(ExpressionStatementTree node, P p)
Visits an ExpressionStatementTree node. This implementation callsdefaultAction
.- Specified by:
visitExpressionStatement
in interfaceTreeVisitor<R,P>
- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
-
the result of
defaultAction
visitBreak
public R visitBreak(BreakTree node, P p)
Visits a BreakTree node. This implementation callsdefaultAction
.- Specified by:
visitBreak
in interfaceTreeVisitor<R,P>
- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
-
the result of
defaultAction
visitContinue
public R visitContinue(ContinueTree node, P p)
Visits a ContinueTree node. This implementation callsdefaultAction
.- Specified by:
visitContinue
in interfaceTreeVisitor<R,P>
- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
-
the result of
defaultAction
visitReturn
public R visitReturn(ReturnTree node, P p)
Visits a ReturnTree node. This implementation callsdefaultAction
.- Specified by:
visitReturn
in interfaceTreeVisitor<R,P>
- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
-
the result of
defaultAction
visitThrow
public R visitThrow(ThrowTree node, P p)
Visits a ThrowTree node. This implementation callsdefaultAction
.- Specified by:
visitThrow
in interfaceTreeVisitor<R,P>
- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
-
the result of
defaultAction
visitAssert
public R visitAssert(AssertTree node, P p)
Visits an AssertTree node. This implementation callsdefaultAction
.- Specified by:
visitAssert
in interfaceTreeVisitor<R,P>
- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
-
the result of
defaultAction
visitMethodInvocation
public R visitMethodInvocation(MethodInvocationTree node, P p)
Visits a MethodInvocationTree node. This implementation callsdefaultAction
.- Specified by:
visitMethodInvocation
in interfaceTreeVisitor<R,P>
- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
-
the result of
defaultAction
visitNewClass
public R visitNewClass(NewClassTree node, P p)
Visits a NewClassTree node. This implementation callsdefaultAction
.- Specified by:
visitNewClass
in interfaceTreeVisitor<R,P>
- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
-
the result of
defaultAction
visitNewArray
public R visitNewArray(NewArrayTree node, P p)
Visits a NewArrayTree node. This implementation callsdefaultAction
.- Specified by:
visitNewArray
in interfaceTreeVisitor<R,P>
- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
-
the result of
defaultAction
visitLambdaExpression
public R visitLambdaExpression(LambdaExpressionTree node, P p)
Visits a LambdaExpressionTree node. This implementation callsdefaultAction
.- Specified by:
visitLambdaExpression
in interfaceTreeVisitor<R,P>
- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
-
the result of
defaultAction
visitParenthesized
public R visitParenthesized(ParenthesizedTree node, P p)
Visits a ParenthesizedTree node. This implementation callsdefaultAction
.- Specified by:
visitParenthesized
in interfaceTreeVisitor<R,P>
- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
-
the result of
defaultAction
visitAssignment
public R visitAssignment(AssignmentTree node, P p)
Visits an AssignmentTree node. This implementation callsdefaultAction
.- Specified by:
visitAssignment
in interfaceTreeVisitor<R,P>
- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
-
the result of
defaultAction
visitCompoundAssignment
public R visitCompoundAssignment(CompoundAssignmentTree node, P p)
Visits a CompoundAssignmentTree node. This implementation callsdefaultAction
.- Specified by:
visitCompoundAssignment
in interfaceTreeVisitor<R,P>
- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
-
the result of
defaultAction
visitUnary
public R visitUnary(UnaryTree node, P p)
Visits a UnaryTree node. This implementation callsdefaultAction
.- Specified by:
visitUnary
in interfaceTreeVisitor<R,P>
- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
-
the result of
defaultAction
visitBinary
public R visitBinary(BinaryTree node, P p)
Visits a BinaryTree node. This implementation callsdefaultAction
.- Specified by:
visitBinary
in interfaceTreeVisitor<R,P>
- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
-
the result of
defaultAction
visitTypeCast
public R visitTypeCast(TypeCastTree node, P p)
Visits a TypeCastTree node. This implementation callsdefaultAction
.- Specified by:
visitTypeCast
in interfaceTreeVisitor<R,P>
- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
-
the result of
defaultAction
visitInstanceOf
public R visitInstanceOf(InstanceOfTree node, P p)
Visits an InstanceOfTree node. This implementation callsdefaultAction
.- Specified by:
visitInstanceOf
in interfaceTreeVisitor<R,P>
- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
-
the result of
defaultAction
visitArrayAccess
public R visitArrayAccess(ArrayAccessTree node, P p)
Visits an ArrayAccessTree node. This implementation callsdefaultAction
.- Specified by:
visitArrayAccess
in interfaceTreeVisitor<R,P>
- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
-
the result of
defaultAction
visitMemberSelect
public R visitMemberSelect(MemberSelectTree node, P p)
Visits a MemberSelectTree node. This implementation callsdefaultAction
.- Specified by:
visitMemberSelect
in interfaceTreeVisitor<R,P>
- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
-
the result of
defaultAction
visitMemberReference
public R visitMemberReference(MemberReferenceTree node, P p)
Visits a MemberReferenceTree node. This implementation callsdefaultAction
.- Specified by:
visitMemberReference
in interfaceTreeVisitor<R,P>
- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
-
the result of
defaultAction
visitIdentifier
public R visitIdentifier(IdentifierTree node, P p)
Visits an IdentifierTree node. This implementation callsdefaultAction
.- Specified by:
visitIdentifier
in interfaceTreeVisitor<R,P>
- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
-
the result of
defaultAction
visitLiteral
public R visitLiteral(LiteralTree node, P p)
Visits a LiteralTree node. This implementation callsdefaultAction
.- Specified by:
visitLiteral
in interfaceTreeVisitor<R,P>
- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
-
the result of
defaultAction
visitPrimitiveType
public R visitPrimitiveType(PrimitiveTypeTree node, P p)
Visits a PrimitiveTypeTree node. This implementation callsdefaultAction
.- Specified by:
visitPrimitiveType
in interfaceTreeVisitor<R,P>
- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
-
the result of
defaultAction
visitArrayType
public R visitArrayType(ArrayTypeTree node, P p)
Visits an ArrayTypeTree node. This implementation callsdefaultAction
.- Specified by:
visitArrayType
in interfaceTreeVisitor<R,P>
- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
-
the result of
defaultAction
visitParameterizedType
public R visitParameterizedType(ParameterizedTypeTree node, P p)
Visits a ParameterizedTypeTree node. This implementation callsdefaultAction
.- Specified by:
visitParameterizedType
in interfaceTreeVisitor<R,P>
- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
-
the result of
defaultAction
visitUnionType
public R visitUnionType(UnionTypeTree node, P p)
Visits a UnionTypeTree node. This implementation callsdefaultAction
.- Specified by:
visitUnionType
in interfaceTreeVisitor<R,P>
- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
-
the result of
defaultAction
visitIntersectionType
public R visitIntersectionType(IntersectionTypeTree node, P p)
Visits an IntersectionTypeTree node. This implementation callsdefaultAction
.- Specified by:
visitIntersectionType
in interfaceTreeVisitor<R,P>
- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
-
the result of
defaultAction
visitTypeParameter
public R visitTypeParameter(TypeParameterTree node, P p)
Visits a TypeParameterTree node. This implementation callsdefaultAction
.- Specified by:
visitTypeParameter
in interfaceTreeVisitor<R,P>
- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
-
the result of
defaultAction
visitWildcard
public R visitWildcard(WildcardTree node, P p)
Visits a WildcardTypeTree node. This implementation callsdefaultAction
.- Specified by:
visitWildcard
in interfaceTreeVisitor<R,P>
- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
-
the result of
defaultAction
visitModifiers
public R visitModifiers(ModifiersTree node, P p)
Visits a ModifiersTree node. This implementation callsdefaultAction
.- Specified by:
visitModifiers
in interfaceTreeVisitor<R,P>
- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
-
the result of
defaultAction
visitAnnotation
public R visitAnnotation(AnnotationTree node, P p)
Visits an AnnotatedTree node. This implementation callsdefaultAction
.- Specified by:
visitAnnotation
in interfaceTreeVisitor<R,P>
- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
-
the result of
defaultAction
visitAnnotatedType
public R visitAnnotatedType(AnnotatedTypeTree node, P p)
Visits an AnnotatedTypeTree node. This implementation callsdefaultAction
.- Specified by:
visitAnnotatedType
in interfaceTreeVisitor<R,P>
- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
-
the result of
defaultAction
visitOther
public R visitOther(Tree node, P p)
Visits an unknown type of Tree node. This can occur if the language evolves and new kinds of nodes are added to theTree
hierarchy. This implementation callsdefaultAction
.- Specified by:
visitOther
in interfaceTreeVisitor<R,P>
- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
-
the result of
defaultAction
-