1 16 19 20 package com.sun.org.apache.xalan.internal.xsltc.compiler; 21 22 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; 23 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; 24 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; 25 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; 26 import com.sun.org.apache.xalan.internal.xsltc.dom.Axis; 27 28 33 public abstract class LocationPathPattern extends Pattern { 34 private Template _template; 35 private int _importPrecedence; 36 private double _priority = Double.NaN; 37 private int _position = 0; 38 39 public Type typeCheck(SymbolTable stable) throws TypeCheckError { 40 return Type.Void; } 42 43 public void translate(ClassGenerator classGen, MethodGenerator methodGen) { 44 } 46 47 public void setTemplate(final Template template) { 48 _template = template; 49 _priority = template.getPriority(); 50 _importPrecedence = template.getImportPrecedence(); 51 _position = template.getPosition(); 52 } 53 54 public Template getTemplate() { 55 return _template; 56 } 57 58 public final double getPriority() { 59 return Double.isNaN(_priority) ? getDefaultPriority() : _priority; 60 } 61 62 public double getDefaultPriority() { 63 return 0.5; 64 } 65 66 74 public boolean noSmallerThan(LocationPathPattern other) { 75 if (_importPrecedence > other._importPrecedence) { 76 return true; 77 } 78 else if (_importPrecedence == other._importPrecedence) { 79 if (_priority > other._priority) { 80 return true; 81 } 82 else if (_priority == other._priority) { 83 if (_position > other._position) { 84 return true; 85 } 86 } 87 } 88 return false; 89 } 90 91 public abstract StepPattern getKernelPattern(); 92 93 public abstract void reduceKernelPattern(); 94 95 public abstract boolean isWildcard(); 96 97 public int getAxis() { 98 final StepPattern sp = getKernelPattern(); 99 return (sp != null) ? sp.getAxis() : Axis.CHILD; 100 } 101 102 public String toString() { 103 return "root()"; 104 } 105 } 106 | Popular Tags |