View Javadoc

    1   /**
    2    * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
    3    */
    4   package net.sourceforge.pmd.dcd.graph;
    5
    6   import java.util.List;
    7
    8   /**
    9    * Adapter class for easy implementation of a NodeVisitor.  Subclasses
    10   * need only override methods to add behavior, and call <code>super</code> to
    11   * continue the visitation.
    12   */
    13  public class NodeVisitorAdapter implements NodeVisitor {
    14
    15  	public NodeVisitorAdapter() {
    16  	}
    17
    18  	public Object visit(UsageGraph usageGraph, Object data) {
    19  		return usageGraph.accept(this, data);
    20  	}
    21
    22  	public Object visit(ClassNode classNode, Object data) {
    23  		return classNode.accept(this, data);
    24  	}
    25
    26  	public Object visitFields(ClassNode classNode, Object data) {
    27  		for (FieldNode fieldNode : classNode.getFieldNodes()) {
    28  			visit(fieldNode, data);
    29  		}
    30  		return data;
    31  	}
    32
    33  	public Object visit(FieldNode fieldNode, Object data) {
    34  		return fieldNode.accept(this, data);
    35  	}
    36
    37  	public Object visitConstructors(ClassNode classNode, Object data) {
    38  		for (ConstructorNode constructorNode : classNode.getConstructorNodes()) {
    39  			visit(constructorNode, data);
    40  		}
    41  		return data;
    42  	}
    43
    44  	public Object visit(ConstructorNode constructorNode, Object data) {
    45  		return constructorNode.accept(this, data);
    46  	}
    47
    48  	public Object visitMethods(ClassNode classNode, Object data) {
    49  		for (MethodNode methodNode : classNode.getMethodNodes()) {
    50  			visit(methodNode, data);
    51  		}
    52  		return data;
    53  	}
    54
    55  	public Object visit(MethodNode methodNode, Object data) {
    56  		return methodNode.accept(this, data);
    57  	}
    58
    59  	public Object visitUses(MemberNode memberNode, Object data) {
    60  		for (MemberNode use : (List<MemberNode>)memberNode.getUses()) {
    61  			this.visitUse(use, data);
    62  		}
    63  		return data;
    64  	}
    65
    66  	public Object visitUse(MemberNode memberNode, Object data) {
    67  		return data;
    68  	}
    69
    70  	public Object visitUsers(MemberNode memberNode, Object data) {
    71  		for (MemberNode user : (List<MemberNode>)memberNode.getUsers()) {
    72  			this.visitUser(user, data);
    73  		}
    74  		return data;
    75  	}
    76
    77  	public Object visitUser(MemberNode memberNode, Object data) {
    78  		return data;
    79  	}
    80  }