1 22 package org.netbeans.lib.cvsclient.commandLine; 23 24 import java.io.*; 25 26 import org.netbeans.lib.cvsclient.command.*; 27 import org.netbeans.lib.cvsclient.event.*; 28 29 35 public class BasicListener extends CVSAdapter { 36 private final StringBuffer taggedLine = new StringBuffer (); 37 private PrintStream stdout; 38 private PrintStream stderr; 39 40 public BasicListener() { 41 this(System.out, System.err); 42 } 43 44 public BasicListener(PrintStream stdout, PrintStream stderr) { 45 this.stdout = stdout; 46 this.stderr = stderr; 47 } 48 49 55 public void messageSent(MessageEvent e) { 56 String line = e.getMessage(); 57 if (e instanceof EnhancedMessageEvent) { 58 return ; 59 } 60 PrintStream stream = e.isError() ? stderr : stdout; 61 62 if (e.isTagged()) { 63 String message = MessageEvent.parseTaggedMessage(taggedLine, e.getMessage()); 64 if (message != null) { 65 stream.println(message); 66 } 67 } 68 else { 69 stream.println(line); 70 } 71 } 72 73 79 public void messageSent(BinaryMessageEvent e) { 80 byte[] bytes = e.getMessage(); 81 int len = e.getMessageLength(); 82 stdout.write(bytes, 0, len); 83 } 84 85 88 public void fileInfoGenerated(FileInfoEvent e) { 89 } 96 } | Popular Tags |