- 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;
- }
-
- }
-