Esempio n. 1
0
 private boolean requiresExpression(int n) {
   if (n < 1) {
     return false;
   }
   final Object parent = stack.get(n - 1);
   if (parent instanceof Formula) {
     return ((Formula) parent).isMember();
   } else if (parent instanceof ResolvedFunCall) {
     final ResolvedFunCall funCall = (ResolvedFunCall) parent;
     if (funCall.getFunDef().getSyntax() == Syntax.Parentheses) {
       return requiresExpression(n - 1);
     } else {
       int k = whichArg(funCall, (Exp) stack.get(n));
       if (k < 0) {
         // Arguments of call have mutated since call was placed
         // on stack. Presumably the call has already been
         // resolved correctly, so the answer we give here is
         // irrelevant.
         return false;
       }
       final FunDef funDef = funCall.getFunDef();
       final int[] parameterTypes = funDef.getParameterCategories();
       return parameterTypes[k] != Category.Set;
     }
   } else if (parent instanceof UnresolvedFunCall) {
     final UnresolvedFunCall funCall = (UnresolvedFunCall) parent;
     if (funCall.getSyntax() == Syntax.Parentheses || funCall.getFunName().equals("*")) {
       return requiresExpression(n - 1);
     } else {
       int k = whichArg(funCall, (Exp) stack.get(n));
       if (k < 0) {
         // Arguments of call have mutated since call was placed
         // on stack. Presumably the call has already been
         // resolved correctly, so the answer we give here is
         // irrelevant.
         return false;
       }
       return requiresExpression(funCall, k);
     }
   } else {
     return false;
   }
 }
Esempio n. 2
0
 /**
  * Returns the scenario inside a calculated member in the scenario dimension. For example, applied
  * to [Scenario].[1], returns the Scenario object representing scenario #1.
  *
  * @param member Wrapper member
  * @return Wrapped scenario
  */
 static Scenario forMember(final RolapMember member) {
   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;
   }
 }