예제 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="vn"></param>
        /// <returns></returns>
        public override double evalNumber(VTDNav vn)
        {
            double d = Double.NaN;
            int    a = 0x7fffffff, k = -1;

            vn.push2();
            int size = vn.contextStack2.size;

            try
            {
                while ((k = evalNodeSet(vn)) != -1)
                {
                    //a = evalNodeSet(vn);
                    if (k < a)
                    {
                        a = k;
                    }
                }
                if (a == 0x7fffffff)
                {
                    a = -1;
                }
                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)
                    {
                        d = vn.XPathStringVal2Double(a);//Double.parseDouble(s);
                    }
                    else if (t == VTDNav.TOKEN_PI_NAME)
                    {
                        if (a + 1 < vn.vtdSize || vn.getTokenType(a + 1) == VTDNav.TOKEN_PI_VAL)
                        {
                            //s = vn.toString(a+1);
                            d = vn.parseDouble(a + 1);
                        }
                        else
                        {
                            d = Double.NaN;
                        }
                    }
                    else
                    {
                        d = vn.parseDouble(a);
                    }
                }
            }
            catch (Exception e)
            {
            }
            vn.contextStack2.size = size;
            reset(vn);
            vn.pop2();
            //return s;
            return(d);
        }
예제 #2
0
        private bool compareVNumber2(int k, VTDNav vn, double d, int op)
        {
            double d1;
            int    t = vn.getTokenType(k);

            if (t == VTDNav.TOKEN_STARTING_TAG || t == VTDNav.TOKEN_DOCUMENT)
            {
                d1 = vn.XPathStringVal2Double(k);
            }
            else
            {
                k  = getStringVal(vn, k);
                d1 = vn.parseDouble(k);
            }
            switch (op)
            {
            case EQ:
                return(d1 == d);

            case NE:
                return(d1 != d);

            case GE:
                return(d1 >= d);

            case LE:
                return(d1 <= d);

            case GT:
                return(d1 > d);

            default:
                return(d1 < d);
            }
        }