Beispiel #1
0
        public override double evalNumber(VTDNav vn)
        {
            int ac = 0;

            switch (opCode)
            {
            case FuncName.LAST:  if (argCount() != 0)
                {
                    throw new System.ArgumentException("floor()'s argument count is invalid");
                }
                return(contextSize);

            case FuncName.POSITION:  if (argCount() != 0)
                {
                    throw new System.ArgumentException("position()'s argument count is invalid");
                }
                return(position);

            case FuncName.COUNT:  return(count(vn));

            case FuncName.NUMBER:  if (argCount() != 1)
                {
                    throw new System.ArgumentException("number()'s argument count is invalid");
                }
                return(argumentList.e.evalNumber(vn));


            case FuncName.SUM:  return(sum(vn));

            case FuncName.FLOOR:  if (argCount() != 1)
                {
                    throw new System.ArgumentException("floor()'s argument count is invalid");
                }
                return(System.Math.Floor(argumentList.e.evalNumber(vn)));


            case FuncName.CEILING:  if (argCount() != 1)
                {
                    throw new System.ArgumentException("ceiling()'s argument count is invalid");
                }
                return(System.Math.Ceiling(argumentList.e.evalNumber(vn)));


            case FuncName.STRING_LENGTH:
                ac = argCount();
                if (ac == 0)
                {
                    try
                    {
                        if (vn.atTerminal == true)
                        {
                            int type = vn.getTokenType(vn.LN);
                            if (type == VTDNav.TOKEN_ATTR_NAME || type == VTDNav.TOKEN_ATTR_NS)
                            {
                                return(vn.getStringLength(vn.LN + 1));
                            }
                            else
                            {
                                return(vn.getStringLength(vn.LN));
                            }
                        }
                        else
                        {
                            int i = vn.getText();
                            if (i == -1)
                            {
                                return(0);
                            }
                            else
                            {
                                return(vn.getStringLength(i));
                            }
                        }
                    }
                    catch (NavException e)
                    {
                        return(0);
                    }
                }
                else if (ac == 1)
                {
                    return(argumentList.e.evalString(vn).Length);
                }
                else
                {
                    throw new System.ArgumentException("string-length()'s argument count is invalid");
                }
            //goto case FuncName.ROUND;


            case FuncName.ROUND:  if (argCount() != 1)
                {
                    throw new System.ArgumentException("round()'s argument count is invalid");
                }
                //UPGRADE_TODO: Method 'java.lang.Math.round' was converted to 'System.Math.Round' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javalangMathround_double'"
                return((long)System.Math.Round(argumentList.e.evalNumber(vn)));


            default:  if (isBoolean_Renamed_Field)
                {
                    if (evalBoolean(vn))
                    {
                        return(1);
                    }
                    else
                    {
                        return(0);
                    }
                }
                else
                {
                    return(System.Double.Parse(evalString(vn)));
                }
                //break;
            }
        }