/// <summary> /// /// </summary> /// <param name="vn"></param> /// <returns></returns> public override bool evalBoolean(VTDNav vn) { bool a = false; vn.push2(); // record teh stack size int size = vn.contextStack2.size; try { a = (evalNodeSet(vn) != -1); } catch (System.Exception ee) { } //rewind stack vn.contextStack2.size = size; reset(vn); vn.pop2(); return a; //} /*if (e.Numerical) { double dval = e.evalNumber(vn); if (dval == 0.0 || System.Double.IsNaN(dval)) return false; return true; } String s = e.evalString(vn); if (s == null || s.Length == 0) return false; return true;*/ }
/// <summary> /// attach a VTDNav instance to NodeRecorder /// </summary> /// <param name="vn1"></param> public void bind(VTDNav vn1) { if (vn1 == null) throw new System.ArgumentException( "NodeRecorder can't take a null VTDNav instatnce"); vn = vn1; }
protected internal ElementFragmentNs(VTDNav vn1, long l1, FastIntBuffer fib1, int len) { vn = vn1; l = l1; fib = fib1; stLen = len; }
public CachedExpr(Expr e1) { e = e1; cached = false; ens = null; count = 0; vn1 = null; }
/// <summary> bind a BookMark object to a VTDNav object /// the cursor position is set to an invalid state /// </summary> /// <param name="vn">* /// </param> public void bind(VTDNav vn) { if (vn == null) throw new System.ArgumentException("vn can't be null"); vn1 = vn; if (ba == null || vn.nestingLevel + 8 != ba.Length) ba = new int[vn.nestingLevel + 8]; ba[0] = -2; // this would never happen in a VTDNav obj's context }
public void reset(VTDNav vn) { Alist temp = this; while (temp != null) { temp.e.reset(vn); temp = temp.next; } }
/// <summary> TextIter constructor comment.</summary> public TextIter() : base() { vn = null; vn = null; sel_type = 0; piName = null; /*sel_char_data = true; sel_comment = true; sel_cdata = true;*/ }
public override bool evalBoolean(VTDNav vn) { // TODO Auto-generated method stub if (cached) { return eb; } else { eb = e.evalBoolean(vn); return eb; } }
public bool eval(VTDNav vn) { if (vn.atTerminal) return false; switch (type) { case 0: return true; case 1: return vn.matchElement(nodeName); case 2: return vn.matchElementNS(URL, localName); } //} return false; }
public override double evalNumber(VTDNav vn) { // TODO Auto-generated method stub if (cached) { return en; } else { cached = true; en = e.evalNumber(vn); return en; } }
public bool eval(VTDNav vn) { if (testType == NODE) return true; else if (testType == NAMETEST) { if (vn.atTerminal == true) return false; if (localName != null) return vn.matchElementNS(URL, localName); else return vn.matchElement(nodeName); } return false; }
public bool eval(VTDNav vn) { bool b; count++; // increment the position expr.Position = count; if (expr.Numerical) { b = (expr.evalNumber(vn) == count); } else { b = expr.evalBoolean(vn); } return b; }
public override int evalNodeSet(VTDNav vn) { // TODO Auto-generated method stub int i = -1; if (cached) { if (count < ens.size_Renamed_Field) { i = ens.intAt(count); vn.recoverNode(i); count++; return i; } else return -1; } else { cached = true; if (ens == null) { ens = new FastIntBuffer(8);//page size 64 } //record node set while ((i = e.evalNodeSet(vn)) != -1) { ens.append(i); } e.reset(vn); if (ens.size_Renamed_Field > 0) { i = ens.intAt(count);//count should be zero vn.recoverNode(i); count++; return i; } else return -1; } }
public bool eval(VTDNav vn) { count++; switch (type) { case simple: if (d < count) return false; else if (d == count) { if (s != null) { s.out_of_range = true; } else fe.out_of_range = true; return true; } return false; default: bool b; expr.Position = count; if (expr.Numerical) { b = (expr.evalNumber(vn) == count); } else { b = expr.evalBoolean(vn); } if (b) return true; else return false; } }
protected internal int computeContextSize4PrecedingSibling2(Predicate p, VTDNav vn) { int i=0; vn.push2(); while(vn.toNode(VTDNav.PREV_SIBLING)){ if (currentStep.eval2(vn,p)){ i++; } } vn.pop2(); currentStep.resetP(vn,p); currentStep.out_of_range=false; //currentStep.o = ap; return i; }
protected internal int computeContextSize4Parent(Predicate p, VTDNav vn) { int i=0; AutoPilot ap = (AutoPilot)currentStep.o; vn.push2(); i = 0; if (vn.toElement(VTDNav.PARENT)){ if (currentStep.eval(vn,p)){ i++; } } vn.pop2(); currentStep.resetP(vn,p); currentStep.out_of_range=false; currentStep.o = ap; return i; }
protected internal int computeContextSize4FollowingSibling(Predicate p, VTDNav vn) { int i=0; //AutoPilot ap = (AutoPilot)currentStep.o; vn.push2(); while(vn.toElement(VTDNav.NEXT_SIBLING)){ if (currentStep.eval(vn,p)){ i++; } } vn.pop2(); currentStep.resetP(vn,p); currentStep.out_of_range=false; //currentStep.o = ap; return i; }
protected internal int computeContextSize4DDFP2(Predicate p, VTDNav vn) { int i=0; AutoPilot ap = (AutoPilot)currentStep.o; if (ap==null) ap = new AutoPilot(vn); else ap.bind(vn); //currentStep.o = ap = new AutoPilot(vn); if (currentStep.axis_type == AxisType.DESCENDANT_OR_SELF) ap.selectNode(); else if (currentStep.axis_type == AxisType.DESCENDANT) ap.selectDescendantNode(); else if (currentStep.axis_type == AxisType.PRECEDING) ap.selectPrecedingNode(); else ap.selectFollowingNode(); vn.push2(); while(ap.iterate2()){ if (currentStep.eval2(vn,p)){ i++; } } vn.pop2(); currentStep.resetP(vn,p); currentStep.out_of_range=false; currentStep.o = ap; return i; }
protected internal int computeContextSize4DDFP(Predicate p, VTDNav vn) { String helper = null; int i=0; AutoPilot ap = (AutoPilot)currentStep.o; if (currentStep.nt.testType == NodeTest.NODE){ helper = "*"; }else if (currentStep.nt.testType == NodeTest.NAMETEST){ helper = currentStep.nt.nodeName; }else throw new XPathEvalException("can't run descendant " + "following, or following-sibling axis over comment(), pi(), and text()"); if (ap==null) ap = new AutoPilot(vn); else ap.bind(vn); if (currentStep.axis_type == AxisType.DESCENDANT_OR_SELF0 ) if (currentStep.nt.testType == NodeTest.NODE || helper.Equals("*")) ap.Special=true; else ap.Special=true; //currentStep.o = ap = new AutoPilot(vn); if (currentStep.axis_type == AxisType.DESCENDANT_OR_SELF0) if (currentStep.nt.localName!=null) ap.selectElementNS(currentStep.nt.URL,currentStep.nt.localName); else ap.selectElement(helper); else if (currentStep.axis_type == AxisType.DESCENDANT0) if (currentStep.nt.localName!=null) ap.selectElementNS_D(currentStep.nt.URL,currentStep.nt.localName); else ap.selectElement_D(helper); else if (currentStep.axis_type == AxisType.PRECEDING0) if (currentStep.nt.localName!=null) ap.selectElementNS_P(currentStep.nt.URL,currentStep.nt.localName); else ap.selectElement_P(helper); else if (currentStep.nt.localName!=null) ap.selectElementNS_F(currentStep.nt.URL,currentStep.nt.localName); else ap.selectElement_F(helper); vn.push2(); while(ap.iterate()){ if (currentStep.evalPredicates(vn,p)){ i++; } } vn.pop2(); currentStep.resetP(vn,p); currentStep.out_of_range=false; currentStep.o = ap; return i; }
protected internal int computeContextSize4Child2(Predicate p, VTDNav vn) { int i=0; bool b = vn.toNode(VTDNav.FIRST_CHILD); if (b) { do { if (currentStep.eval2(vn, p)) { i++; } } while (vn.toNode(VTDNav.NS)); vn.toNode(VTDNav.PARENT); currentStep.resetP(vn,p); currentStep.out_of_range=false; return i; } else return 0; }
protected internal int computeContextSize4AncestorOrSelf2(Predicate p, VTDNav vn) { int i=0; AutoPilot ap = (AutoPilot)currentStep.o; vn.push2(); i = 0; do { if (currentStep.eval2(vn, p)) { i++; } }while(vn.toNode(VTDNav.PARENT)); vn.pop2(); currentStep.resetP(vn,p); currentStep.out_of_range=false; currentStep.o = ap; return i; }
public override void reset(VTDNav vn) { state = START; Step temp = s; ih.reset(); currentStep = null; while (temp != null) { temp.reset(vn); temp = temp.nextS; } }
public override System.String evalString(VTDNav vn) { String s = ""; int a = -1; vn.push2(); int size = vn.contextStack2.size; try { a = evalNodeSet(vn); if (a != -1) { int t = vn.getTokenType(a); switch (t) { case VTDNav.TOKEN_STARTING_TAG: case VTDNav.TOKEN_DOCUMENT: s = vn.getXPathStringVal2(a,(short)0); break; case VTDNav.TOKEN_ATTR_NAME: s = vn.toString(a + 1); break; case VTDNav.TOKEN_PI_NAME: //if (a + 1 < vn.vtdSize // || vn.getTokenType(a + 1) == VTDNav.TOKEN_PI_VAL) s = vn.toString(a + 1); break; default: s = vn.toString(a); break; } } } catch (Exception e) { } vn.contextStack2.size = size; reset(vn); vn.pop2(); return s; }
public override double evalNumber(VTDNav vn) { double d = Double.NaN; int a = -1; vn.push2(); int size = vn.contextStack2.size; try { a = evalNodeSet(vn); if (a != -1) { int t = vn.getTokenType(a); if (t == VTDNav.TOKEN_ATTR_NAME) { d = vn.parseDouble(a + 1); } else if (t == VTDNav.TOKEN_STARTING_TAG || t == VTDNav.TOKEN_DOCUMENT) { String s = vn.getXPathStringVal(); d = Double.Parse(s); } else if (t == VTDNav.TOKEN_PI_NAME) { if (a + 1 < vn.vtdSize || vn.getTokenType(a + 1) == VTDNav.TOKEN_PI_VAL) d = vn.parseDouble(a + 1); } else d = vn.parseDouble(a); } } catch (Exception e) { } vn.contextStack2.size = size; reset(vn); vn.pop2(); //return s; return d; }
/// <summary> Obtain the current navigation position and element info from VTDNav. /// So one can instantiate it once and use it for many different elements /// Creation date: (12/5/03 6:20:44 PM) /// </summary> /// <param name="vn">com.ximpleware.VTDNav /// </param> public void touch(VTDNav v) { if (v == null) throw new System.ArgumentException(" VTDNav instance can't be null"); depth = v.context[0]; if (depth == -1) index = 0; else index = (depth != 0) ? v.context[depth] : v.rootIndex; vn = v; prevLocation = -1; lcIndex = -1; lcUpper = -1; lcLower = -1; }
protected internal int computeContextSize4Self2(Predicate p, VTDNav vn) { int i = 0; AutoPilot ap = (AutoPilot)currentStep.o; //if (vn.toNode(VTDNav.PARENT)){ if (currentStep.eval2(vn,p)){ i++; } //} currentStep.resetP(vn,p); currentStep.out_of_range=false; currentStep.o = ap; return i; }
protected internal int process_ancestor2( VTDNav vn) { int result; bool b = false, b1 = false; //int contextSize; Predicate t= null; switch(state){ case START: t = currentStep.p; while (t != null) { if (t.requireContext) { int i = computeContextSize( t, vn); if (i == 0) { b1 = true; break; } else t.ContextSize=(i); } t = t.nextP; } if (b1) { state = END; break; } state = END; //if (vn.getCurrentDepth() != -1) { vn.push2(); while (vn.toNode(VTDNav.P)) { if ((currentStep.nt_eval || currentStep.nt.eval2(vn)) && ((!currentStep.hasPredicate) || currentStep.evalPredicates(vn))) { if (currentStep.nextS != null) { state = FORWARD; currentStep = currentStep.nextS; break; } else { //vn.pop(); state = TERMINAL; result = vn.getCurrentIndex2(); if (isUnique(result)) return result; } } } if (state == END) { if (currentStep.hasPredicate) currentStep.resetP(vn); vn.pop2(); } // } break; case END: currentStep =null; // reset(); return -1; case FORWARD: t = currentStep.p; while(t!=null){ if (t.requireContext){ int i = computeContextSize(t,vn); if (i==0){ b1 = true; break; }else t.ContextSize=(i); } t = t.nextP; } if (b1){ currentStep = currentStep.prevS; state = BACKWARD; break; } state = BACKWARD; vn.push2(); while(vn.toNode(VTDNav.P)){ if ((currentStep.nt_eval || currentStep.nt.eval2(vn)) && ((!currentStep.hasPredicate) || currentStep.evalPredicates(vn))){ if (currentStep.nextS != null){ state = FORWARD; currentStep = currentStep.nextS; break; } else { //vn.pop(); state = TERMINAL; result = vn.getCurrentIndex2(); if ( isUnique(result)) return result; } } } if ( state == BACKWARD){ if (currentStep.hasPredicate) currentStep.resetP(vn); vn.pop2(); currentStep=currentStep.prevS; } break; case BACKWARD: b = false; //vn.push2(); if (currentStep.out_of_range) { currentStep.out_of_range = false; transition_ancestor(vn); break; } while (vn.toNode(VTDNav.P)) { if ((currentStep.nt_eval || currentStep.nt.eval2(vn)) && ((!currentStep.hasPredicate) || currentStep.evalPredicates(vn))) { if (currentStep.nextS!= null) { state = FORWARD; currentStep = currentStep.nextS; b = true; break; } else { //vn.pop(); state = TERMINAL; result = vn.getCurrentIndex2(); if ( isUnique(result)) return result; } } } if (b==false){ currentStep.out_of_range = false; transition_ancestor(vn); } break; case TERMINAL: if (currentStep.out_of_range) { currentStep.out_of_range = false; transition_ancestor(vn); break; } while (vn.toNode(VTDNav.P)) { if ((currentStep.nt_eval || currentStep.nt.eval2(vn)) && ((!currentStep.hasPredicate) || currentStep.evalPredicates(vn))) { result = vn.getCurrentIndex2(); if ( isUnique(result)) return result; } } currentStep.out_of_range = false; transition_ancestor(vn); break; default: throw new XPathEvalException("unknown state"); } return -2; }
private void transition_ancestor_or_self(VTDNav vn) { //currentStep.out_of_range = false; vn.pop2(); if (currentStep.prevS != null) { if (currentStep.hasPredicate) currentStep.resetP(vn); state = BACKWARD; currentStep = currentStep.prevS; } else { state = END; } }
public bool eval2(VTDNav vn) { switch (testType) { case NAMETEST: if (vn.atTerminal) return false; switch (type) { case 0: return true; case 1: return vn.matchElement(nodeName); case 2: return vn.matchElementNS(URL, localName); } return false; case NODE: return true; case TEXT: if (!vn.atTerminal) return false; int t = vn.getTokenType(vn.LN); if (t == VTDNav.TOKEN_CHARACTER_DATA || t == VTDNav.TOKEN_CDATA_VAL) { return true; } return false; case PI0: if (!vn.atTerminal) return false; if (vn.getTokenType(vn.LN) == VTDNav.TOKEN_PI_NAME) { return true; } return false; case PI1: if (!vn.atTerminal) return false; if (vn.getTokenType(vn.LN) == VTDNav.TOKEN_PI_NAME) { return vn.matchTokenString(vn.LN, nodeName); } return false; default: // comment if (!vn.atTerminal) return false; if (vn.getTokenType(vn.LN) == VTDNav.TOKEN_COMMENT) { return true; } return false; } }
private void transition_preceding_sibling(VTDNav vn) { vn.pop2(); if (currentStep.hasPredicate) currentStep.resetP(vn); if(currentStep.prevS!=null){ currentStep = currentStep.prevS; state = BACKWARD; }else{ state = END; } }