Examples of Calc


Examples of mondrian.calc.Calc

        super(dummyFunDef);
    }

    public Calc compileCall(ResolvedFunCall call, ExpCompiler compiler) {
        final ListCalc listCalc = compiler.compileList(call.getArg(0));
        final Calc calc =
            call.getArgCount() > 1
            ? compiler.compileScalar(call.getArg(1), true)
            : new ValueCalc(call);
        return new AggregateCalc(call, listCalc, calc);
    }
View Full Code Here

Examples of mondrian.calc.Calc

    }

    public Calc compileCall(ResolvedFunCall call, ExpCompiler compiler) {
        final Type targetType = call.getType();
        final Exp arg = call.getArg(0);
        final Calc calc = compiler.compileScalar(arg, false);
        return new CalcImpl(arg, calc, targetType);
    }
View Full Code Here

Examples of mondrian.calc.Calc

    public IsEmptyFunDef(FunDef dummyFunDef) {
        super(dummyFunDef);
    }

    public Calc compileCall(ResolvedFunCall call, ExpCompiler compiler) {
        final Calc calc = compiler.compileScalar(call.getArg(0), true);
        return new AbstractBooleanCalc(call, new Calc[] {calc}) {
            public boolean evaluateBoolean(Evaluator evaluator) {
                Object o = calc.evaluate(evaluator);
                return o == null;
            }
        };
    }
View Full Code Here

Examples of mondrian.calc.Calc

    }

    public Calc compileCall(ResolvedFunCall call, ExpCompiler compiler) {
        final Exp[] args = call.getArgs();
        final List<Calc> calcList = new ArrayList<Calc>();
        final Calc valueCalc =
                compiler.compileScalar(args[0], true);
        calcList.add(valueCalc);
        final int matchCount = (args.length - 1) / 2;
        final Calc[] matchCalcs = new Calc[matchCount];
        final Calc[] exprCalcs = new Calc[matchCount];
        for (int i = 0, j = 1; i < exprCalcs.length; i++) {
            matchCalcs[i] = compiler.compileScalar(args[j++], true);
            calcList.add(matchCalcs[i]);
            exprCalcs[i] = compiler.compile(args[j++]);
            calcList.add(exprCalcs[i]);
        }
        final Calc defaultCalc =
            args.length % 2 == 0
            ? compiler.compile(args[args.length - 1])
            : ConstantCalc.constantNull(call.getType());
        calcList.add(defaultCalc);
        final Calc[] calcs = calcList.toArray(new Calc[calcList.size()]);

        return new GenericCalc(call) {
            public Object evaluate(Evaluator evaluator) {
                Object value = valueCalc.evaluate(evaluator);
                for (int i = 0; i < matchCalcs.length; i++) {
                    Object match = matchCalcs[i].evaluate(evaluator);
                    if (match.equals(value)) {
                        return exprCalcs[i].evaluate(evaluator);
                    }
                }
                return defaultCalc.evaluate(evaluator);
            }

            public Calc[] getCalcs() {
                return calcs;
            }
View Full Code Here

Examples of mondrian.calc.Calc

                throw Util.unexpected(root.solveOrderMode);
            }
        }
        final int savepoint = savepoint();
        maxSolveMember.setContextIn(this);
        final Calc calc = maxSolveMember.getCompiledExpression(root);
        final Object o;
        try {
            o = calc.evaluate(this);
        } finally {
            restore(savepoint);
        }
        if (o == Util.nullValue) {
            return null;
View Full Code Here

Examples of mondrian.calc.Calc

        final Exp formatExp =
            (Exp) getProperty(Property.FORMAT_EXP_PARSED.name, null);
        if (formatExp == null) {
            return "Standard";
        }
        final Calc formatCalc = root.getCompiled(formatExp, true, null);
        final Object o = formatCalc.evaluate(this);
        if (o == null) {
            return "Standard";
        }
        return o.toString();
    }
View Full Code Here

Examples of mondrian.calc.Calc

        if (isScenario(member.getHierarchy())) {
            final Formula formula = ((RolapCalculatedMember) member)
                .getFormula();
            final ResolvedFunCall resolvedFunCall =
                (ResolvedFunCall) formula.getExpression();
            final Calc calc = resolvedFunCall.getFunDef()
                .compileCall(null, null);
            return ((ScenarioCalc) calc).getScenario();
        } else {
            return null;
        }
View Full Code Here

