org.apache.xalan.xsltc.compiler
Class TestSeq

java.lang.Object
  extended by org.apache.xalan.xsltc.compiler.TestSeq

final class TestSeq
extends java.lang.Object

A test sequence is a sequence of patterns that (1) occured in templates in the same mode (2) share the same kernel node type (e.g. A/B and C/C/B) (3) may also contain patterns matching "*" and "node()" (element sequence only) or matching "@*" (attribute sequence only). A test sequence may have a default template, which will be instantiated if none of the other patterns match.


Field Summary
private  Template _default
          Default template for this test sequence
private  InstructionList _instructionList
          Instruction list representing this test sequence.
private  int _kernelType
          Integer code for the kernel type of this test sequence
private  Mode _mode
          A reference to the Mode object.
private  java.util.Vector _patterns
          Vector of all patterns in the test sequence.
private  InstructionHandle _start
          Cached handle to avoid compiling more than once.
 
Constructor Summary
TestSeq(java.util.Vector patterns, int kernelType, Mode mode)
           
TestSeq(java.util.Vector patterns, Mode mode)
          Creates a new test sequence given a set of patterns and a mode.
 
Method Summary
 InstructionHandle compile(ClassGenerator classGen, MethodGenerator methodGen, InstructionHandle continuation)
          Compile the code for this test sequence.
 void findTemplates(java.util.Dictionary templates)
          Returns, by reference, the templates that are included in this test sequence.
 InstructionList getInstructionList()
          Returns the instruction list for this test sequence
private  LocationPathPattern getPattern(int n)
          Returns pattern n in this test sequence
 int getPosition()
          Returns the position of the highest priority pattern in this test sequence.
 double getPriority()
          Return the highest priority for a pattern in this test sequence.
private  InstructionHandle getTemplateHandle(Template template)
          Get the instruction handle to a template's code.
 void reduce()
          Reduce the patterns in this test sequence.
 java.lang.String toString()
          Returns a string representation of this test sequence.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_kernelType

private int _kernelType
Integer code for the kernel type of this test sequence


_patterns

private java.util.Vector _patterns
Vector of all patterns in the test sequence. May include patterns with "*", "@*" or "node()" kernel.


_mode

private Mode _mode
A reference to the Mode object.


_default

private Template _default
Default template for this test sequence


_instructionList

private InstructionList _instructionList
Instruction list representing this test sequence.


_start

private InstructionHandle _start
Cached handle to avoid compiling more than once.

Constructor Detail

TestSeq

public TestSeq(java.util.Vector patterns,
               Mode mode)
Creates a new test sequence given a set of patterns and a mode.


TestSeq

public TestSeq(java.util.Vector patterns,
               int kernelType,
               Mode mode)
Method Detail

toString

public java.lang.String toString()
Returns a string representation of this test sequence. Notice that test sequences are mutable, so the value returned by this method is different before and after calling reduce().

Overrides:
toString in class java.lang.Object

getInstructionList

public InstructionList getInstructionList()
Returns the instruction list for this test sequence


getPriority

public double getPriority()
Return the highest priority for a pattern in this test sequence. This is either the priority of the first or of the default pattern.


getPosition

public int getPosition()
Returns the position of the highest priority pattern in this test sequence.


reduce

public void reduce()
Reduce the patterns in this test sequence. Creates a new vector of patterns and sets the default pattern if it finds a patterns that is fully reduced.


findTemplates

public void findTemplates(java.util.Dictionary templates)
Returns, by reference, the templates that are included in this test sequence. Note that a single template can occur in several test sequences if its pattern is a union.


getTemplateHandle

private InstructionHandle getTemplateHandle(Template template)
Get the instruction handle to a template's code. This is used when a single template occurs in several test sequences; that is, if its pattern is a union of patterns (e.g. match="A/B | A/C").


getPattern

private LocationPathPattern getPattern(int n)
Returns pattern n in this test sequence


compile

public InstructionHandle compile(ClassGenerator classGen,
                                 MethodGenerator methodGen,
                                 InstructionHandle continuation)
Compile the code for this test sequence. Compile patterns from highest to lowest priority. Note that since patterns can be share by multiple test sequences, instruction lists must be copied before backpatching.