KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > xalan > xsltc > compiler > util > NodeCounterGenerator


1 /*
2  * Copyright 2001-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: NodeCounterGenerator.java,v 1.6 2004/02/16 22:26:45 minchau Exp $
18  */

19
20 package org.apache.xalan.xsltc.compiler.util;
21
22 import org.apache.bcel.generic.ALOAD;
23 import org.apache.bcel.generic.Instruction;
24 import org.apache.xalan.xsltc.compiler.Stylesheet;
25
26 /**
27  * This class implements auxiliary classes needed to compile
28  * patterns in <tt>xsl:number</tt>. These classes inherit from
29  * {Any,Single,Multiple}NodeCounter and override the
30  * <tt>matchFrom</tt> and <tt>matchCount</tt> methods.
31  * @author Jacek Ambroziak
32  * @author Santiago Pericas-Geertsen
33  */

34 public final class NodeCounterGenerator extends ClassGenerator {
35     private Instruction _aloadTranslet;
36
37     public NodeCounterGenerator(String JavaDoc className,
38                 String JavaDoc superClassName,
39                     String JavaDoc fileName,
40                     int accessFlags,
41                 String JavaDoc[] interfaces,
42                     Stylesheet stylesheet) {
43     super(className, superClassName, fileName,
44           accessFlags, interfaces, stylesheet);
45     }
46
47     /**
48      * Set the index of the register where "this" (the pointer to
49      * the translet) is stored.
50      */

51     public void setTransletIndex(int index) {
52     _aloadTranslet = new ALOAD(index);
53     }
54
55     /**
56      * The index of the translet pointer within the execution of
57      * matchFrom or matchCount.
58      * Overridden from ClassGenerator.
59      */

60     public Instruction loadTranslet() {
61     return _aloadTranslet;
62     }
63     
64     /**
65      * Returns <tt>true</tt> since this class is external to the
66      * translet.
67      */

68     public boolean isExternal() {
69     return true;
70     }
71 }
72
Popular Tags