Ejemplo n.º 1
0
  void accept(Environment env) throws TemplateException, IOException {
    boolean processedCase = false;
    Iterator iterator = nestedElements.iterator();
    try {
      while (iterator.hasNext()) {
        Case cas = (Case) iterator.next();
        boolean processCase = false;

        // Fall through if a previous case tested true.
        if (processedCase) {
          processCase = true;
        } else if (!cas.isDefault) {
          // Otherwise, if this case isn't the default, test it.
          ComparisonExpression equalsOp =
              new ComparisonExpression(testExpression, cas.expression, "==");
          processCase = equalsOp.isTrue(env);
        }
        if (processCase) {
          env.visit(cas);
          processedCase = true;
        }
      }

      // If we didn't process any nestedElements, and we have a default,
      // process it.
      if (!processedCase && defaultCase != null) {
        env.visit(defaultCase);
      }
    } catch (BreakInstruction.Break br) {
    }
  }