IT. Expert System.

Java Standard Edition (SE)

TreeScanner


com.sun.source.util

Class TreeScanner<R,P>

  • All Implemented Interfaces:
    TreeVisitor<R,P>
    Direct Known Subclasses:
    TreePathScanner


    @Exported
    public class TreeScanner<R,P>
    extends Object
    implements TreeVisitor<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 identifier nodes in a tree:

       class CountIdentifiers extends TreeScanner<Integer,Void> {
           @Override
          public Integer visitIdentifier(IdentifierTree node, Void p) {
              return 1;
          }
           @Override
          public Integer reduce(Integer r1, Integer r2) {
              return (r1 == null ? 0 : r1) + (r2 == null ? 0 : r2);
          }
       }
     
    Since:
    1.6


Content

Android Reference

Java basics

Java Enterprise Edition (EE)

Java Standard Edition (SE)

SQL

HTML

PHP

CSS

Java Script

MYSQL

JQUERY

VBS

REGEX

C

C++

C#

Design patterns

RFC (standard status)

RFC (proposed standard status)

RFC (draft standard status)

RFC (informational status)

RFC (experimental status)

RFC (best current practice status)

RFC (historic status)

RFC (unknown status)

IT dictionary

License.
All information of this service is derived from the free sources and is provided solely in the form of quotations. This service provides information and interfaces solely for the familiarization (not ownership) and under the "as is" condition.
Copyright 2016 © ELTASK.COM. All rights reserved.
Site is optimized for mobile devices.
Downloads: 111 / 158695262. Delta: 0.05806 с