java.lang.Object
com.sun.source.util.DocTreeScanner<R,P>
- All Implemented Interfaces:
- DocTreeVisitor<R,P>
- Direct Known Subclasses:
- DocTreePathScanner
public class DocTreeScanner<R,P> extends Object implements DocTreeVisitor<R,P>
A TreeVisitor 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.
 
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 scanon 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 scaneach 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 of a list of nodes. The default behavior of thereducemethod is such that the result of the visitXYZ method will be the result of the last child scanned.
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 SummaryConstructors Constructor Description DocTreeScanner()
- 
Method SummaryModifier and Type Method Description Rreduce(R r1, R r2)Reduces two results into a combined result.Rscan(DocTree node, P p)Scans a single node.Rscan(Iterable<? extends DocTree> nodes, P p)Scans a sequence of nodes.RvisitAttribute(AttributeTree node, P p)Visits an AttributeTree node.RvisitAuthor(AuthorTree node, P p)Visits an AuthorTree node.RvisitComment(CommentTree node, P p)Visits a CommentTree node.RvisitDeprecated(DeprecatedTree node, P p)Visits a DeprecatedTree node.RvisitDocComment(DocCommentTree node, P p)Visits a DocCommentTree node.RvisitDocRoot(DocRootTree node, P p)Visits a DocRootTree node.RvisitDocType(DocTypeTree node, P p)Visits a DocTypeTree node.RvisitEndElement(EndElementTree node, P p)Visits an EndElementTree node.RvisitEntity(EntityTree node, P p)Visits an EntityTree node.RvisitErroneous(ErroneousTree node, P p)Visits an ErroneousTree node.RvisitHidden(HiddenTree node, P p)Visits a HiddenTree node.RvisitIdentifier(IdentifierTree node, P p)Visits an IdentifierTree node.RvisitIndex(IndexTree node, P p)Visits an IndexTree node.RvisitInheritDoc(InheritDocTree node, P p)Visits an InheritDocTree node.RvisitLink(LinkTree node, P p)Visits a LinkTree node.RvisitLiteral(LiteralTree node, P p)Visits an LiteralTree node.RvisitOther(DocTree node, P p)Visits an unknown type of DocTree node.RvisitParam(ParamTree node, P p)Visits a ParamTree node.RvisitProvides(ProvidesTree node, P p)Visits a ProvidesTree node.RvisitReference(ReferenceTree node, P p)Visits a ReferenceTree node.RvisitReturn(ReturnTree node, P p)Visits a ReturnTree node.RvisitSee(SeeTree node, P p)Visits a SeeTree node.RvisitSerial(SerialTree node, P p)Visits a SerialTree node.RvisitSerialData(SerialDataTree node, P p)Visits a SerialDataTree node.RvisitSerialField(SerialFieldTree node, P p)Visits a SerialFieldTree node.RvisitSince(SinceTree node, P p)Visits a SinceTree node.RvisitStartElement(StartElementTree node, P p)Visits a StartElementTree node.RvisitSummary(SummaryTree node, P p)Visits a SummaryTree node.RvisitSystemProperty(SystemPropertyTree node, P p)Visits a SystemPropertyTree node.RvisitText(TextTree node, P p)Visits a TextTree node.RvisitThrows(ThrowsTree node, P p)Visits a ThrowsTree node.RvisitUnknownBlockTag(UnknownBlockTagTree node, P p)Visits an UnknownBlockTagTree node.RvisitUnknownInlineTag(UnknownInlineTagTree node, P p)Visits an UnknownInlineTagTree node.RvisitUses(UsesTree node, P p)Visits a UsesTree node.RvisitValue(ValueTree node, P p)Visits a ValueTree node.RvisitVersion(VersionTree node, P p)Visits a VersionTreeTree node.
- 
Constructor Details- 
DocTreeScannerpublic DocTreeScanner()
 
- 
- 
Method Details- 
scanScans a single node.- Parameters:
- node- the node to be scanned
- p- a parameter value passed to the visit method
- Returns:
- the result value from the visit method
 
- 
scanScans a sequence of nodes.- Parameters:
- nodes- the nodes to be scanned
- p- 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.
 
- 
reduceReduces 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 combined
- r2- the second of the values to be combined
- Returns:
- the result of combining the two parameters
 
- 
visitAttributeVisits an AttributeTree node. This implementation scans the children in left to right order.- Specified by:
- visitAttributein interface- DocTreeVisitor<R,P>
- Parameters:
- node- the node being visited
- p- a parameter value
- Returns:
- the result of scanning
 
- 
visitAuthorVisits an AuthorTree node. This implementation scans the children in left to right order.- Specified by:
- visitAuthorin interface- DocTreeVisitor<R,P>
- Parameters:
- node- the node being visited
- p- a parameter value
- Returns:
- the result of scanning
 
- 
visitCommentVisits a CommentTree node. This implementation returnsnull.- Specified by:
- visitCommentin interface- DocTreeVisitor<R,P>
- Parameters:
- node- the node being visited
- p- a parameter value
- Returns:
- the result of scanning
 
- 
visitDeprecatedVisits a DeprecatedTree node. This implementation scans the children in left to right order.- Specified by:
- visitDeprecatedin interface- DocTreeVisitor<R,P>
- Parameters:
- node- the node being visited
- p- a parameter value
- Returns:
- the result of scanning
 
- 
visitDocCommentVisits a DocCommentTree node. This implementation scans the children in left to right order.- Specified by:
- visitDocCommentin interface- DocTreeVisitor<R,P>
- Parameters:
- node- the node being visited
- p- a parameter value
- Returns:
- the result of scanning
 
- 
visitDocRootVisits a DocRootTree node. This implementation returnsnull.- Specified by:
- visitDocRootin interface- DocTreeVisitor<R,P>
- Parameters:
- node- the node being visited
- p- a parameter value
- Returns:
- the result of scanning
 
- 
visitDocTypeVisits a DocTypeTree node. This implementation returnsnull.- Specified by:
- visitDocTypein interface- DocTreeVisitor<R,P>
- Parameters:
- node- the node being visited
- p- a parameter value
- Returns:
- the result of scanning
 
- 
visitEndElementVisits an EndElementTree node. This implementation returnsnull.- Specified by:
- visitEndElementin interface- DocTreeVisitor<R,P>
- Parameters:
- node- the node being visited
- p- a parameter value
- Returns:
- the result of scanning
 
- 
visitEntityVisits an EntityTree node. This implementation returnsnull.- Specified by:
- visitEntityin interface- DocTreeVisitor<R,P>
- Parameters:
- node- the node being visited
- p- a parameter value
- Returns:
- the result of scanning
 
- 
visitErroneousVisits an ErroneousTree node. This implementation returnsnull.- Specified by:
- visitErroneousin interface- DocTreeVisitor<R,P>
- Parameters:
- node- the node being visited
- p- a parameter value
- Returns:
- the result of scanning
 
- 
visitHiddenVisits a HiddenTree node. This implementation scans the children in left to right order.- Specified by:
- visitHiddenin interface- DocTreeVisitor<R,P>
- Parameters:
- node- the node being visited
- p- a parameter value
- Returns:
- the result of scanning
 
- 
visitIdentifierVisits an IdentifierTree node. This implementation returnsnull.- Specified by:
- visitIdentifierin interface- DocTreeVisitor<R,P>
- Parameters:
- node- the node being visited
- p- a parameter value
- Returns:
- the result of scanning
 
- 
visitIndexVisits an IndexTree node. This implementation returnsnull.- Specified by:
- visitIndexin interface- DocTreeVisitor<R,P>
- Parameters:
- node- the node being visited
- p- a parameter value
- Returns:
- the result of scanning
 
- 
visitInheritDocVisits an InheritDocTree node. This implementation returnsnull.- Specified by:
- visitInheritDocin interface- DocTreeVisitor<R,P>
- Parameters:
- node- the node being visited
- p- a parameter value
- Returns:
- the result of scanning
 
- 
visitLinkVisits a LinkTree node. This implementation scans the children in left to right order.- Specified by:
- visitLinkin interface- DocTreeVisitor<R,P>
- Parameters:
- node- the node being visited
- p- a parameter value
- Returns:
- the result of scanning
 
- 
visitLiteralVisits an LiteralTree node. This implementation scans the children in left to right order.- Specified by:
- visitLiteralin interface- DocTreeVisitor<R,P>
- Parameters:
- node- the node being visited
- p- a parameter value
- Returns:
- the result of scanning
 
- 
visitParamVisits a ParamTree node. This implementation scans the children in left to right order.- Specified by:
- visitParamin interface- DocTreeVisitor<R,P>
- Parameters:
- node- the node being visited
- p- a parameter value
- Returns:
- the result of scanning
 
- 
visitProvidesVisits a ProvidesTree node. This implementation scans the children in left to right order.- Specified by:
- visitProvidesin interface- DocTreeVisitor<R,P>
- Parameters:
- node- the node being visited
- p- a parameter value
- Returns:
- the result of scanning
 
- 
visitReferenceVisits a ReferenceTree node. This implementation returnsnull.- Specified by:
- visitReferencein interface- DocTreeVisitor<R,P>
- Parameters:
- node- the node being visited
- p- a parameter value
- Returns:
- the result of scanning
 
- 
visitReturnVisits a ReturnTree node. This implementation scans the children in left to right order.- Specified by:
- visitReturnin interface- DocTreeVisitor<R,P>
- Parameters:
- node- the node being visited
- p- a parameter value
- Returns:
- the result of scanning
 
- 
visitSeeVisits a SeeTree node. This implementation scans the children in left to right order.- Specified by:
- visitSeein interface- DocTreeVisitor<R,P>
- Parameters:
- node- the node being visited
- p- a parameter value
- Returns:
- the result of scanning
 
- 
visitSerialVisits a SerialTree node. This implementation scans the children in left to right order.- Specified by:
- visitSerialin interface- DocTreeVisitor<R,P>
- Parameters:
- node- the node being visited
- p- a parameter value
- Returns:
- the result of scanning
 
- 
visitSerialDataVisits a SerialDataTree node. This implementation scans the children in left to right order.- Specified by:
- visitSerialDatain interface- DocTreeVisitor<R,P>
- Parameters:
- node- the node being visited
- p- a parameter value
- Returns:
- the result of scanning
 
- 
visitSerialFieldVisits a SerialFieldTree node. This implementation scans the children in left to right order.- Specified by:
- visitSerialFieldin interface- DocTreeVisitor<R,P>
- Parameters:
- node- the node being visited
- p- a parameter value
- Returns:
- the result of scanning
 
- 
visitSinceVisits a SinceTree node. This implementation scans the children in left to right order.- Specified by:
- visitSincein interface- DocTreeVisitor<R,P>
- Parameters:
- node- the node being visited
- p- a parameter value
- Returns:
- the result of scanning
 
- 
visitStartElementVisits a StartElementTree node. This implementation scans the children in left to right order.- Specified by:
- visitStartElementin interface- DocTreeVisitor<R,P>
- Parameters:
- node- the node being visited
- p- a parameter value
- Returns:
- the result of scanning
 
- 
visitSummaryVisits a SummaryTree node. This implementation scans the children in left to right order.- Specified by:
- visitSummaryin interface- DocTreeVisitor<R,P>
- Parameters:
- node- the node being visited
- p- a parameter value
- Returns:
- the result of scanning
- Since:
- 10
 
- 
visitSystemPropertyVisits a SystemPropertyTree node. This implementation returnsnull.- Specified by:
- visitSystemPropertyin interface- DocTreeVisitor<R,P>
- Parameters:
- node- the node being visited
- p- a parameter value
- Returns:
- the result of scanning
- Since:
- 12
 
- 
visitTextVisits a TextTree node. This implementation returnsnull.- Specified by:
- visitTextin interface- DocTreeVisitor<R,P>
- Parameters:
- node- the node being visited
- p- a parameter value
- Returns:
- the result of scanning
 
- 
visitThrowsVisits a ThrowsTree node. This implementation scans the children in left to right order.- Specified by:
- visitThrowsin interface- DocTreeVisitor<R,P>
- Parameters:
- node- the node being visited
- p- a parameter value
- Returns:
- the result of scanning
 
- 
visitUnknownBlockTagVisits an UnknownBlockTagTree node. This implementation scans the children in left to right order.- Specified by:
- visitUnknownBlockTagin interface- DocTreeVisitor<R,P>
- Parameters:
- node- the node being visited
- p- a parameter value
- Returns:
- the result of scanning
 
- 
visitUnknownInlineTagVisits an UnknownInlineTagTree node. This implementation scans the children in left to right order.- Specified by:
- visitUnknownInlineTagin interface- DocTreeVisitor<R,P>
- Parameters:
- node- the node being visited
- p- a parameter value
- Returns:
- the result of scanning
 
- 
visitUsesVisits a UsesTree node. This implementation scans the children in left to right order.- Specified by:
- visitUsesin interface- DocTreeVisitor<R,P>
- Parameters:
- node- the node being visited
- p- a parameter value
- Returns:
- the result of scanning
 
- 
visitValueVisits a ValueTree node. This implementation scans the children in left to right order.- Specified by:
- visitValuein interface- DocTreeVisitor<R,P>
- Parameters:
- node- the node being visited
- p- a parameter value
- Returns:
- the result of scanning
 
- 
visitVersionVisits a VersionTreeTree node. This implementation scans the children in left to right order.- Specified by:
- visitVersionin interface- DocTreeVisitor<R,P>
- Parameters:
- node- the node being visited
- p- a parameter value
- Returns:
- the result of scanning
 
- 
visitOtherVisits an unknown type of DocTree node. This can occur if the set of tags evolves and new kinds of nodes are added to theDocTreehierarchy. This implementation returnsnull.- Specified by:
- visitOtherin interface- DocTreeVisitor<R,P>
- Parameters:
- node- the node being visited
- p- a parameter value
- Returns:
- the result of scanning
 
 
-