toNode() protected method

protected toNode ( int dir ) : bool
dir int
return bool
Ejemplo n.º 1
0
 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;
 }
Ejemplo n.º 2
0
        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;
        }
Ejemplo n.º 3
0
 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;
 }
Ejemplo n.º 4
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;
 }
Ejemplo n.º 5
0
        protected internal int process_parent2(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.toNode(VTDNav.P); // must return true
                    if ((currentStep.nt_eval || currentStep.nt.eval2(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;
        }
Ejemplo n.º 6
0
        protected internal int process_child2(VTDNav vn)
        {
            int result;
            bool b = false, b1 = false;
            Predicate t= null;

            switch(state){
            case START:
            // 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.toNode(VTDNav.FIRST_CHILD);
            state = END;
            if (b) {
                do {
                    if ((currentStep.nt_eval || currentStep.nt.eval2(vn))
                            && ((!currentStep.hasPredicate) || currentStep.evalPredicates(vn))) {
                        if (currentStep.nextS != null) {
                            // currentStep.position++;
                            state = FORWARD;
                            currentStep = currentStep.nextS;
                        } else {
                            state = TERMINAL;
                            result = vn.getCurrentIndex();
                            if (isUnique(result)) {
                                return result;
                            }
                        }
                        break;
                    }
                } while (vn.toNode(VTDNav.NS));
                if (state == END)
                    vn.toNode(VTDNav.PARENT);
            }
            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;
             if (vn.toNode(VTDNav.FC)) {
                do {
                    if ((currentStep.nt_eval || currentStep.nt.eval2(vn))
                            && ((!currentStep.hasPredicate) || currentStep.evalPredicates(vn))) {
                        if (currentStep.nextS != null) {
                            state = FORWARD;
                            currentStep = currentStep.nextS;
                        } else {
                            state = TERMINAL;
                            result = vn.getCurrentIndex();
                            if (isUnique(result))
                                return result;
                        }
                        goto forward;
                    }
                } while (vn.toNode(VTDNav.NS));

                vn.toNode(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.out_of_range){
                currentStep.out_of_range = false;
                transition_child(vn);
                break;
            }

            // currentStep = currentStep.prevS;
            //b = false;
            while (vn.toNode(VTDNav.NS)) {
                if ((currentStep.nt_eval || currentStep.nt.eval2(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;
            }
            while (vn.toNode(VTDNav.NS)) {
                if ((currentStep.nt_eval || currentStep.nt.eval2(vn))
                        && ((!currentStep.hasPredicate) || currentStep.evalPredicates(vn))) {
                    // state = TERMINAL;
                    result = vn.getCurrentIndex();
                    if (isUnique(result))
                        return result;
                }
            }
                    currentStep.out_of_range = false;
                    transition_child(vn);

            break;

            default:
            throw new XPathEvalException("unknown state");
            }
            return -2;
        }
Ejemplo n.º 7
0
        protected internal int process_ancestor_or_self2(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.eval2(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.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.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.eval2(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.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.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.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.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.toNode(VTDNav.P)) {
                    if ((currentStep.nt_eval || currentStep.nt.eval2(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;
        }