1 package org.apache.maven.scm.provider.cvslib.cvsjava.util; 2 3 /* 4 * Licensed to the Apache Software Foundation (ASF) under one 5 * or more contributor license agreements. See the NOTICE file 6 * distributed with this work for additional information 7 * regarding copyright ownership. The ASF licenses this file 8 * to you under the Apache License, Version 2.0 (the 9 * "License"); you may not use this file except in compliance 10 * with the License. You may obtain a copy of the License at 11 * 12 * http://www.apache.org/licenses/LICENSE-2.0 13 * 14 * Unless required by applicable law or agreed to in writing, 15 * software distributed under the License is distributed on an 16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 * KIND, either express or implied. See the License for the 18 * specific language governing permissions and limitations 19 * under the License. 20 */ 21 22 import org.netbeans.lib.cvsclient.event.CVSAdapter; 23 import org.netbeans.lib.cvsclient.event.MessageEvent; 24 25 /** 26 * A basic implementation of a CVS listener. It merely saves up 27 * into StringBuilders the stdout and stderr printstreams. 28 * 29 * @author <a href="mailto:epugh@upstate.com">Eric Pugh</a> 30 * 31 */ 32 public class CvsLogListener 33 extends CVSAdapter 34 { 35 private final StringBuffer taggedLine = new StringBuffer(); 36 37 private StringBuffer stdout = new StringBuffer(); 38 39 private StringBuffer stderr = new StringBuffer(); 40 41 /** 42 * Called when the server wants to send a message to be displayed to the 43 * user. The message is only for information purposes and clients can 44 * choose to ignore these messages if they wish. 45 * 46 * {@inheritDoc} 47 */ 48 public void messageSent( MessageEvent e ) 49 { 50 String line = e.getMessage(); 51 StringBuffer stream = e.isError() ? stderr : stdout; 52 53 if ( e.isTagged() ) 54 { 55 String message = MessageEvent.parseTaggedMessage( taggedLine, e.getMessage() ); 56 if ( message != null ) 57 { 58 //stream.println(message); 59 stream.append( message ).append( "\n" ); 60 61 } 62 } 63 else 64 { 65 //stream.println(line); 66 stream.append( line ).append( "\n" ); 67 68 } 69 } 70 71 /** 72 * @return Returns the standard output from cvs as a StringBuilder.. 73 */ 74 public StringBuffer getStdout() 75 { 76 return stdout; 77 } 78 79 /** 80 * @return Returns the standard error from cvs as a StringBuilder.. 81 */ 82 public StringBuffer getStderr() 83 { 84 return stderr; 85 } 86 }