1 23 24 package com.sun.enterprise.util.diagnostics; 25 26 import java.io.*; 27 import java.util.*; 28 import com.sun.enterprise.util.StringUtils; 29 30 34 public class ReporterWriter implements IReporterEnum 35 { 36 40 protected ReporterWriter(String title) 41 { 42 this.title = title; 43 out = System.out; 44 } 45 46 48 55 protected void println(int severity, String s) 56 { 57 String type; 58 String msg; 59 60 68 { 69 type = severityNames[severity]; 70 msg = StringUtils.padRight(severityNames[severity], longestSeverityLength) + s; 71 } 72 73 out.println(msg); 74 getFrame().pr(msg); 75 } 76 77 79 private ReporterFrame getFrame() 80 { 81 if(frame == null) 82 { 83 frame = new ReporterFrame(title); 85 frame.show(); 86 calcLongestString(); 87 } 88 89 return frame; 90 } 91 92 94 private void calcLongestString() 95 { 96 int maxLen = 0; 97 98 for(int i = 0; i < severityNames.length; i++) 99 { 100 int len = severityNames[i].length(); 101 102 if(len > maxLen) 103 maxLen = len; 104 } 105 longestSeverityLength = maxLen + 2; 106 } 107 108 110 private PrintStream out; 111 private ReporterFrame frame = null; 112 private int longestSeverityLength; 113 private String title; 114 115 } 116 117 | Popular Tags |