Esempio n. 1
0
        /*
         * (non-Javadoc)
         *
         * @see com.ximpleware.xpath.Expr#evalBoolean(com.ximpleware.VTDNav)
         */
        public override bool evalBoolean(VTDNav vn)
        {
            if (e.Boolean)
            {
                return(e.evalBoolean(vn));
            }
            if (e.NodeSet)
            {
                bool a = false;
                vn.push2();
                // record teh stack size
                int size = vn.contextStack2.size;
                try
                {
                    a = (evalNodeSet(vn) != -1);
                }
                catch (System.Exception ee)
                {
                }
                //rewind stack
                vn.contextStack2.size = size;
                reset(vn);
                vn.pop2();
                return(a);
            }
            if (e.Numerical)
            {
                double dval = e.evalNumber(vn);

                if (dval == 0.0 || System.Double.IsNaN(dval))
                {
                    return(false);
                }
                return(true);
            }

            String s = e.evalString(vn);

            if (s == null || s.Length == 0)
            {
                return(false);
            }
            return(true);
        }
Esempio n. 2
0
 public override double evalNumber(VTDNav vn)
 {
     // TODO Auto-generated method stub
     if (cached)
     {
         return(en);
     }
     else
     {
         cached = true;
         en     = e.evalNumber(vn);
         return(en);
     }
 }
Esempio n. 3
0
 /// <summary>
 ///  evalXPathToNumber() evaluates the xpath expression to a double
 /// </summary>
 /// <returns>return the result as a double</returns>
 public double evalXPathToNumber()
 {
     return(xpe.evalNumber(vn));
 }
Esempio n. 4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="vn"></param>
        /// <returns></returns>
        public override double evalNumber(VTDNav vn)
        {
            if (e.NodeSet == false)
            {
                return(e.evalNumber(vn));
            }
            //double d;
            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 = vn.parseDouble(a);
                    }
                }
            }
            catch (Exception ee)
            {
            }
            vn.contextStack2.size = size;
            reset(vn);
            vn.pop2();
            //return s;
            return(d);
        }