コード例 #1
0
ファイル: Reporter.java プロジェクト: and146/SPLAT
 /**
  * Writes to the output stream a summary of messages which were suppressed in a given stage
  * because the maximum repeat count was exceeded.
  *
  * @param scode section code to summarise
  */
 public void summariseUnreportedMessages(String scode) {
   String dscode = "-" + scode + "-";
   int lds = dscode.length();
   for (Iterator<String> it = codeMap_.keySet().iterator(); it.hasNext(); ) {
     String ecode = it.next();
     if (dscode.equals(ecode.substring(1, 1 + lds))) {
       int count = codeMap_.getCount(ecode);
       if (count > maxRepeat_) {
         println(ecode + "-" + countXx_ + " (" + (count - maxRepeat_) + " more)");
       }
       it.remove();
     }
   }
 }
コード例 #2
0
ファイル: Reporter.java プロジェクト: and146/SPLAT
 /**
  * Provides a summary of any message types which were not reported.
  *
  * @param code message code for this summary
  * @param types array of types to report on, or null for all types
  */
 public void summariseUnreportedTypes(String code, ReportType[] types) {
   if (types == null) {
     types = typeMap_.keySet().toArray(new ReportType[0]);
   }
   StringBuffer sbuf = new StringBuffer();
   for (int it = 0; it < types.length; it++) {
     ReportType type = types[it];
     if (it > 0) {
       sbuf.append(", ");
     }
     sbuf.append(type.toString()).append(": ").append(typeMap_.getCount(type));
   }
   report(ReportType.SUMMARY, code, sbuf.toString());
 }
コード例 #3
0
ファイル: Reporter.java プロジェクト: and146/SPLAT
 /**
  * Reports a message with an associated throwable.
  *
  * @param type message type
  * @param code short, fixed-length message code which ought to identify which messages are
  *     essentially the same as each other (though may refer to different data etc); preferably
  *     {@link #MCODE_LENGTH}-characters long
  * @param message free-text message; it may be multi-line and/or longish, but may in practice be
  *     truncated on output
  * @param err throwable
  */
 public void report(ReportType type, String code, String message, Throwable err) {
   if (!typeList_.contains(type)) {
     return;
   }
   if (message == null || message.trim().length() == 0) {
     message = "?";
   }
   if (code == null || code.length() == 0) {
     code = createCode(message);
   }
   if (code.length() > MCODE_LENGTH) {
     code = code.substring(0, MCODE_LENGTH);
   }
   if (code.length() < MCODE_LENGTH) {
     code += repeatChar('X', MCODE_LENGTH - code.length());
   }
   assert code.length() == MCODE_LENGTH;
   StringBuffer codeBuf = new StringBuffer();
   codeBuf.append(type.getChar()).append('-');
   if (scode_ != null) {
     codeBuf.append(scode_).append('-');
   }
   codeBuf.append(code);
   String ecode = codeBuf.toString();
   typeMap_.addItem(type);
   int count = codeMap_.addItem(ecode);
   if (count <= maxRepeat_) {
     String fcount = countFormat_.format(count);
     StringBuffer mbuf = new StringBuffer(message.trim());
     if (err != null) {
       mbuf.append(" [").append(stringifyError(err, false)).append("]");
     }
     String[] lines = mbuf.toString().split("[\\n\\r]+");
     for (int il = 0; il < lines.length; il++) {
       String line = lines[il];
       if (line.trim().length() > 0) {
         StringBuffer sbuf = new StringBuffer();
         sbuf.append(ecode)
             .append(il == 0 ? '-' : '+')
             .append(fcount)
             .append(' ')
             .append(lines[il]);
         println(sbuf.toString());
       }
     }
   }
   if (debug_ && err != null) {
     err.printStackTrace(out_);
   }
 }
コード例 #4
0
ファイル: Reporter.java プロジェクト: and146/SPLAT
 /** Prints the total number of each report type reported by this object. */
 public void reportTotals() {
   StringBuffer sbuf = new StringBuffer();
   sbuf.append("Totals: ");
   ReportType[] types = typeList_.toArray(new ReportType[0]);
   Arrays.sort(types);
   for (int i = 0; i < types.length; i++) {
     ReportType type = types[i];
     if (i > 0) {
       sbuf.append("; ");
     }
     sbuf.append(type.getNames()).append(": ").append(typeMap_.getCount(type));
   }
   println(sbuf.toString());
 }
コード例 #5
0
ファイル: Reporter.java プロジェクト: and146/SPLAT
 /** Clears any memory of which messages have been reported. */
 public void clear() {
   codeMap_.clear();
 }