Class DocTreeScanner<R,P>
java.lang.Object
com.sun.source.util.DocTreeScanner<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:
DocTreeVisitor<R,
P>
- Direct Known Subclasses:
DocTreePathScanner
A DocTreeVisitor that visits all the child tree nodes.
To visit nodes of a particular type, just override the
corresponding visitXYZ method.
Inside your method, call super.visitXYZ to visit descendant
nodes.
Here is an example to count the number of erroneous nodes in a tree:
class CountErrors extends DocTreeScanner<Integer,Void> { @Override public Integer visitErroneous(ErroneousTree node, Void p) { return 1; } @Override public Integer reduce(Integer r1, Integer r2) { return (r1 == null ? 0 : r1) + (r2 == null ? 0 : r2); } }
- Implementation Requirements:
The default implementation of the visitXYZ methods will determine a result as follows:
- If the node being visited has no children, the result will be
null
. - If the node being visited has one child, the result will be the
result of calling
scan
with that child. The child may be a simple node or itself a list of nodes. - If the node being visited has more than one child, the result will
be determined by calling
scan
with each child in turn, and then combining the result of each scan after the first with the cumulative result so far, as determined by thereduce(R, R)
method. Each child may be either a simple node or a list of nodes. The default behavior of thereduce
method is such that the result of the visitXYZ method will be the result of the last child scanned.
- If the node being visited has no children, the result will be
- Since:
- 1.8
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionReduces two results into a combined result.Scans a single node.Scans a sequence of nodes.visitAttribute
(AttributeTree node, P p) Visits anAttributeTree
node.visitAuthor
(AuthorTree node, P p) Visits anAuthorTree
node.visitComment
(CommentTree node, P p) Visits aCommentTree
node.visitDeprecated
(DeprecatedTree node, P p) Visits aDeprecatedTree
node.visitDocComment
(DocCommentTree node, P p) Visits aDocCommentTree
node.visitDocRoot
(DocRootTree node, P p) Visits aDocRootTree
node.visitDocType
(DocTypeTree node, P p) Visits aDocTypeTree
node.visitEndElement
(EndElementTree node, P p) Visits anEndElementTree
node.visitEntity
(EntityTree node, P p) Visits anEntityTree
node.visitErroneous
(ErroneousTree node, P p) Visits anErroneousTree
node.visitEscape
(EscapeTree node, P p) Visits anEscapeTree
node.visitHidden
(HiddenTree node, P p) Visits aHiddenTree
node.visitIdentifier
(IdentifierTree node, P p) Visits anIdentifierTree
node.visitIndex
(IndexTree node, P p) Visits anIndexTree
node.visitInheritDoc
(InheritDocTree node, P p) Visits anInheritDocTree
node.Visits aLinkTree
node.visitLiteral
(LiteralTree node, P p) Visits anLiteralTree
node.visitOther
(DocTree node, P p) Visits an unknown type ofDocTree
node.visitParam
(ParamTree node, P p) Visits aParamTree
node.visitProvides
(ProvidesTree node, P p) Visits aProvidesTree
node.visitRawText
(RawTextTree node, P p) Visits aRawTextTree
node.visitReference
(ReferenceTree node, P p) Visits aReferenceTree
node.visitReturn
(ReturnTree node, P p) Visits aReturnTree
node.Visits aSeeTree
node.visitSerial
(SerialTree node, P p) Visits aSerialTree
node.visitSerialData
(SerialDataTree node, P p) Visits aSerialDataTree
node.visitSerialField
(SerialFieldTree node, P p) Visits aSerialFieldTree
node.visitSince
(SinceTree node, P p) Visits aSinceTree
node.visitSnippet
(SnippetTree node, P p) Visits aSnippetTree
node.Visits aSpecTree
node.visitStartElement
(StartElementTree node, P p) Visits aStartElementTree
node.visitSummary
(SummaryTree node, P p) Visits aSummaryTree
node.visitSystemProperty
(SystemPropertyTree node, P p) Visits aSystemPropertyTree
node.Visits aTextTree
node.visitThrows
(ThrowsTree node, P p) Visits aThrowsTree
node.visitUnknownBlockTag
(UnknownBlockTagTree node, P p) Visits anUnknownBlockTagTree
node.visitUnknownInlineTag
(UnknownInlineTagTree node, P p) Visits anUnknownInlineTagTree
node.Visits aUsesTree
node.visitValue
(ValueTree node, P p) Visits aValueTree
node.visitVersion
(VersionTree node, P p) Visits aVersionTree
node.
-
Constructor Details
-
DocTreeScanner
public DocTreeScanner()Constructs aDocTreeScanner
.
-
-
Method Details
-
scan
-
scan
Scans a sequence of nodes.- Parameters:
nodes
- the nodes to be scannedp
- a parameter value to be passed to the visit method for each node- Returns:
- the combined return value from the visit methods.
The values are combined using the
reduce
method.
-
reduce
Reduces two results into a combined result. The default implementation is to return the first parameter. The general contract of the method is that it may take any action whatsoever.- Parameters:
r1
- the first of the values to be combinedr2
- the second of the values to be combined- Returns:
- the result of combining the two parameters
-
visitAttribute
Visits anAttributeTree
node.- Specified by:
visitAttribute
in interfaceDocTreeVisitor<R,
P> - Implementation Requirements:
- This implementation scans the children in left to right order.
- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- the result of scanning
-
visitAuthor
Visits anAuthorTree
node.- Specified by:
visitAuthor
in interfaceDocTreeVisitor<R,
P> - Implementation Requirements:
- This implementation scans the children in left to right order.
- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- the result of scanning
-
visitComment
Visits aCommentTree
node.- Specified by:
visitComment
in interfaceDocTreeVisitor<R,
P> - Implementation Requirements:
- This implementation returns
null
. - Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- the result of scanning
-
visitDeprecated
Visits aDeprecatedTree
node.- Specified by:
visitDeprecated
in interfaceDocTreeVisitor<R,
P> - Implementation Requirements:
- This implementation scans the children in left to right order.
- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- the result of scanning
-
visitDocComment
Visits aDocCommentTree
node.- Specified by:
visitDocComment
in interfaceDocTreeVisitor<R,
P> - Implementation Requirements:
- This implementation scans the children in left to right order.
- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- the result of scanning
-
visitDocRoot
Visits aDocRootTree
node.- Specified by:
visitDocRoot
in interfaceDocTreeVisitor<R,
P> - Implementation Requirements:
- This implementation returns
null
. - Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- the result of scanning
-
visitDocType
Visits aDocTypeTree
node.- Specified by:
visitDocType
in interfaceDocTreeVisitor<R,
P> - Implementation Requirements:
- This implementation returns
null
. - Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- the result of scanning
- Since:
- 10
-
visitEndElement
Visits anEndElementTree
node.- Specified by:
visitEndElement
in interfaceDocTreeVisitor<R,
P> - Implementation Requirements:
- This implementation returns
null
. - Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- the result of scanning
-
visitEntity
Visits anEntityTree
node.- Specified by:
visitEntity
in interfaceDocTreeVisitor<R,
P> - Implementation Requirements:
- This implementation returns
null
. - Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- the result of scanning
-
visitErroneous
Visits anErroneousTree
node.- Specified by:
visitErroneous
in interfaceDocTreeVisitor<R,
P> - Implementation Requirements:
- This implementation returns
null
. - Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- the result of scanning
-
visitEscape
Visits anEscapeTree
node.- Specified by:
visitEscape
in interfaceDocTreeVisitor<R,
P> - Implementation Requirements:
- This implementation returns
null
. - Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- the result of scanning
- Since:
- 21
-
visitHidden
Visits aHiddenTree
node.- Specified by:
visitHidden
in interfaceDocTreeVisitor<R,
P> - Implementation Requirements:
- This implementation scans the children in left to right order.
- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- the result of scanning
-
visitIdentifier
Visits anIdentifierTree
node.- Specified by:
visitIdentifier
in interfaceDocTreeVisitor<R,
P> - Implementation Requirements:
- This implementation returns
null
. - Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- the result of scanning
-
visitIndex
Visits anIndexTree
node.- Specified by:
visitIndex
in interfaceDocTreeVisitor<R,
P> - Implementation Requirements:
- This implementation scans the children in left to right order.
- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- the result of scanning
-
visitInheritDoc
Visits anInheritDocTree
node.- Specified by:
visitInheritDoc
in interfaceDocTreeVisitor<R,
P> - Implementation Requirements:
- This implementation scans the children in left to right order.
- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- the result of scanning
-
visitLink
Visits aLinkTree
node.- Specified by:
visitLink
in interfaceDocTreeVisitor<R,
P> - Implementation Requirements:
- This implementation scans the children in left to right order.
- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- the result of scanning
-
visitLiteral
Visits anLiteralTree
node.- Specified by:
visitLiteral
in interfaceDocTreeVisitor<R,
P> - Implementation Requirements:
- This implementation scans the children in left to right order.
- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- the result of scanning
-
visitParam
Visits aParamTree
node.- Specified by:
visitParam
in interfaceDocTreeVisitor<R,
P> - Implementation Requirements:
- This implementation scans the children in left to right order.
- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- the result of scanning
-
visitProvides
Visits aProvidesTree
node.- Specified by:
visitProvides
in interfaceDocTreeVisitor<R,
P> - Implementation Requirements:
- This implementation scans the children in left to right order.
- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- the result of scanning
-
visitRawText
Visits aRawTextTree
node.- Specified by:
visitRawText
in interfaceDocTreeVisitor<R,
P> - Implementation Requirements:
- This implementation returns
null
. - Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- the result of scanning
- Since:
- 23
-
visitReference
Visits aReferenceTree
node.- Specified by:
visitReference
in interfaceDocTreeVisitor<R,
P> - Implementation Requirements:
- This implementation returns
null
. - Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- the result of scanning
-
visitReturn
Visits aReturnTree
node.- Specified by:
visitReturn
in interfaceDocTreeVisitor<R,
P> - Implementation Requirements:
- This implementation scans the children in left to right order.
- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- the result of scanning
-
visitSee
Visits aSeeTree
node.- Specified by:
visitSee
in interfaceDocTreeVisitor<R,
P> - Implementation Requirements:
- This implementation scans the children in left to right order.
- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- the result of scanning
-
visitSerial
Visits aSerialTree
node.- Specified by:
visitSerial
in interfaceDocTreeVisitor<R,
P> - Implementation Requirements:
- This implementation scans the children in left to right order.
- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- the result of scanning
-
visitSerialData
Visits aSerialDataTree
node.- Specified by:
visitSerialData
in interfaceDocTreeVisitor<R,
P> - Implementation Requirements:
- This implementation scans the children in left to right order.
- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- the result of scanning
-
visitSerialField
Visits aSerialFieldTree
node.- Specified by:
visitSerialField
in interfaceDocTreeVisitor<R,
P> - Implementation Requirements:
- This implementation scans the children in left to right order.
- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- the result of scanning
-
visitSince
Visits aSinceTree
node.- Specified by:
visitSince
in interfaceDocTreeVisitor<R,
P> - Implementation Requirements:
- This implementation scans the children in left to right order.
- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- the result of scanning
-
visitSnippet
Visits aSnippetTree
node.- Specified by:
visitSnippet
in interfaceDocTreeVisitor<R,
P> - Implementation Requirements:
- This implementation scans the children in left to right order.
- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- the result of scanning
- Since:
- 18
-
visitSpec
Visits aSpecTree
node.- Specified by:
visitSpec
in interfaceDocTreeVisitor<R,
P> - Implementation Requirements:
- This implementation scans the children in left to right order.
- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- the result of scanning
- Since:
- 20
-
visitStartElement
Visits aStartElementTree
node.- Specified by:
visitStartElement
in interfaceDocTreeVisitor<R,
P> - Implementation Requirements:
- This implementation scans the children in left to right order.
- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- the result of scanning
-
visitSummary
Visits aSummaryTree
node.- Specified by:
visitSummary
in interfaceDocTreeVisitor<R,
P> - Implementation Requirements:
- This implementation scans the children in left to right order.
- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- the result of scanning
- Since:
- 10
-
visitSystemProperty
Visits aSystemPropertyTree
node.- Specified by:
visitSystemProperty
in interfaceDocTreeVisitor<R,
P> - Implementation Requirements:
- This implementation returns
null
. - Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- the result of scanning
- Since:
- 12
-
visitText
-
visitThrows
Visits aThrowsTree
node.- Specified by:
visitThrows
in interfaceDocTreeVisitor<R,
P> - Implementation Requirements:
- This implementation scans the children in left to right order.
- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- the result of scanning
-
visitUnknownBlockTag
Visits anUnknownBlockTagTree
node.- Specified by:
visitUnknownBlockTag
in interfaceDocTreeVisitor<R,
P> - Implementation Requirements:
- This implementation scans the children in left to right order.
- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- the result of scanning
-
visitUnknownInlineTag
Visits anUnknownInlineTagTree
node.- Specified by:
visitUnknownInlineTag
in interfaceDocTreeVisitor<R,
P> - Implementation Requirements:
- This implementation scans the children in left to right order.
- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- the result of scanning
-
visitUses
Visits aUsesTree
node.- Specified by:
visitUses
in interfaceDocTreeVisitor<R,
P> - Implementation Requirements:
- This implementation scans the children in left to right order.
- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- the result of scanning
-
visitValue
Visits aValueTree
node.- Specified by:
visitValue
in interfaceDocTreeVisitor<R,
P> - Implementation Requirements:
- This implementation scans the children in left to right order.
- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- the result of scanning
-
visitVersion
Visits aVersionTree
node.- Specified by:
visitVersion
in interfaceDocTreeVisitor<R,
P> - Implementation Requirements:
- This implementation scans the children in left to right order.
- Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- the result of scanning
-
visitOther
Visits an unknown type ofDocTree
node. This can occur if the set of tags evolves and new kinds of nodes are added to theDocTree
hierarchy.- Specified by:
visitOther
in interfaceDocTreeVisitor<R,
P> - Implementation Requirements:
- This implementation returns
null
. - Parameters:
node
- the node being visitedp
- a parameter value- Returns:
- the result of scanning
-