Example #1
0
        private bool compNodeSetString(Expr left, Expr right, VTDNav vn, int op)
        {
            int    i, i1 = 0, stackSize;
            String s;

            try
            {
                s = right.evalString(vn);
                vn.push2();
                stackSize = vn.contextStack2.size;
                while ((i = left.evalNodeSet(vn)) != -1)
                {
                    int t = vn.getTokenType(i);
                    if (t != VTDNav.TOKEN_STARTING_TAG &&
                        t != VTDNav.TOKEN_DOCUMENT)
                    {
                        i1 = getStringVal(vn, i);
                        // if (i1==-1 && s.length()==0)
                        //return true;
                        if (i1 != -1)
                        {
                            bool b = compareVString1(i1, vn, s, op);
                            if (b)
                            {
                                left.reset(vn);
                                vn.contextStack2.size = stackSize;
                                vn.pop2();
                                return(b);
                            }
                        }
                    }
                    else
                    {
                        bool b = vn.XPathStringVal_Matches(i, s);
                        if (b)
                        {
                            left.reset(vn);
                            vn.contextStack2.size = stackSize;
                            vn.pop2();
                            return(b);
                        }
                    }
                }
                vn.contextStack2.size = stackSize;
                vn.pop2();
                left.reset(vn);
                return(false); // compareEmptyNodeSet(op, s);
            }
            catch (Exception e)
            {
                throw new System.SystemException("Undefined behavior");
            }
        }
Example #2
0
    private bool compStringNodeSet(Expr left, Expr right, VTDNav vn, int op)
    {
        int i, i1 = 0, stackSize;
        String s;
        try
        {
            s = left.evalString(vn);
            vn.push2();
            stackSize = vn.contextStack2.size;
            while ((i = right.evalNodeSet(vn)) != -1)
            {
                    int t = vn.getTokenType(i);
                    if (t != VTDNav.TOKEN_STARTING_TAG
                            && t != VTDNav.TOKEN_DOCUMENT)
                    {

                        i1 = getStringVal(vn, i);
                        if (i1 != -1)
                        {
                            bool b = compareVString2(i1, vn, s, op);
                            if (b)
                            {
                                right.reset(vn);
                                vn.contextStack2.size = stackSize;
                                vn.pop2();
                                return b;
                            }
                        }
                    }
                    else
                    {
                        bool b = vn.XPathStringVal_Matches(i, s);
                        if (b)
                        {
                            right.reset(vn);
                            vn.contextStack2.size = stackSize;
                            vn.pop2();
                            return b;
                        }
                    }
                }
            vn.contextStack2.size = stackSize;
            vn.pop2();
            right.reset(vn);
            return false;// compareEmptyNodeSet(op, s);
        }
        catch (Exception e)
        {
            throw new System.SystemException("Undefined behavior");
        }
    }
Example #3
0
        /// <summary>
        /// compute the binary expr whose operand is either = or !=
        /// </summary>
        /// <param name="op"></param>
        /// <param name="vn"></param>
        /// <returns></returns>
        ///
        ///
        private bool computeComp(int op, VTDNav vn)
        {
            //int i, t, i1 = 0, stackSize, s1, s2;
            String st1, st2;

            switch (compType)
            {
            case NS_NS: return(compNodeSetNodeSet(left, right, vn, op));

            case NS_N: return(compNodeSetNumerical(left, right, vn, op));

            case NS_S: return(compNodeSetString(left, right, vn, op));

            //case NS_B:
            case N_NS: return(compNumericalNodeSet(left, right, vn, op));

            //case N_N:   break;
            //case N_S:   break;
            //case N_B:
            case S_NS: return(compStringNodeSet(left, right, vn, op));
                //case S_N:
                //case S_S:
                //case S_B:
                //case B_NS:
                //case B_N:
                //case B_S:
                //default:break;
            }
            if (op == EQ || op == NE)
            {
                if (left.Boolean || right.Boolean)
                {
                    if (op == EQ)
                    {
                        return(left.evalBoolean(vn) == right.evalBoolean(vn));
                    }
                    else
                    {
                        return(left.evalBoolean(vn) != right.evalBoolean(vn));
                    }
                }

                if (left.Numerical || right.Numerical)
                {
                    if (op == EQ)
                    {
                        return(left.evalNumber(vn) == right.evalNumber(vn));
                    }
                    else
                    {
                        return(left.evalNumber(vn) != right.evalNumber(vn));
                    }
                }

                st1 = left.evalString(vn);
                st2 = right.evalString(vn);

                /*if (st1 == null || st2 == null)
                 *  if (op == EQ)
                 *      return false;
                 *  else
                 *      return true;*/

                return((op == EQ) ? (st1.Equals(st2)) : (!st1.Equals(st2)));
            }
            return(compNumbers(left.evalNumber(vn), right.evalNumber(vn), op));
        }
Example #4
0
 private bool compStringNodeSet(Expr left, Expr right, VTDNav vn, int op)
 {
     int i, i1 = 0, stackSize;
     String s;
     try
     {
     s = left.evalString(vn);
     vn.push2();
     stackSize = vn.contextStack2.size;
     while ((i = right.evalNodeSet(vn)) != -1)
     {
         i1 = getStringVal(vn, i);
         if (i1 != -1)
         {
             bool b = compareVString2(i1, vn, s, op);
             if (b)
             {
                 right.reset(vn);
                 vn.contextStack2.size = stackSize;
                 vn.pop2();
                 return b;
             }
         }
     }
     vn.contextStack2.size = stackSize;
     vn.pop2();
     right.reset(vn);
     return false;// compareEmptyNodeSet(op, s);
     }
     catch (Exception e)
     {
     throw new System.SystemException("Undefined behavior");
     }
 }