Example #1
0
		private int process_DDFP(VTDNav vn)
		{
			AutoPilot ap;
			bool b = false, b1 = false;
			//int contextSize;
			Predicate t = null;
			int result;
			
			
			switch (state)
			{
				
				case START: 
				case FORWARD: 
					if (vn.atTerminal)
					{
						if (state == START)
							state = END;
						else
						{
							// no need to set_ft to true
							// no need to resetP
							state = BACKWARD;
							currentStep = currentStep.PrevStep;
						}
						break;
					}
					
					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 == START)
							state = END;
						else
						{
							currentStep = currentStep.PrevStep;
							state = BACKWARD;
						}
						break;
					}
					
					System.String helper = null;
					if (currentStep.nt.testType == NodeTest.NODE)
					{
						helper = "*";
					}
					else
					{
						helper = currentStep.nt.nodeName;
					}
					if (currentStep.o == null)
						currentStep.o = ap = new AutoPilot(vn);
					else
					{
						ap = (AutoPilot) currentStep.o;
						ap.bind(vn);
					}
					if (currentStep.get_ft() == true)
					{
						
						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)
							ap.selectElement(helper);
						else if (currentStep.axis_type == AxisType.DESCENDANT)
							ap.selectElement_D(helper);
						else if (currentStep.axis_type == AxisType.PRECEDING)
							ap.selectElement_P(helper);
						else
							ap.selectElement_F(helper);
						currentStep.set_ft(false);
					}
					if (state == START)
						state = END;
					
					vn.push2(); // not the most efficient. good for now
					//System.out.println("  --++ push in //");
					b = false;
					while (ap.iterate())
					{
						if (currentStep.evalPredicates(vn))
						{
							b = true;
							break;
						}
					}
					if (b == false)
					{
						vn.pop2();
						//System.out.println("  --++ pop in //");
						currentStep.set_ft(true);
						currentStep.resetP(vn);
						if (state == FORWARD)
						{
							state = BACKWARD;
							currentStep = currentStep.PrevStep;
						}
					}
					else
					{
						if (currentStep.NextStep != null)
						{
							state = FORWARD;
							currentStep = currentStep.NextStep;
						}
						else
						{
							//vn.pop();
							state = TERMINAL;
							result = vn.getCurrentIndex();
							if (isUnique(result))
								return result;
						}
					}
					break;
				
				
				case END: 
					currentStep = null;
					// reset();
					return - 1;
				
				
				case BACKWARD: 
					//currentStep = currentStep.getPrevStep();
					ap = (AutoPilot) currentStep.o;
					//vn.push();
					b = false;
					while (ap.iterate())
					{
						if (currentStep.evalPredicates(vn))
						{
							b = true;
							break;
						}
					}
					if (b == false)
					{
						vn.pop2();
						currentStep.set_ft(true);
						currentStep.resetP(vn);
						//System.out.println("  --++ pop in //");
						if (currentStep.PrevStep != null)
						{
							state = BACKWARD;
							currentStep = currentStep.PrevStep;
						}
						else
							state = END;
					}
					else
					{
						if (currentStep.NextStep != null)
						{
							//vn.push();
							//System.out.println("  --++ push in //");
							state = FORWARD;
							currentStep = currentStep.NextStep;
						}
						else
						{
							state = TERMINAL;
							result = vn.getCurrentIndex();
							if (isUnique(result))
								return result;
						}
					}
					break;
				
				
				case TERMINAL: 
					ap = (AutoPilot) currentStep.o;
					b = false;
					while (ap.iterate())
					{
						if (currentStep.evalPredicates(vn))
						{
							b = true;
							break;
						}
					}
					if (b == true)
					{
						if (currentStep.evalPredicates(vn))
						{
							result = vn.getCurrentIndex();
							if (isUnique(result))
								return result;
						}
					}
					else if (currentStep.PrevStep == null)
					{
						currentStep.resetP(vn);
						vn.pop2();
						state = END;
					}
					else
					{
						vn.pop2();
						currentStep.set_ft(true);
						currentStep.resetP(vn);
						//System.out.println(" --++ pop in //");
						state = BACKWARD;
						//currentStep.ft = true;
						currentStep = currentStep.PrevStep;
					}
					break;
				
				
				default: 
					throw new XPathEvalException("unknown state");
				
			}
			return - 2;
		}
