1 package com.icl.saxon.pattern; 2 import com.icl.saxon.Context; 3 import com.icl.saxon.expr.StaticContext; 4 import com.icl.saxon.expr.ExpressionParser; 5 import com.icl.saxon.om.NodeInfo; 6 import com.icl.saxon.expr.XPathException; 7 8 9 14 15 public abstract class Pattern { 16 17 protected StaticContext staticContext; 18 protected String originalText; 19 20 26 27 public static Pattern make(String pattern, StaticContext env) throws XPathException { 28 29 Pattern pat = (new ExpressionParser()).parsePattern(pattern, env).simplify(); 30 pat.staticContext = env; 32 33 pat.setOriginalText(pattern); 35 return pat; 36 } 37 38 41 42 public void setOriginalText(String text) { 43 originalText = text; 44 } 45 46 51 52 public Pattern simplify() throws XPathException { 53 return this; 54 } 55 56 59 60 public final void setStaticContext(StaticContext sc) { 61 staticContext = sc; 62 } 63 64 67 68 public StaticContext getStaticContext() { 69 return staticContext; 70 } 71 72 79 80 public abstract boolean matches(NodeInfo node, Context context) throws XPathException; 81 82 87 88 public short getNodeType() { 89 return NodeInfo.NODE; 90 } 91 92 98 99 public int getFingerprint() { 100 return -1; 101 } 102 103 107 108 public double getDefaultPriority() { 109 return 0.5; 110 } 111 112 115 116 public String getSystemId() { 117 return staticContext.getSystemId(); 118 } 119 120 123 124 public int getLineNumber() { 125 return staticContext.getLineNumber(); 126 } 127 128 131 132 public String toString() { 133 return originalText; 134 } 135 136 } 137 138 | Popular Tags |