Examples of org.apache.tuscany.sca.binding.corba.testing.exceptions.Calc

            InvocationProxy proxy = new ComponentInvocationProxy((RuntimeEndpoint) service.getEndpoints().get(0), javaClass);
            DynaCorbaServant servant = new DynaCorbaServant(proxy, Utils.getTypeId(javaClass));
            String[] ids = {"IDL:org/apache/tuscany/sca/binding/corba/testing/exceptions/Calc:1.0"};
            servant.setIds(ids);
            bindServant(servant, "Calc");
            Calc calcClient = CalcHelper.narrow(bindReference("Calc"));
            calcClient.div(1, 0);
            fail();
        } catch (Exception e) {
            if (e instanceof DivByZero) {
                assertTrue(true);
            } else {
                e.printStackTrace();
                fail();
            }
        }

        try {
            CalcServant calc = new CalcServant();
            TestRuntimeComponentService service = new TestRuntimeComponentService(calc);
            Class<?> javaClass = ((JavaInterface)service.getInterfaceContract().getInterface()).getJavaClass();
            InvocationProxy proxy = new ComponentInvocationProxy((RuntimeEndpoint) service.getEndpoints().get(0), javaClass);
            DynaCorbaServant servant = new DynaCorbaServant(proxy, Utils.getTypeId(javaClass));
            String[] ids = {"IDL:org/apache/tuscany/sca/binding/corba/testing/exceptions/Calc:1.0"};
            servant.setIds(ids);
            bindServant(servant, "Calc");
            Calc calcClient = CalcHelper.narrow(bindReference("Calc"));
            calcClient.divForSmallArgs(255, 255);
            fail();
        } catch (Exception e) {
            if (e instanceof NotSupported) {
                assertTrue(true);
            } else {
View Full Code Here

Examples of org.apache.tuscany.sca.binding.corba.testing.exceptions.Calc

            InvocationProxy proxy = new ComponentInvocationProxy(service, service.getRuntimeWire(null), javaClass);
            DynaCorbaServant servant = new DynaCorbaServant(proxy, Utils.getTypeId(javaClass));
            String[] ids = {"IDL:org/apache/tuscany/sca/binding/corba/testing/exceptions/Calc:1.0"};
            servant.setIds(ids);
            bindServant(servant, "Calc");
            Calc calcClient = CalcHelper.narrow(bindReference("Calc"));
            calcClient.div(1, 0);
            fail();
        } catch (Exception e) {
            if (e instanceof DivByZero) {
                assertTrue(true);
            } else {
                e.printStackTrace();
                fail();
            }
        }

        try {
            CalcServant calc = new CalcServant();
            TestRuntimeComponentService service = new TestRuntimeComponentService(calc);
            Class<?> javaClass = ((JavaInterface)service.getInterfaceContract().getInterface()).getJavaClass();
            InvocationProxy proxy = new ComponentInvocationProxy(service, service.getRuntimeWire(null), javaClass);
            DynaCorbaServant servant = new DynaCorbaServant(proxy, Utils.getTypeId(javaClass));
            String[] ids = {"IDL:org/apache/tuscany/sca/binding/corba/testing/exceptions/Calc:1.0"};
            servant.setIds(ids);
            bindServant(servant, "Calc");
            Calc calcClient = CalcHelper.narrow(bindReference("Calc"));
            calcClient.divForSmallArgs(255, 255);
            fail();
        } catch (Exception e) {
            if (e instanceof NotSupported) {
                assertTrue(true);
            } else {
View Full Code Here

Examples of org.apache.tuscany.sca.binding.corba.testing.exceptions.Calc

            InvocationProxy proxy = new ComponentInvocationProxy((RuntimeEndpoint) service.getEndpoints().get(0), javaClass);
            DynaCorbaServant servant = new DynaCorbaServant(proxy, Utils.getTypeId(javaClass));
            String[] ids = {"IDL:org/apache/tuscany/sca/binding/corba/testing/exceptions/Calc:1.0"};
            servant.setIds(ids);
            bindServant(servant, "Calc");
            Calc calcClient = CalcHelper.narrow(bindReference("Calc"));
            calcClient.div(1, 0);
            fail();
        } catch (Exception e) {
            if (e instanceof DivByZero) {
                assertTrue(true);
            } else {
                e.printStackTrace();
                fail();
            }
        }

        try {
            CalcServant calc = new CalcServant();
            TestRuntimeComponentService service = new TestRuntimeComponentService(calc);
            Class<?> javaClass = ((JavaInterface)service.getInterfaceContract().getInterface()).getJavaClass();
            InvocationProxy proxy = new ComponentInvocationProxy((RuntimeEndpoint) service.getEndpoints().get(0), javaClass);
            DynaCorbaServant servant = new DynaCorbaServant(proxy, Utils.getTypeId(javaClass));
            String[] ids = {"IDL:org/apache/tuscany/sca/binding/corba/testing/exceptions/Calc:1.0"};
            servant.setIds(ids);
            bindServant(servant, "Calc");
            Calc calcClient = CalcHelper.narrow(bindReference("Calc"));
            calcClient.divForSmallArgs(255, 255);
            fail();
        } catch (Exception e) {
            if (e instanceof NotSupported) {
                assertTrue(true);
            } else {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.