public toElement ( int direction ) : bool | ||
direction | int | int /// |
return | bool |
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 computeContextSize4PrecedingSibling(Predicate p, VTDNav vn) { int i=0; vn.push2(); while(vn.toElement(VTDNav.PREV_SIBLING)){ if (currentStep.eval(vn,p)){ i++; } } vn.pop2(); currentStep.resetP(vn,p); currentStep.out_of_range=false; //currentStep.o = ap; return i; }
private int process_preceding_sibling(VTDNav vn) { bool b = false, b1 = false; Predicate t = null; int result; switch (state) { case START: 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) { if (state == FORWARD) { state = BACKWARD; currentStep = currentStep.prevS; } else state = END; break; } if (state == START) state = END; else state = BACKWARD; vn.push2(); while (vn.toElement(VTDNav.PS)) { if ((currentStep.nt_eval || currentStep.nt.eval(vn)) && ((!currentStep.hasPredicate) || currentStep.evalPredicates(vn))) { if (currentStep.nextS != null) { state = FORWARD; currentStep = currentStep.nextS; break; } else { state = TERMINAL; result = vn.getCurrentIndex2(); if (isUnique(result)) return result; } } } if(state == END) { if (currentStep.hasPredicate) currentStep.resetP(vn); vn.pop2(); }else if (state == BACKWARD) { if (currentStep.hasPredicate) currentStep.resetP(vn); vn.pop2(); currentStep = currentStep.prevS; } break; case END: currentStep = null; // reset(); return -1; case BACKWARD: if (currentStep.out_of_range) { currentStep.out_of_range = false; transition_preceding_sibling(vn); break; } while (vn.toElement(VTDNav.PS)) { if ((currentStep.nt_eval || currentStep.nt.eval(vn)) && ((!currentStep.hasPredicate) || currentStep.evalPredicates(vn))) { if (currentStep.nextS != null) { state = FORWARD; currentStep = currentStep.nextS; b = true; break; } else { state = TERMINAL; result = vn.getCurrentIndex2(); if (isUnique(result)) return result; } } } if (b == false) { currentStep.out_of_range = false; transition_preceding_sibling(vn); } break; case TERMINAL: if (currentStep.out_of_range) { currentStep.out_of_range = false; transition_preceding_sibling(vn); break; } while (vn.toElement(VTDNav.PS)) { if ((currentStep.nt_eval || currentStep.nt.eval(vn)) && ((!currentStep.hasPredicate) || currentStep.evalPredicates(vn))) { // state = TERMINAL; result = vn.getCurrentIndex2(); if (isUnique(result)) return result; } } currentStep.out_of_range = false; transition_preceding_sibling(vn); break; default: throw new XPathEvalException("unknown state"); } return -2; }
protected internal int computeContextSize4Child(Predicate p, VTDNav vn) { int i=0; bool b = vn.toElement(VTDNav.FIRST_CHILD); if (b) { do { if (currentStep.eval(vn, p)) { i++; } } while (vn.toElement(VTDNav.NS)); vn.toElement(VTDNav.PARENT); currentStep.resetP(vn,p); currentStep.out_of_range=false; return i; } else return 0; }
public override int evalNodeSet(VTDNav vn) { int result; if (currentStep == null) { if (pathType == ABSOLUTE_PATH) { vn.toElement(VTDNav.ROOT); vn.toElement(VTDNav.PARENT); } currentStep = s; if (currentStep == null) { if (state == START) { state = END; return 0; } else { return -1; } } } while (true) { switch (currentStep.axis_type) { case AxisType.CHILD0: if ((result = process_child(vn)) != -2) { return result; } break; case AxisType.CHILD: if ((result = process_child2(vn)) != -2) { return result; } break; case AxisType.DESCENDANT_OR_SELF0: case AxisType.DESCENDANT0: case AxisType.PRECEDING0: case AxisType.FOLLOWING0: if ((result = process_DDFP(vn)) != -2) return result; break; case AxisType.DESCENDANT_OR_SELF: case AxisType.DESCENDANT: case AxisType.PRECEDING: case AxisType.FOLLOWING: if ((result = process_DDFP2(vn)) != -2) return result; break; case AxisType.PARENT: if ((result = process_parent(vn)) != -2) return result; break; case AxisType.ANCESTOR: if ((result = process_ancestor2(vn)) != -2) return result; break; case AxisType.ANCESTOR_OR_SELF: if ((result = process_ancestor_or_self2(vn)) != -2) return result; break; case AxisType.SELF: if ((result = process_self2(vn)) != -2) return result; break; case AxisType.FOLLOWING_SIBLING: if ((result = process_following_sibling2(vn)) != -2) return result; break; case AxisType.FOLLOWING_SIBLING0: if ((result = process_following_sibling(vn)) != -2) return result; break; case AxisType.PRECEDING_SIBLING: if ((result = process_preceding_sibling2(vn)) != -2) return result; break; case AxisType.PRECEDING_SIBLING0: if ((result = process_preceding_sibling(vn)) != -2) return result; break; case AxisType.ATTRIBUTE: if ((result = process_attribute(vn)) != -2) return result; break; default: if ((result = process_namespace(vn)) != -2) return result; break; } } }
private int process_parent(VTDNav vn) { bool b1 = false; Predicate t = null; int result; switch (state) { case START: 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) { if (state == FORWARD) { state = BACKWARD; currentStep = currentStep.prevS; } else state = END; break; } if (vn.getCurrentDepth() == -1) { if (state == START) state = END; else { //vn.pop(); state = BACKWARD; currentStep = currentStep.prevS; } } else { vn.push2(); vn.toElement(VTDNav.P); // must return true if ((currentStep.nt_eval || currentStep.nt.eval(vn)) && ((!currentStep.hasPredicate) || currentStep.evalPredicates(vn))) { if (currentStep.nextS != null) { state = FORWARD; currentStep = currentStep.nextS; } else { state = TERMINAL; result = vn.getCurrentIndex2(); if (isUnique(result)) return result; } } else { vn.pop2(); if (currentStep.hasPredicate) currentStep.resetP(vn); if (state == START) state = END; else { state = BACKWARD; currentStep = currentStep.prevS; } } } break; case END: currentStep = null; // reset(); return -1; case BACKWARD: case TERMINAL: if (currentStep.prevS == null) { vn.pop2(); state = END; break; } else { vn.pop2(); state = BACKWARD; currentStep = currentStep.prevS; break; } default: throw new XPathEvalException("unknown state"); } return -2; }
protected internal void transition_child(VTDNav vn) { vn.toElement(VTDNav.P); if (currentStep.prevS != null){ currentStep = currentStep.prevS; state = BACKWARD; }else{ state = END; } }
private int process_child(VTDNav vn) { int result; bool b = false, b1 = false; int k=1; Predicate t= null; // Console.WriteLine(" index-============= " + vn.getCurrentIndex()); // Console.WriteLine(" depth ==============" + vn.getCurrentDepth()); switch(state){ case START: //if (currentStep.nt.testType < NodeTest.TEXT){ // first search for any predicate that // requires contextSize // if so, compute its context size // if size > 0 // set context // if size ==0 // immediately set the state to backward or end 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; } b=vn.toElement(VTDNav.FIRST_CHILD); state = END; if (b ){ do { if ((currentStep.nt_eval || currentStep.nt.eval(vn)) && ((!currentStep.hasPredicate) || currentStep.evalPredicates(vn))) { if (currentStep.nextS != null){ //currentStep.position++; state = FORWARD; currentStep = currentStep.nextS; } else { state = TERMINAL; result = vn.getCurrentIndex2(); if ( isUnique(result)){ return result; } } break; } } while (vn.toElement(VTDNav.NS)); if (state == END) vn.toElement(VTDNav.PARENT); } break; case END: currentStep =null; // reset(); return -1; case FORWARD: //if (currentStep.nt.testType < NodeTest.TEXT){ 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; if (vn.toElement(VTDNav.FC)) { do { if ((currentStep.nt_eval || currentStep.nt.eval(vn)) && ((!currentStep.hasPredicate) || currentStep.evalPredicates(vn))) { if (currentStep.nextS != null) { state = FORWARD; currentStep = currentStep.nextS; } else { state = TERMINAL; result = vn.getCurrentIndex2(); if ( isUnique(result)) return result; } goto forward; } } while (vn.toElement(VTDNav.NS)); vn.toElement(VTDNav.P); if (currentStep.hasPredicate) currentStep.resetP(vn); currentStep = currentStep.prevS; } else { //vn.toElement(VTDNav.P); currentStep = currentStep.prevS; } forward: break; case BACKWARD: //if (currentStep.nt.testType < NodeTest.TEXT) { //currentStep = currentStep.prevS; //b = false; if(currentStep.out_of_range){ currentStep.out_of_range = false; transition_child(vn); break; } while (vn.toElement(VTDNav.NS)) { if ((currentStep.nt_eval || currentStep.nt.eval(vn)) && ((!currentStep.hasPredicate) || currentStep.evalPredicates(vn))) { b = true; break; } } if (b ) { state = FORWARD; currentStep = currentStep.nextS; } else { currentStep.out_of_range = false; transition_child(vn); } break; case TERMINAL: if(currentStep.out_of_range){ currentStep.out_of_range = false; transition_child(vn); break; } //if (currentStep.nt.testType < NodeTest.TEXT) { while (vn.toElement(VTDNav.NS)) { if ((currentStep.nt_eval || currentStep.nt.eval(vn)) && ((!currentStep.hasPredicate) || currentStep.evalPredicates(vn))) { // state = TERMINAL; result = vn.getCurrentIndex2(); if ( isUnique(result)) return result; } } currentStep.out_of_range = false; transition_child(vn); break; default: throw new XPathEvalException("unknown state"); } return -2; }
/// <summary> /// /// </summary> /// <param name="vn"></param> /// <param name="s"></param> /// <returns></returns> private bool lang(VTDNav vn, String s) { // check the length of s bool b = false; vn.push2(); try { while (vn.getCurrentDepth() >= 0) { int i = vn.getAttrVal("xml:lang"); if (i != -1) { b = vn.matchTokenString(i, s); break; } vn.toElement(VTDNav.P); } } catch (NavException e) { } vn.pop2(); return b; }
private int process_child(VTDNav vn) { int result; bool b = false, b1 = false; //int contextSize; Predicate t = null; switch (state) { case START: if (currentStep.nt.testType != NodeTest.TEXT) { // first search for any predicate that // requires contextSize // if so, compute its context size // if size > 0 // set context // if size ==0 // immediately set the state to backward or end t = currentStep.p; while (t != null) { if (t.requireContextSize()) { int i = computeContextSize(t, vn); if (i == 0) { b1 = true; break; } else t.ContextSize = i; } t = t.nextP; } if (b1) { state = END; break; } b = vn.toElement(VTDNav.FIRST_CHILD); state = END; if (b == true) { do { if (currentStep.eval(vn)) { if (currentStep.NextStep != null) { //currentStep.position++; state = FORWARD; currentStep = currentStep.NextStep; } else { state = TERMINAL; result = vn.getCurrentIndex(); if (isUnique(result)) { return result; } } break; } } while (vn.toElement(VTDNav.NS)); if (state == END) vn.toElement(VTDNav.PARENT); } } else { if (vn.AtTerminal == true) { state = END; } else { // compute context size; t = currentStep.p; while (t != null) { if (t.requireContextSize()) { int i = computeContextSize(t, vn); if (i == 0) { b1 = true; break; } else t.ContextSize=i; } t = t.nextP; } // b1 false indicate context size is zero. no need to go any further... if (b1) { state = END; break; } // get textIter TextIter ti = null; if (currentStep.o != null) { ti = (TextIter)currentStep.o; } else { ti = new TextIter(); currentStep.o = ti; } ti.touch(vn); state = END; while ((result = ti.getNext()) != -1) { if (currentStep.evalPredicates(vn)) { break; } } // old code //result = vn.getText(); if (result != -1) { vn.AtTerminal=true; //currentStep.resetP(vn); vn.LN = result; if (currentStep.NextStep != null) { vn.LN = result; state = FORWARD; currentStep = currentStep.NextStep; } else { //vn.pop(); state = TERMINAL; if (isUnique(result)) { vn.LN = result; return result; } } } else { //currentStep.set_ft(true); currentStep.resetP(vn); vn.AtTerminal=false; } } } break; case END: currentStep = null; // reset(); return - 1; case FORWARD: if (currentStep.nt.testType != NodeTest.TEXT) { t = currentStep.p; while (t != null) { if (t.requireContextSize()) { int i = computeContextSize(t, vn); if (i == 0) { b1 = true; break; } else t.ContextSize = i; } t = t.nextP; } if (b1) { currentStep = currentStep.PrevStep; state = BACKWARD; break; } state = BACKWARD; if (vn.toElement(VTDNav.FC)) { do { if (currentStep.eval(vn)) { if (currentStep.NextStep != null) { state = FORWARD; currentStep = currentStep.NextStep; } else { state = TERMINAL; result = vn.getCurrentIndex(); if (isUnique(result)) return result; } //UPGRADE_NOTE: Labeled break statement was changed to a goto statement. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1012'" goto forward_brk; } } while (vn.toElement(VTDNav.NS)); vn.toElement(VTDNav.P); currentStep.resetP(vn); currentStep = currentStep.PrevStep; } else { //vn.toElement(VTDNav.P); currentStep = currentStep.PrevStep; } //UPGRADE_NOTE: Label 'forward_brk' was added. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1011'" forward_brk: ; } else { // predicate at an attribute is not evaled if (vn.AtTerminal == true) { state = BACKWARD; currentStep = currentStep.PrevStep; } else { // compute context size; t = currentStep.p; while (t != null) { if (t.requireContextSize()) { int i = computeContextSize(t, vn); if (i == 0) { b1 = true; break; } else t.ContextSize=i; } t = t.nextP; } // b1 false indicate context size is zero. no need to go any further... if (b1) { state = BACKWARD; break; } // get textIter TextIter ti = null; if (currentStep.o != null) { ti = (TextIter)currentStep.o; } else { ti = new TextIter(); currentStep.o = ti; } ti.touch(vn); //result = ti.getNext(); while ((result = ti.getNext()) != -1) { if (currentStep.evalPredicates(vn)) { break; } } if (result == -1) { //currentStep.set_ft(true); //currentStep.resetP(vn); vn.AtTerminal=false; if (state == FORWARD) { state = BACKWARD; currentStep = currentStep.PrevStep; } } else { vn.AtTerminal=true; if (currentStep.NextStep != null) { vn.LN = result; state = FORWARD; currentStep = currentStep.NextStep; } else { //vn.pop(); state = TERMINAL; if (isUnique(result)) { vn.LN = result; return result; } } } } } break; case BACKWARD: if (currentStep.nt.testType != NodeTest.TEXT) { //currentStep = currentStep.getPrevStep(); b = false; while (vn.toElement(VTDNav.NS)) { if (currentStep.eval(vn)) { b = true; break; } } if (b == true) { state = FORWARD; currentStep = currentStep.NextStep; } else if (currentStep.PrevStep == null) { currentStep.resetP(vn); vn.toElement(VTDNav.P); state = END; } else { currentStep.resetP(vn); state = BACKWARD; vn.toElement(VTDNav.P); currentStep = currentStep.PrevStep; } } else { vn.AtTerminal = false; if (currentStep.PrevStep == null) state = END; else { state = BACKWARD; //vn.setAtTerminal(false); currentStep = currentStep.PrevStep; } } break; case TERMINAL: if (currentStep.nt.testType != NodeTest.TEXT) { while (vn.toElement(VTDNav.NS)) { if (currentStep.eval(vn)) { // state = TERMINAL; result = vn.getCurrentIndex(); if (isUnique(result)) return result; } } currentStep.resetP(vn); if (currentStep.PrevStep == null) { state = END; vn.toElement(VTDNav.P); } else { vn.toElement(VTDNav.P); state = BACKWARD; currentStep = currentStep.PrevStep; } } else { TextIter ti = (TextIter)currentStep.o; while ((result = ti.getNext()) != -1) { if (currentStep.evalPredicates(vn)) { if (isUnique(result)) return result; } } currentStep.resetP(vn); vn.AtTerminal=false; if (currentStep.PrevStep == null) state = END; else { state = BACKWARD; currentStep = currentStep.PrevStep; } } break; default: throw new XPathEvalException("unknown state"); } return - 2; }
public int computeContextSize(Predicate p, VTDNav vn){ bool b = false; Predicate tp = null; int i = 0; AutoPilot ap; switch(currentStep.axis_type){ case AxisType.CHILD: if (currentStep.nt.testType != NodeTest.TEXT){ b = vn.toElement(VTDNav.FIRST_CHILD); if (b) { do { if (currentStep.eval(vn, p)) { i++; } } while (vn.toElement(VTDNav.NS)); vn.toElement(VTDNav.PARENT); currentStep.resetP(vn,p); return i; } else return 0; }else { TextIter ti = new TextIter(); ti.touch(vn); while((ti.getNext())!=-1){ if (currentStep.evalPredicates(vn,p)){ i++; } } currentStep.resetP(vn,p); return i; } case AxisType.DESCENDANT_OR_SELF: case AxisType.DESCENDANT: case AxisType.PRECEDING: case AxisType.FOLLOWING: String helper = null; if (currentStep.nt.testType == NodeTest.NODE){ helper = "*"; }else { helper = currentStep.nt.nodeName; } ap = new AutoPilot(vn); if (currentStep.axis_type == AxisType.DESCENDANT_OR_SELF ) if (currentStep.nt.testType == NodeTest.NODE) ap.Special = true; else ap.Special = false; //currentStep.o = ap = new AutoPilot(vn); if (currentStep.axis_type == AxisType.DESCENDANT_OR_SELF) if (currentStep.nt.localName!=null) ap.selectElementNS(currentStep.nt.URL,currentStep.nt.localName); else ap.selectElement(helper); else if (currentStep.axis_type == AxisType.DESCENDANT) 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.PRECEDING) 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); return i; case AxisType.PARENT: vn.push2(); i = 0; if (vn.toElement(VTDNav.PARENT)){ if (currentStep.eval(vn,p)){ i++; } } vn.pop2(); currentStep.resetP(vn,p); return i; case AxisType.ANCESTOR: vn.push2(); i = 0; while (vn.toElement(VTDNav.PARENT)) { if (currentStep.eval(vn, p)) { i++; } } vn.pop2(); currentStep.resetP(vn,p); return i; case AxisType.ANCESTOR_OR_SELF: vn.push2(); i = 0; do { if (currentStep.eval(vn, p)) { i++; } }while(vn.toElement(VTDNav.PARENT)); vn.pop2(); currentStep.resetP(vn,p); return i; case AxisType.SELF: i = 0; if (vn.toElement(VTDNav.PARENT)){ if (currentStep.eval(vn,p)){ i++; } } currentStep.resetP(vn,p); return i; case AxisType.FOLLOWING_SIBLING: vn.push2(); while(vn.toElement(VTDNav.NEXT_SIBLING)){ if (currentStep.eval(vn,p)){ i++; } } vn.pop2(); currentStep.resetP(vn,p); return i; case AxisType.PRECEDING_SIBLING: vn.push2(); while(vn.toElement(VTDNav.PREV_SIBLING)){ if (currentStep.eval(vn,p)){ i++; } } vn.pop2(); currentStep.resetP(vn,p); return i; case AxisType.ATTRIBUTE: ap = new AutoPilot(vn); if (currentStep.nt.localName!=null) ap.selectAttrNS(currentStep.nt.URL, currentStep.nt.localName); else ap.selectAttr(currentStep.nt.nodeName); i = 0; while(ap.iterateAttr()!=-1){ if (currentStep.evalPredicates(vn,p)){ i++; } } currentStep.resetP(vn,p); return i; default: throw new XPathEvalException("axis not supported"); } //return 8; }
private int process_preceding_sibling(VTDNav vn) { bool b = false, b1 = false; //int contextSize; Predicate t = null; int result; switch (state) { case START: case FORWARD: t = currentStep.p; while (t != null) { if (t.requireContextSize()) { int i = computeContextSize(t, vn); if (i == 0) { b1 = true; break; } else t.ContextSize = i; } t = t.nextP; } if (b1) { if (state == FORWARD) { state = BACKWARD; currentStep = currentStep.PrevStep; } else state = END; break; } if (state == START) state = END; else state = BACKWARD; vn.push2(); while (vn.toElement(VTDNav.PS)) { if (currentStep.eval(vn)) { if (currentStep.NextStep != null) { state = FORWARD; currentStep = currentStep.NextStep; break; } else { state = TERMINAL; result = vn.getCurrentIndex(); if (isUnique(result)) return result; } } } if (state == END) { currentStep.resetP(vn); vn.pop2(); } else if (state == BACKWARD) { currentStep.resetP(vn); vn.pop2(); currentStep = currentStep.PrevStep; } break; case END: currentStep = null; // reset(); return - 1; case BACKWARD: while (vn.toElement(VTDNav.PS)) { if (currentStep.eval(vn)) { if (currentStep.NextStep != null) { state = FORWARD; currentStep = currentStep.NextStep; b = true; break; } else { state = TERMINAL; result = vn.getCurrentIndex(); if (isUnique(result)) return result; } } } if (b == false) { vn.pop2(); currentStep.resetP(vn); if (currentStep.PrevStep == null) { state = END; } else { state = BACKWARD; currentStep = currentStep.PrevStep; } } break; case TERMINAL: while (vn.toElement(VTDNav.PS)) { if (currentStep.eval(vn)) { // state = TERMINAL; result = vn.getCurrentIndex(); if (isUnique(result)) return result; } } vn.pop2(); if (currentStep.PrevStep != null) { currentStep = currentStep.PrevStep; state = BACKWARD; } else { state = END; } break; default: throw new XPathEvalException("unknown state"); } return - 2; }
private int process_ancestor_or_self(VTDNav vn) { bool b = false, b1 = false; Predicate t = null; int result; 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; vn.push2(); if (currentStep.ft) { currentStep.ft = false; if ((currentStep.nt_eval || currentStep.nt.eval(vn)) && ((!currentStep.hasPredicate) || currentStep.evalPredicates(vn))) { if (currentStep.nextS != null) { state = FORWARD; currentStep = currentStep.nextS; break; } else { //vn.pop(); state = TERMINAL; if (vn.atTerminal) result = vn.LN; else result = vn.getCurrentIndex(); if (isUnique(result)) return result; } } } while (vn.toElement(VTDNav.P)) { if ((currentStep.nt_eval || currentStep.nt.eval(vn)) && ((!currentStep.hasPredicate) || currentStep.evalPredicates(vn))) { if (currentStep.nextS != null) { state = FORWARD; currentStep = currentStep.nextS; break; } else { //vn.pop(); state = TERMINAL; result = vn.getCurrentIndex(); if (isUnique(result)) return result; } } } if (state == END) { if (currentStep.hasPredicate) currentStep.resetP(vn); vn.pop2(); } break; 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(); if (currentStep.ft) { currentStep.ft = false; if ((currentStep.nt_eval || currentStep.nt.eval(vn)) && ((!currentStep.hasPredicate) || currentStep.evalPredicates(vn))) { if (currentStep.nextS != null) { state = FORWARD; currentStep = currentStep.nextS; break; } else { //vn.pop(); state = TERMINAL; if (vn.atTerminal) result = vn.LN; else result = vn.getCurrentIndex(); if (isUnique(result)) return result; } } } while (vn.toElement(VTDNav.P)) { if ((currentStep.nt_eval || currentStep.nt.eval(vn)) && ((!currentStep.hasPredicate) || currentStep.evalPredicates(vn))) { if (currentStep.nextS != null) { state = FORWARD; currentStep = currentStep.nextS; break; } else { //vn.pop(); state = TERMINAL; result = vn.getCurrentIndex(); if (isUnique(result)) return result; } } } if (state == BACKWARD) { if (currentStep.hasPredicate) currentStep.resetP(vn); currentStep.ft = true; vn.pop2(); currentStep = currentStep.prevS; } break; case END: currentStep = null; // reset(); return -1; case BACKWARD: //b = false; vn.push2(); while (vn.toElement(VTDNav.P)) { if ((currentStep.nt_eval || currentStep.nt.eval(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.getCurrentIndex(); if (isUnique(result)) return result; } } } if (b == false) { vn.pop2(); if (currentStep.hasPredicate) currentStep.resetP(vn); if (currentStep.prevS != null) { currentStep.ft = true; state = BACKWARD; currentStep = currentStep.prevS; } else { state = END; } } break; case TERMINAL: while (vn.toElement(VTDNav.P)) { if ((currentStep.nt_eval || currentStep.nt.eval(vn)) && ((!currentStep.hasPredicate) || currentStep.evalPredicates(vn))) { result = vn.getCurrentIndex(); if (isUnique(result)) return result; } } vn.pop2(); if (currentStep.hasPredicate) currentStep.resetP(vn); if (currentStep.prevS != null) { currentStep.ft = true; state = BACKWARD; currentStep = currentStep.prevS; } else { state = END; } break; default: throw new XPathEvalException("unknown state"); } return -2; }