varnamecollector.java

来自「java jdk 1.4的源码」· Java 代码 · 共 61 行

JAVA
61
字号
package org.apache.xalan.templates;import java.util.Vector;import org.apache.xml.utils.QName;import org.apache.xpath.ExpressionOwner;import org.apache.xpath.XPathVisitor;import org.apache.xpath.operations.Variable;/** * This class visits variable refs in an XPath and collects their QNames. */public class VarNameCollector extends XPathVisitor{	Vector m_refs = new Vector();		/**	 * Reset the list for a fresh visitation and collection.	 */	public void reset()	{		m_refs.removeAllElements(); //.clear();	}		/**	 * Get the number of variable references that were collected.	 * @return the size of the list.	 */	public int getVarCount()	{		return m_refs.size();	}		/**	 * Tell if the given qualified name occurs in 	 * the list of qualified names collected.	 * 	 * @param refName Must be a valid qualified name.	 * @return true if the list contains the qualified name.	 */	boolean doesOccur(QName refName)	{		return m_refs.contains(refName);	}	/**	 * Visit a variable reference.	 * @param owner The owner of the expression, to which the expression can 	 *              be reset if rewriting takes place.	 * @param var The variable reference object.	 * @return true if the sub expressions should be traversed.	 */	public boolean visitVariableRef(ExpressionOwner owner, Variable var)	{		m_refs.addElement(var.getQName());		return true;	}}

⌨️ 快捷键说明

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