com.sun.source.util

## Class DocTreeScanner<R,P>

- java.lang.Object
- - com.sun.source.util.DocTreeScanner<R,P>

- All Implemented Interfaces:
    DocTreeVisitor<R,P>
  Direct Known Subclasses:
    DocTreePathScanner

      @Exported
      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 `scan` on 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` each child in turn, and then combining the result of each scan after the first with the cumulative result so far, as determined by the `reduce(R, R)` method. Each child may be either a simple node of a list of nodes. The default behavior of the `reduce` method 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 Summary

    Constructors
    Constructor and Description
    `DocTreeScanner()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `R` | `reduce(R r1, R r2)` Reduces two results into a combined result.
    `R` | `scan(DocTree node, P p)` Scan a single node.
    `R` | `scan(Iterable<? extends DocTree> nodes, P p)` Scan a list of nodes.
    `R` | `visitAttribute(AttributeTree node, P p)`
    `R` | `visitAuthor(AuthorTree node, P p)`
    `R` | `visitComment(CommentTree node, P p)`
    `R` | `visitDeprecated(DeprecatedTree node, P p)`
    `R` | `visitDocComment(DocCommentTree node, P p)`
    `R` | `visitDocRoot(DocRootTree node, P p)`
    `R` | `visitEndElement(EndElementTree node, P p)`
    `R` | `visitEntity(EntityTree node, P p)`
    `R` | `visitErroneous(ErroneousTree node, P p)`
    `R` | `visitIdentifier(IdentifierTree node, P p)`
    `R` | `visitInheritDoc(InheritDocTree node, P p)`
    `R` | `visitLink(LinkTree node, P p)`
    `R` | `visitLiteral(LiteralTree node, P p)`
    `R` | `visitOther(DocTree node, P p)`
    `R` | `visitParam(ParamTree node, P p)`
    `R` | `visitReference(ReferenceTree node, P p)`
    `R` | `visitReturn(ReturnTree node, P p)`
    `R` | `visitSee(SeeTree node, P p)`
    `R` | `visitSerial(SerialTree node, P p)`
    `R` | `visitSerialData(SerialDataTree node, P p)`
    `R` | `visitSerialField(SerialFieldTree node, P p)`
    `R` | `visitSince(SinceTree node, P p)`
    `R` | `visitStartElement(StartElementTree node, P p)`
    `R` | `visitText(TextTree node, P p)`
    `R` | `visitThrows(ThrowsTree node, P p)`
    `R` | `visitUnknownBlockTag(UnknownBlockTagTree node, P p)`
    `R` | `visitUnknownInlineTag(UnknownInlineTagTree node, P p)`
    `R` | `visitValue(ValueTree node, P p)`
    `R` | `visitVersion(VersionTree node, P p)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### DocTreeScanner

          public DocTreeScanner()

  - ### Method Detail

    - #### scan

          public R scan(DocTree node,
                        P p)

      Scan a single node.

    - #### scan

          public R scan(Iterable<? extends DocTree> nodes,
                        P p)

      Scan a list of nodes.

    - #### reduce

          public R reduce(R r1,
                          R r2)

      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.

    - #### visitAttribute

          public R visitAttribute(AttributeTree node,
                                  P p)

      Specified by:
        `visitAttribute` in interface `DocTreeVisitor<R,P>`

    - #### visitAuthor

          public R visitAuthor(AuthorTree node,
                               P p)

      Specified by:
        `visitAuthor` in interface `DocTreeVisitor<R,P>`

    - #### visitComment

          public R visitComment(CommentTree node,
                                P p)

      Specified by:
        `visitComment` in interface `DocTreeVisitor<R,P>`

    - #### visitDeprecated

          public R visitDeprecated(DeprecatedTree node,
                                   P p)

      Specified by:
        `visitDeprecated` in interface `DocTreeVisitor<R,P>`

    - #### visitDocComment

          public R visitDocComment(DocCommentTree node,
                                   P p)

      Specified by:
        `visitDocComment` in interface `DocTreeVisitor<R,P>`

    - #### visitDocRoot

          public R visitDocRoot(DocRootTree node,
                                P p)

      Specified by:
        `visitDocRoot` in interface `DocTreeVisitor<R,P>`

    - #### visitEndElement

          public R visitEndElement(EndElementTree node,
                                   P p)

      Specified by:
        `visitEndElement` in interface `DocTreeVisitor<R,P>`

    - #### visitEntity

          public R visitEntity(EntityTree node,
                               P p)

      Specified by:
        `visitEntity` in interface `DocTreeVisitor<R,P>`

    - #### visitErroneous

          public R visitErroneous(ErroneousTree node,
                                  P p)

      Specified by:
        `visitErroneous` in interface `DocTreeVisitor<R,P>`

    - #### visitIdentifier

          public R visitIdentifier(IdentifierTree node,
                                   P p)

      Specified by:
        `visitIdentifier` in interface `DocTreeVisitor<R,P>`

    - #### visitInheritDoc

          public R visitInheritDoc(InheritDocTree node,
                                   P p)

      Specified by:
        `visitInheritDoc` in interface `DocTreeVisitor<R,P>`

    - #### visitLink

          public R visitLink(LinkTree node,
                             P p)

      Specified by:
        `visitLink` in interface `DocTreeVisitor<R,P>`

    - #### visitLiteral

          public R visitLiteral(LiteralTree node,
                                P p)

      Specified by:
        `visitLiteral` in interface `DocTreeVisitor<R,P>`

    - #### visitParam

          public R visitParam(ParamTree node,
                              P p)

      Specified by:
        `visitParam` in interface `DocTreeVisitor<R,P>`

    - #### visitReference

          public R visitReference(ReferenceTree node,
                                  P p)

      Specified by:
        `visitReference` in interface `DocTreeVisitor<R,P>`

    - #### visitReturn

          public R visitReturn(ReturnTree node,
                               P p)

      Specified by:
        `visitReturn` in interface `DocTreeVisitor<R,P>`

    - #### visitSee

          public R visitSee(SeeTree node,
                            P p)

      Specified by:
        `visitSee` in interface `DocTreeVisitor<R,P>`

    - #### visitSerial

          public R visitSerial(SerialTree node,
                               P p)

      Specified by:
        `visitSerial` in interface `DocTreeVisitor<R,P>`

    - #### visitSerialData

          public R visitSerialData(SerialDataTree node,
                                   P p)

      Specified by:
        `visitSerialData` in interface `DocTreeVisitor<R,P>`

    - #### visitSerialField

          public R visitSerialField(SerialFieldTree node,
                                    P p)

      Specified by:
        `visitSerialField` in interface `DocTreeVisitor<R,P>`

    - #### visitSince

          public R visitSince(SinceTree node,
                              P p)

      Specified by:
        `visitSince` in interface `DocTreeVisitor<R,P>`

    - #### visitStartElement

          public R visitStartElement(StartElementTree node,
                                     P p)

      Specified by:
        `visitStartElement` in interface `DocTreeVisitor<R,P>`

    - #### visitText

          public R visitText(TextTree node,
                             P p)

      Specified by:
        `visitText` in interface `DocTreeVisitor<R,P>`

    - #### visitThrows

          public R visitThrows(ThrowsTree node,
                               P p)

      Specified by:
        `visitThrows` in interface `DocTreeVisitor<R,P>`

    - #### visitUnknownBlockTag

          public R visitUnknownBlockTag(UnknownBlockTagTree node,
                                        P p)

      Specified by:
        `visitUnknownBlockTag` in interface `DocTreeVisitor<R,P>`

    - #### visitUnknownInlineTag

          public R visitUnknownInlineTag(UnknownInlineTagTree node,
                                         P p)

      Specified by:
        `visitUnknownInlineTag` in interface `DocTreeVisitor<R,P>`

    - #### visitValue

          public R visitValue(ValueTree node,
                              P p)

      Specified by:
        `visitValue` in interface `DocTreeVisitor<R,P>`

    - #### visitVersion

          public R visitVersion(VersionTree node,
                                P p)

      Specified by:
        `visitVersion` in interface `DocTreeVisitor<R,P>`

    - #### visitOther

          public R visitOther(DocTree node,
                              P p)

      Specified by:
        `visitOther` in interface `DocTreeVisitor<R,P>`

Copyright © 2005, 2016, Oracle and/or its affiliates. All rights reserved.