java.lang.Object
com.sun.source.util.DocTreeScanner<R,P>
- 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);
}
}
- Since:
- 1.8
-
Constructor Summary
Constructors -
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 an AttributeTree node.visitAuthor(AuthorTree node, P p) Visits an AuthorTree node.visitComment(CommentTree node, P p) Visits a CommentTree node.visitDeprecated(DeprecatedTree node, P p) Visits a DeprecatedTree node.visitDocComment(DocCommentTree node, P p) Visits a DocCommentTree node.visitDocRoot(DocRootTree node, P p) Visits a DocRootTree node.visitDocType(DocTypeTree node, P p) Visits a DocTypeTree node.visitEndElement(EndElementTree node, P p) Visits an EndElementTree node.visitEntity(EntityTree node, P p) Visits an EntityTree node.visitErroneous(ErroneousTree node, P p) Visits an ErroneousTree node.visitHidden(HiddenTree node, P p) Visits a HiddenTree node.visitIdentifier(IdentifierTree node, P p) Visits an IdentifierTree node.visitIndex(IndexTree node, P p) Visits an IndexTree node.visitInheritDoc(InheritDocTree node, P p) Visits an InheritDocTree node.Visits a LinkTree node.visitLiteral(LiteralTree node, P p) Visits an LiteralTree node.visitOther(DocTree node, P p) Visits an unknown type of DocTree node.visitParam(ParamTree node, P p) Visits a ParamTree node.visitProvides(ProvidesTree node, P p) Visits a ProvidesTree node.visitReference(ReferenceTree node, P p) Visits a ReferenceTree node.visitReturn(ReturnTree node, P p) Visits a ReturnTree node.Visits a SeeTree node.visitSerial(SerialTree node, P p) Visits a SerialTree node.visitSerialData(SerialDataTree node, P p) Visits a SerialDataTree node.visitSerialField(SerialFieldTree node, P p) Visits a SerialFieldTree node.visitSince(SinceTree node, P p) Visits a SinceTree node.visitStartElement(StartElementTree node, P p) Visits a StartElementTree node.visitSummary(SummaryTree node, P p) Visits a SummaryTree node.visitSystemProperty(SystemPropertyTree node, P p) Visits a SystemPropertyTree node.Visits a TextTree node.visitThrows(ThrowsTree node, P p) Visits a ThrowsTree node.visitUnknownBlockTag(UnknownBlockTagTree node, P p) Visits an UnknownBlockTagTree node.visitUnknownInlineTag(UnknownInlineTagTree node, P p) Visits an UnknownInlineTagTree node.Visits a UsesTree node.visitValue(ValueTree node, P p) Visits a ValueTree node.visitVersion(VersionTree node, P p) Visits a VersionTree node.
-
Constructor Details
-
DocTreeScanner
public DocTreeScanner()Constructs aDocTreeScanner.
-
-
Method Details
-
scan
Scans a single node.- Parameters:
node- the node to be scannedp- a parameter value passed to the visit method- Returns:
- the result value from the visit method
-
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
reducemethod.
-
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 an AttributeTree node.- Specified by:
visitAttributein interfaceDocTreeVisitor<R,P> - Parameters:
node- the node being visitedp- a parameter value- Returns:
- the result of scanning
-
visitAuthor
Visits an AuthorTree node.- Specified by:
visitAuthorin interfaceDocTreeVisitor<R,P> - Parameters:
node- the node being visitedp- a parameter value- Returns:
- the result of scanning
-
visitComment
Visits a CommentTree node.- Specified by:
visitCommentin interfaceDocTreeVisitor<R,P> - Parameters:
node- the node being visitedp- a parameter value- Returns:
- the result of scanning
-
visitDeprecated
Visits a DeprecatedTree node.- Specified by:
visitDeprecatedin interfaceDocTreeVisitor<R,P> - Parameters:
node- the node being visitedp- a parameter value- Returns:
- the result of scanning
-
visitDocComment
Visits a DocCommentTree node.- Specified by:
visitDocCommentin interfaceDocTreeVisitor<R,P> - Parameters:
node- the node being visitedp- a parameter value- Returns:
- the result of scanning
-
visitDocRoot
Visits a DocRootTree node.- Specified by:
visitDocRootin interfaceDocTreeVisitor<R,P> - Parameters:
node- the node being visitedp- a parameter value- Returns:
- the result of scanning
-
visitDocType
Visits a DocTypeTree node.- Specified by:
visitDocTypein interfaceDocTreeVisitor<R,P> - Parameters:
node- the node being visitedp- a parameter value- Returns:
- the result of scanning
-
visitEndElement
Visits an EndElementTree node.- Specified by:
visitEndElementin interfaceDocTreeVisitor<R,P> - Parameters:
node- the node being visitedp- a parameter value- Returns:
- the result of scanning
-
visitEntity
Visits an EntityTree node.- Specified by:
visitEntityin interfaceDocTreeVisitor<R,P> - Parameters:
node- the node being visitedp- a parameter value- Returns:
- the result of scanning
-
visitErroneous
Visits an ErroneousTree node.- Specified by:
visitErroneousin interfaceDocTreeVisitor<R,P> - Parameters:
node- the node being visitedp- a parameter value- Returns:
- the result of scanning
-
visitHidden
Visits a HiddenTree node.- Specified by:
visitHiddenin interfaceDocTreeVisitor<R,P> - Parameters:
node- the node being visitedp- a parameter value- Returns:
- the result of scanning
-
visitIdentifier
Visits an IdentifierTree node.- Specified by:
visitIdentifierin interfaceDocTreeVisitor<R,P> - Parameters:
node- the node being visitedp- a parameter value- Returns:
- the result of scanning
-
visitIndex
Visits an IndexTree node.- Specified by:
visitIndexin interfaceDocTreeVisitor<R,P> - Parameters:
node- the node being visitedp- a parameter value- Returns:
- the result of scanning
-
visitInheritDoc
Visits an InheritDocTree node.- Specified by:
visitInheritDocin interfaceDocTreeVisitor<R,P> - Parameters:
node- the node being visitedp- a parameter value- Returns:
- the result of scanning
-
visitLink
Visits a LinkTree node.- Specified by:
visitLinkin interfaceDocTreeVisitor<R,P> - Parameters:
node- the node being visitedp- a parameter value- Returns:
- the result of scanning
-
visitLiteral
Visits an LiteralTree node.- Specified by:
visitLiteralin interfaceDocTreeVisitor<R,P> - Parameters:
node- the node being visitedp- a parameter value- Returns:
- the result of scanning
-
visitParam
Visits a ParamTree node.- Specified by:
visitParamin interfaceDocTreeVisitor<R,P> - Parameters:
node- the node being visitedp- a parameter value- Returns:
- the result of scanning
-
visitProvides
Visits a ProvidesTree node.- Specified by:
visitProvidesin interfaceDocTreeVisitor<R,P> - Parameters:
node- the node being visitedp- a parameter value- Returns:
- the result of scanning
-
visitReference
Visits a ReferenceTree node.- Specified by:
visitReferencein interfaceDocTreeVisitor<R,P> - Parameters:
node- the node being visitedp- a parameter value- Returns:
- the result of scanning
-
visitReturn
Visits a ReturnTree node.- Specified by:
visitReturnin interfaceDocTreeVisitor<R,P> - Parameters:
node- the node being visitedp- a parameter value- Returns:
- the result of scanning
-
visitSee
Visits a SeeTree node.- Specified by:
visitSeein interfaceDocTreeVisitor<R,P> - Parameters:
node- the node being visitedp- a parameter value- Returns:
- the result of scanning
-
visitSerial
Visits a SerialTree node.- Specified by:
visitSerialin interfaceDocTreeVisitor<R,P> - Parameters:
node- the node being visitedp- a parameter value- Returns:
- the result of scanning
-
visitSerialData
Visits a SerialDataTree node.- Specified by:
visitSerialDatain interfaceDocTreeVisitor<R,P> - Parameters:
node- the node being visitedp- a parameter value- Returns:
- the result of scanning
-
visitSerialField
Visits a SerialFieldTree node.- Specified by:
visitSerialFieldin interfaceDocTreeVisitor<R,P> - Parameters:
node- the node being visitedp- a parameter value- Returns:
- the result of scanning
-
visitSince
Visits a SinceTree node.- Specified by:
visitSincein interfaceDocTreeVisitor<R,P> - Parameters:
node- the node being visitedp- a parameter value- Returns:
- the result of scanning
-
visitStartElement
Visits a StartElementTree node.- Specified by:
visitStartElementin interfaceDocTreeVisitor<R,P> - Parameters:
node- the node being visitedp- a parameter value- Returns:
- the result of scanning
-
visitSummary
Visits a SummaryTree node.- Specified by:
visitSummaryin interfaceDocTreeVisitor<R,P> - Parameters:
node- the node being visitedp- a parameter value- Returns:
- the result of scanning
- Since:
- 10
-
visitSystemProperty
Visits a SystemPropertyTree node.- Specified by:
visitSystemPropertyin interfaceDocTreeVisitor<R,P> - Parameters:
node- the node being visitedp- a parameter value- Returns:
- the result of scanning
- Since:
- 12
-
visitText
Visits a TextTree node.- Specified by:
visitTextin interfaceDocTreeVisitor<R,P> - Parameters:
node- the node being visitedp- a parameter value- Returns:
- the result of scanning
-
visitThrows
Visits a ThrowsTree node.- Specified by:
visitThrowsin interfaceDocTreeVisitor<R,P> - Parameters:
node- the node being visitedp- a parameter value- Returns:
- the result of scanning
-
visitUnknownBlockTag
Visits an UnknownBlockTagTree node.- Specified by:
visitUnknownBlockTagin interfaceDocTreeVisitor<R,P> - Parameters:
node- the node being visitedp- a parameter value- Returns:
- the result of scanning
-
visitUnknownInlineTag
Visits an UnknownInlineTagTree node.- Specified by:
visitUnknownInlineTagin interfaceDocTreeVisitor<R,P> - Parameters:
node- the node being visitedp- a parameter value- Returns:
- the result of scanning
-
visitUses
Visits a UsesTree node.- Specified by:
visitUsesin interfaceDocTreeVisitor<R,P> - Parameters:
node- the node being visitedp- a parameter value- Returns:
- the result of scanning
-
visitValue
Visits a ValueTree node.- Specified by:
visitValuein interfaceDocTreeVisitor<R,P> - Parameters:
node- the node being visitedp- a parameter value- Returns:
- the result of scanning
-
visitVersion
Visits a VersionTree node.- Specified by:
visitVersionin interfaceDocTreeVisitor<R,P> - Parameters:
node- the node being visitedp- a parameter value- Returns:
- the result of scanning
-
visitOther
Visits an unknown type of DocTree node. This can occur if the set of tags evolves and new kinds of nodes are added to theDocTreehierarchy.- Specified by:
visitOtherin interfaceDocTreeVisitor<R,P> - Parameters:
node- the node being visitedp- a parameter value- Returns:
- the result of scanning
-