1 26 27 package org.objectweb.util.cmdline.lib; 28 29 import org.objectweb.util.cmdline.api.Console; 31 import java.io.PrintStream ; 32 33 57 58 public class DefaultConsole 59 implements Console 60 { 61 67 68 private PrintStream outputStream_; 69 70 71 private PrintStream errorStream_; 72 73 74 private String messageHeader_; 75 76 77 private boolean silentMessage_; 78 79 85 86 public 87 DefaultConsole() 88 { 89 this("", false); 90 } 91 92 97 public 98 DefaultConsole(String header) 99 { 100 this(header, false); 101 } 102 103 110 public 111 DefaultConsole(String header, 112 boolean silent) 113 { 114 this(System.out, System.err, header, silent); 115 } 116 117 125 public 126 DefaultConsole(PrintStream output, 127 PrintStream error, 128 String header, 129 boolean silent) 130 { 131 outputStream_ = output; 133 errorStream_ = error; 134 messageHeader_ = header; 135 silentMessage_ = silent; 136 } 137 138 144 150 155 public PrintStream 156 getOutputStream() 157 { 158 return outputStream_; 159 } 160 161 166 public void 167 setOutputStream(PrintStream output) 168 { 169 outputStream_ = output; 170 } 171 172 177 public PrintStream 178 getErrorStream() 179 { 180 return errorStream_; 181 } 182 183 188 public void 189 setErrorStream(PrintStream error) 190 { 191 errorStream_ = error; 192 } 193 194 199 public String 200 getMessageHeader() 201 { 202 return messageHeader_; 203 } 204 205 210 public void 211 setMessageHeader(String header) 212 { 213 messageHeader_ = header; 214 } 215 216 221 public boolean 222 getSilentMessage() 223 { 224 return silentMessage_; 225 } 226 227 232 public void 233 setSilentMessage(boolean flag) 234 { 235 silentMessage_ = flag; 236 } 237 238 243 public void 244 message(String text) 245 { 246 if(!silentMessage_) 247 getOutputStream().println(messageHeader_ + ": " + text); 248 } 249 250 255 public void 256 error(String text) 257 { 258 getErrorStream().println(messageHeader_ + ": " + text); 259 } 260 } 261 | Popular Tags |