1 package com.icl.saxon.pattern; 2 import com.icl.saxon.Context; 3 import com.icl.saxon.om.*; 4 import com.icl.saxon.expr.XPathException; 5 6 9 10 public class UnionPattern extends Pattern { 11 12 protected Pattern p1, p2; 13 private short nodeType = NodeInfo.NODE; 14 15 20 21 public UnionPattern(Pattern p1, Pattern p2) { 22 this.p1 = p1; 23 this.p2 = p2; 24 if (p1.getNodeType()==p2.getNodeType()) nodeType = p1.getNodeType(); 25 } 26 27 30 31 public Pattern simplify() throws XPathException { 32 return new UnionPattern(p1.simplify(), p2.simplify()); 33 } 34 35 38 39 public void setOriginalText(String pattern) { 40 this.originalText = pattern; 41 p1.setOriginalText(pattern); 42 p2.setOriginalText(pattern); 43 } 44 45 50 51 public boolean matches(NodeInfo e, Context c) throws XPathException { 52 return p1.matches(e, c) || p2.matches(e, c); 53 } 54 55 60 61 public short getNodeType() { 62 return nodeType; 63 } 64 65 68 69 public Pattern getLHS() { 70 return p1; 71 } 72 73 76 77 public Pattern getRHS() { 78 return p2; 79 } 80 81 } 82 83 | Popular Tags |