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