⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 nodetraverser.java

📁 一个Java持久层类库
💻 JAVA
字号:
package org.hibernate.hql.ast.util;import antlr.collections.AST;/** * A visitor for traversing an AST tree. * * @author Steve Ebersole */public class NodeTraverser {	public static interface VisitationStrategy {		public void visit(AST node);	}	private final VisitationStrategy strategy;	public NodeTraverser(VisitationStrategy strategy) {		this.strategy = strategy;	}	/**	 * Traverse the AST tree depth first.	 * <p/>	 * Note that the AST passed in is not visited itself.  Visitation starts	 * with its children.	 *	 * @param ast	 */	public void traverseDepthFirst(AST ast) {		if ( ast == null ) {			throw new IllegalArgumentException( "node to traverse cannot be null!" );		}		visitDepthFirst( ast.getFirstChild() );	}	private void visitDepthFirst(AST ast) {		if ( ast == null ) {			return;		}		strategy.visit( ast );		visitDepthFirst( ast.getFirstChild() );		visitDepthFirst( ast.getNextSibling() );	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -