All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jvnet.jaxbcommons.tree.ClassSearchingNodeVisitor Maven / Gradle / Ivy

There is a newer version: 1.0.4.7
Show newest version
package org.jvnet.jaxbcommons.tree;

import java.util.LinkedList;
import java.util.List;

public class ClassSearchingNodeVisitor implements NodeVisitor {

  private final Class targetClass;

  private final List foundNodes;

  public ClassSearchingNodeVisitor(final Class theClass) {
    this.targetClass = theClass;
    this.foundNodes = new LinkedList();
  }

  public Object visitNode(Node node) {
    if (targetClass.equals(node.getType())) {
      foundNodes.add(node);
    }

    final Node[] children = node.getChildren();
    for (int index = 0; index < children.length; index++) {
      final Node childNode = children[index];
      childNode.visit(this);
    }
    return foundNodes;
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy