~ubuntu-branches/ubuntu/saucy/libxalan2-java/saucy-security

« back to all changes in this revision

Viewing changes to src/org/apache/xalan/templates/VarNameCollector.java

  • Committer: Bazaar Package Importer
  • Author(s): Michael Koch
  • Date: 2008-04-27 10:20:03 UTC
  • mfrom: (1.1.3 upstream) (3.1.11 hardy)
  • Revision ID: james.westby@ubuntu.com-20080427102003-qy06c2if0qayzwlg
Tags: 2.7.1-2
* Build-Depends on default-jdk-builddep. Closes: #477893
* Clarified debian/copyright.
* Don't use '-1' in Build-Depends.
* Updated watch file to match upstream correctly.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright 1999-2004 The Apache Software Foundation.
3
 
 *
4
 
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 
 * you may not use this file except in compliance with the License.
6
 
 * You may obtain a copy of the License at
7
 
 *
8
 
 *     http://www.apache.org/licenses/LICENSE-2.0
9
 
 *
10
 
 * Unless required by applicable law or agreed to in writing, software
11
 
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 
 * See the License for the specific language governing permissions and
14
 
 * limitations under the License.
15
 
 */
16
 
/*
17
 
 * $Id: VarNameCollector.java,v 1.5 2004/02/16 20:32:33 minchau Exp $
18
 
 */
19
 
package org.apache.xalan.templates;
20
 
 
21
 
import java.util.Vector;
22
 
 
23
 
import org.apache.xml.utils.QName;
24
 
import org.apache.xpath.ExpressionOwner;
25
 
import org.apache.xpath.XPathVisitor;
26
 
import org.apache.xpath.operations.Variable;
27
 
 
28
 
/**
29
 
 * This class visits variable refs in an XPath and collects their QNames.
30
 
 */
31
 
public class VarNameCollector extends XPathVisitor
32
 
{
33
 
        Vector m_refs = new Vector();
34
 
        
35
 
        /**
36
 
         * Reset the list for a fresh visitation and collection.
37
 
         */
38
 
        public void reset()
39
 
        {
40
 
                m_refs.removeAllElements(); //.clear();
41
 
        }
42
 
        
43
 
        /**
44
 
         * Get the number of variable references that were collected.
45
 
         * @return the size of the list.
46
 
         */
47
 
        public int getVarCount()
48
 
        {
49
 
                return m_refs.size();
50
 
        }
51
 
        
52
 
        /**
53
 
         * Tell if the given qualified name occurs in 
54
 
         * the list of qualified names collected.
55
 
         * 
56
 
         * @param refName Must be a valid qualified name.
57
 
         * @return true if the list contains the qualified name.
58
 
         */
59
 
        boolean doesOccur(QName refName)
60
 
        {
61
 
                return m_refs.contains(refName);
62
 
        }
63
 
 
64
 
        /**
65
 
         * Visit a variable reference.
66
 
         * @param owner The owner of the expression, to which the expression can 
67
 
         *              be reset if rewriting takes place.
68
 
         * @param var The variable reference object.
69
 
         * @return true if the sub expressions should be traversed.
70
 
         */
71
 
        public boolean visitVariableRef(ExpressionOwner owner, Variable var)
72
 
        {
73
 
                m_refs.addElement(var.getQName());
74
 
                return true;
75
 
        }
76
 
 
77
 
}
78
 
 
 
1
/*
 
2
 * Licensed to the Apache Software Foundation (ASF) under one
 
3
 * or more contributor license agreements. See the NOTICE file
 
4
 * distributed with this work for additional information
 
5
 * regarding copyright ownership. The ASF licenses this file
 
6
 * to you under the Apache License, Version 2.0 (the  "License");
 
7
 * you may not use this file except in compliance with the License.
 
8
 * You may obtain a copy of the License at
 
9
 *
 
10
 *     http://www.apache.org/licenses/LICENSE-2.0
 
11
 *
 
12
 * Unless required by applicable law or agreed to in writing, software
 
13
 * distributed under the License is distributed on an "AS IS" BASIS,
 
14
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
15
 * See the License for the specific language governing permissions and
 
16
 * limitations under the License.
 
17
 */
 
18
/*
 
19
 * $Id: VarNameCollector.java 468643 2006-10-28 06:56:03Z minchau $
 
20
 */
 
21
package org.apache.xalan.templates;
 
22
 
 
23
import java.util.Vector;
 
24
 
 
25
import org.apache.xml.utils.QName;
 
26
import org.apache.xpath.ExpressionOwner;
 
27
import org.apache.xpath.XPathVisitor;
 
28
import org.apache.xpath.operations.Variable;
 
29
 
 
30
/**
 
31
 * This class visits variable refs in an XPath and collects their QNames.
 
32
 */
 
33
public class VarNameCollector extends XPathVisitor
 
34
{
 
35
        Vector m_refs = new Vector();
 
36
        
 
37
        /**
 
38
         * Reset the list for a fresh visitation and collection.
 
39
         */
 
40
        public void reset()
 
41
        {
 
42
                m_refs.removeAllElements(); //.clear();
 
43
        }
 
44
        
 
45
        /**
 
46
         * Get the number of variable references that were collected.
 
47
         * @return the size of the list.
 
48
         */
 
49
        public int getVarCount()
 
50
        {
 
51
                return m_refs.size();
 
52
        }
 
53
        
 
54
        /**
 
55
         * Tell if the given qualified name occurs in 
 
56
         * the list of qualified names collected.
 
57
         * 
 
58
         * @param refName Must be a valid qualified name.
 
59
         * @return true if the list contains the qualified name.
 
60
         */
 
61
        boolean doesOccur(QName refName)
 
62
        {
 
63
                return m_refs.contains(refName);
 
64
        }
 
65
 
 
66
        /**
 
67
         * Visit a variable reference.
 
68
         * @param owner The owner of the expression, to which the expression can 
 
69
         *              be reset if rewriting takes place.
 
70
         * @param var The variable reference object.
 
71
         * @return true if the sub expressions should be traversed.
 
72
         */
 
73
        public boolean visitVariableRef(ExpressionOwner owner, Variable var)
 
74
        {
 
75
                m_refs.addElement(var.getQName());
 
76
                return true;
 
77
        }
 
78
 
 
79
}
 
80