Example #2
0
        private int process_namespace(VTDNav vn)
        {
            AutoPilot ap = null;
            bool b1 = false;
            Predicate t = null;
            int temp;
            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.atTerminal)
                    {
                        if (state == START)
                            state = END;
                        else
                        {
                            state = BACKWARD;
                            currentStep = currentStep.prevS;
                        }
                    }
                    else
                    {

                        if (currentStep.ft)
                        {
                            if (currentStep.o == null)
                                currentStep.o = ap = new AutoPilot(vn);
                            else
                            {
                                ap = (AutoPilot)currentStep.o;
                                ap.bind(vn);
                                //ap.set_ft(true);
                            }
                            if (currentStep.nt.testType == NodeTest.NODE)
                                ap.selectNameSpace("*");
                            else
                                ap.selectNameSpace(currentStep.nt.nodeName);
                            currentStep.ft = false;
                        }
                        if (state == START)
                            state = END;
                        vn.push2();
                        //vn.setAtTerminal(true);
                        while ((temp = ap.iterateNameSpace()) != -1)
                        {
                            if ((!currentStep.hasPredicate) || currentStep.evalPredicates(vn))
                            {
                                break;
                            }
                        }
                        if (temp == -1)
                        {
                            vn.pop2();
                            currentStep.ft = true;
                            if (currentStep.hasPredicate)
                                currentStep.resetP(vn);
                            vn.atTerminal=(false);
                            if (state == FORWARD)
                            {
                                state = BACKWARD;
                                currentStep = currentStep.prevS;
                            }
                        }
                        else
                        {
                            vn.atTerminal=(true);
                            if (currentStep.nextS != null)
                            {
                                vn.LN = temp;
                                state = FORWARD;
                                currentStep = currentStep.nextS;
                            }
                            else
                            {
                                //vn.pop();
                                state = TERMINAL;
                                if (isUnique(temp))
                                {
                                    vn.LN = temp;
                                    return temp;
                                }
                            }

                        }
                    }
                    break;

                case END:
                    currentStep = null;
                    // reset();
                    return -1;

                case BACKWARD:
                    ap = (AutoPilot)currentStep.o;
                    //vn.push();
                    while ((temp = ap.iterateNameSpace()) != -1)
                    {
                        if ((!currentStep.hasPredicate) || currentStep.evalPredicates(vn))
                        {
                            break;
                        }
                    }
                    if (temp == -1)
                    {
                        vn.pop2();
                        currentStep.ft = true;
                        if (currentStep.hasPredicate)
                            currentStep.resetP(vn);
                        vn.atTerminal=(false);
                        if (currentStep.prevS != null)
                        {
                            state = BACKWARD;
                            currentStep = currentStep.prevS;
                        }
                        else
                            state = END;
                    }
                    else
                    {
                        if (currentStep.nextS != null)
                        {
                            state = FORWARD;
                            currentStep = currentStep.nextS;
                        }
                        else
                        {
                            state = TERMINAL;
                            if (isUnique(temp))
                            {
                                vn.LN = temp;
                                return temp;
                            }
                        }
                    }
                    break;

                case TERMINAL:
                    ap = (AutoPilot)currentStep.o;
                    while ((temp = ap.iterateNameSpace()) != -1)
                    {
                        if (!currentStep.hasPredicate || currentStep.evalPredicates(vn))
                        {
                            break;
                        }
                    }
                    if (temp != -1)
                        if (isUnique(temp))
                        {
                            vn.LN = temp;
                            return temp;
                        }
                    vn.atTerminal=(false);
                    if (currentStep.hasPredicate)
                        currentStep.resetP(vn);
                    if (currentStep.prevS == null)
                    {
                        currentStep.ft = true;
                        vn.pop2();
                        state = END;
                    }
                    else
                    {
                        state = BACKWARD;
                        vn.pop2();
                        currentStep.ft = true;
                        currentStep = currentStep.prevS;
                    }

                    break;

                default:
                    throw new XPathEvalException("unknown state");
            }
            return -2;
        }
