private void reportErrors(List<ErrorReport> errorLog, Controller controller) {
    String pattern = LocaleMgr.misc.getString("FailedOn0");
    for (ErrorReport report : errorLog) {
      String filename = report.m_file.toString();
      String msg = MessageFormat.format(pattern, filename);
      controller.println(msg);

      StringWriter sw = new StringWriter();
      PrintWriter pw = new PrintWriter(sw);
      report.m_th.printStackTrace(pw);
      String s = sw.toString();
      controller.println(s);
    } // end for

    pattern = LocaleMgr.misc.getString("FailedOn0Files");
    int nb = errorLog.size();
    String msg = MessageFormat.format(pattern, nb);
    controller.println(msg);

    for (ErrorReport report : errorLog) {
      String filename = report.m_file.toString();
      msg = MessageFormat.format(pattern, filename);
      controller.println(msg);
    } // end for
  } // end reportErrors()
Ejemplo n.º 2
0
  public boolean expandChild(
      Writer output,
      DbObject parent,
      DbObject child,
      int nbChildren,
      boolean state[], // for {prefixPrinted,
      // atLeastOneChildPrinted}
      RuleOptions options)
      throws DbException, IOException, RuleException {
    boolean expanded = false;
    boolean prefixPrinted = state[0];
    boolean atLeastOneChildPrinted = state[1];

    // If no 'WHEN MODIFIER' defined, or one defined that returns true
    // if ((m_whenClause == null) ||
    boolean condition = true;
    if (m_booleanModifier != null) {
      condition = m_booleanModifier.evaluate(child);
    } // end if

    if (condition) {
      // Make sure a child has been defined
      if (childRule == null) {
        String msg = NoChildRuleException.buildMessage(m_ruleName, m_childStrRule);
        throw new NoChildRuleException(msg);
      }

      // create a string buffer
      StringWriter sw = new StringWriter();

      // take CHILD rule, except if there is one element and ONECHILD rule
      // is defined
      Rule ruleToUse = childRule;
      if ((nbChildren == 1) && (oneChildRule != null)) {
        ruleToUse = oneChildRule;
      }

      // expand the child in the string buffer
      boolean childExpanded = ruleToUse.expand(sw, child, options);

      if (childExpanded) {
        // if there is a prefix to print
        if ((prefixModifier != null) && (!prefixPrinted)) {
          expanded |= prefixModifier.expand(output, parent, options);
          prefixPrinted = true;
        } else { // prefix already printed, or no prefix
          if (atLeastOneChildPrinted) {
            if (separatorModifier != null) {
              // expand the SEParator right before to print the
              // child
              expanded |= separatorModifier.expand(output, parent, options);
            } // end if
          } // end if
        } // end if

        // copy the string buffer into the output stream
        output.write(sw.toString());
      } // end if

      expanded |= childExpanded;
      if (childExpanded) {
        atLeastOneChildPrinted = true;
      }
    } // end if

    state[0] = prefixPrinted;
    state[1] = atLeastOneChildPrinted;
    return expanded;
  }