Example #3
0
		private int process_attribute(VTDNav vn)
		{
			AutoPilot ap = null;
			bool  b1 = false;
			//int contextSize;
			Predicate t = null;
			//int result;
			int temp;
			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 (vn.AtTerminal == true)
					{
						if (state == START)
							state = END;
						else
						{
							state = BACKWARD;
							currentStep = currentStep.PrevStep;
						}
					}
					else
					{
						if (currentStep.get_ft() == true)
						{
							if (currentStep.o == null)
								currentStep.o = ap = new AutoPilot(vn);
							else
							{
								ap = (AutoPilot) currentStep.o;
								ap.bind(vn);
								//ap.set_ft(true);	
							}
							if (currentStep.nt.localName != null)
								ap.selectAttrNS(currentStep.nt.URL, currentStep.nt.localName);
							else
								ap.selectAttr(currentStep.nt.nodeName);
							currentStep.set_ft(false);
						}
						if (state == START)
							state = END;
						vn.AtTerminal = true;
						while ((temp = ap.iterateAttr()) != - 1)
						{
							if (currentStep.evalPredicates(vn))
							{
								break;
							}
						}
						if (temp == - 1)
						{
							currentStep.set_ft(true);
							currentStep.resetP(vn);
							vn.AtTerminal = false;
							if (state == FORWARD)
							{
								state = BACKWARD;
								currentStep = currentStep.PrevStep;
							}
						}
						else
						{
							
							if (currentStep.NextStep != null)
							{
								vn.LN = temp;
								state = FORWARD;
								currentStep = currentStep.NextStep;
							}
							else
							{
								//vn.pop();
								state = TERMINAL;
								if (isUnique(temp))
								{
									vn.LN = temp;
									return temp;
								}
							}
						}
					}
					break;
				
				
				case END: 
					currentStep = null;
					// reset();
					return - 1;
				
				
				case BACKWARD: 
					ap = (AutoPilot) currentStep.o;
					//vn.push();
					while ((temp = ap.iterateAttr()) != - 1)
					{
						if (currentStep.evalPredicates(vn))
						{
							break;
						}
					}
					if (temp == - 1)
					{
						currentStep.set_ft(true);
						currentStep.resetP(vn);
						vn.AtTerminal = false;
						if (currentStep.PrevStep != null)
						{
							state = BACKWARD;
							currentStep = currentStep.PrevStep;
						}
						else
							state = END;
					}
					else
					{
						if (currentStep.NextStep != null)
						{
							state = FORWARD;
							currentStep = currentStep.NextStep;
						}
						else
						{
							state = TERMINAL;
							if (isUnique(temp))
							{
								vn.LN = temp;
								return temp;
							}
						}
					}
					break;
				
				
				case TERMINAL: 
					ap = (AutoPilot) currentStep.o;
					while ((temp = ap.iterateAttr()) != - 1)
					{
						if (currentStep.evalPredicates(vn))
						{
							break;
						}
					}
					if (temp != - 1)
						if (isUnique(temp))
						{
							vn.LN = temp;
							return temp;
						}
					vn.AtTerminal = false;
					currentStep.resetP(vn);
					if (currentStep.PrevStep == null)
					{
						currentStep.set_ft(true);
						state = END;
					}
					else
					{
						state = BACKWARD;
						currentStep.set_ft(true);
						currentStep = currentStep.PrevStep;
					}
					
					break;
				
				
				default: 
					throw new XPathEvalException("unknown state");
				
			}
			return - 2;
		}