View Javadoc
1 /* 2 AntMake 3 4 Copyright (C) 2004 Jose San Leandro Armend?riz 5 jsanleandro@yahoo.es 6 chousz@yahoo.com 7 8 This library is free software; you can redistribute it and/or 9 modify it under the terms of the GNU General Public 10 License as published by the Free Software Foundation; either 11 version 2 of the License, or (at your option) any later version. 12 13 This library is distributed in the hope that it will be useful, 14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 General Public License for more details. 17 18 You should have received a copy of the GNU General Public 19 License along with this library; if not, write to the Free Software 20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 22 Thanks to ACM S.L. for distributing this library under the GPL license. 23 Contact info: jsr000@terra.es 24 Postal Address: c/Playa de Lagoa, 1 25 Urb. Valdecaba?as 26 Boadilla del monte 27 28660 Madrid 28 Spain 29 30 ****************************************************************************** 31 This class is based on RedirectingStreamHandler 32 included in Ant distribution, and whose license details 33 are the following. 34 35 * 36 * The Apache Software License, Version 1.1 37 * 38 * Copyright (c) 2002 The Apache Software Foundation. All rights 39 * reserved. 40 * 41 * Redistribution and use in source and binary forms, with or without 42 * modification, are permitted provided that the following conditions 43 * are met: 44 * 45 * 1. Redistributions of source code must retain the above copyright 46 * notice, this list of conditions and the following disclaimer. 47 * 48 * 2. Redistributions in binary form must reproduce the above copyright 49 * notice, this list of conditions and the following disclaimer in 50 * the documentation and/or other materials provided with the 51 * distribution. 52 * 53 * 3. The end-user documentation included with the redistribution, if 54 * any, must include the following acknowlegement: 55 * "This product includes software developed by the 56 * Apache Software Foundation (http://www.apache.org/)." 57 * Alternately, this acknowlegement may appear in the software itself, 58 * if and wherever such third-party acknowlegements normally appear. 59 * 60 * 4. The names "Ant" and "Apache Software 61 * Foundation" must not be used to endorse or promote products derived 62 * from this software without prior written permission. For written 63 * permission, please contact apache@apache.org. 64 * 65 * 5. Products derived from this software may not be called "Apache" 66 * nor may "Apache" appear in their names without prior written 67 * permission of the Apache Group. 68 * 69 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 70 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 71 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 72 * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR 73 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 74 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 75 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 76 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 77 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 78 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 79 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 80 * SUCH DAMAGE. 81 * ==================================================================== 82 * 83 * This software consists of voluntary contributions made by many 84 * individuals on behalf of the Apache Software Foundation. For more 85 * information on the Apache Software Foundation, please see 86 * <http://www.apache.org/>. 87 * 88 89 ****************************************************************************** 90 * 91 * Filename: $RCSfile: RedirectingStreamHandler.java,v $ 92 * 93 * Author: Jose San Leandro Armend?riz 94 * 95 * Description: Do-nothing handler to allow redirection of the stream 96 * to the cvs log's output parser. 97 * 98 * Last modified by: $Author: chous $ at $Date: 2004/01/28 07:20:30 $ 99 * 100 * File version: $Revision: 1.1 $ 101 * 102 * Project version: $Name: $ 103 * 104 * $Id: RedirectingStreamHandler.java,v 1.1 2004/01/28 07:20:30 chous Exp $ 105 * 106 */ 107 package org.acmsl.antmake.cvslib; 108 109 /* 110 * Importing project classes. 111 */ 112 import org.acmsl.antmake.cvslib.RedirectingOutputStream; 113 114 /* 115 * Importing JDK classes. 116 */ 117 import java.io.ByteArrayOutputStream; 118 import java.io.IOException; 119 120 /* 121 * Importing Ant classes. 122 */ 123 import org.apache.tools.ant.BuildException; 124 import org.apache.tools.ant.taskdefs.PumpStreamHandler; 125 126 /* 127 * Importing Commons Logging classes. 128 */ 129 import org.apache.commons.logging.LogFactory; 130 131 /*** 132 * Do-nothing handler to allow redirection of the stream 133 * to the cvs log's output parser. 134 * @author <a href="mailto:jsanleandro@yahoo.es" 135 >Jose San Leandro</a>, based on 136 * <a href="mailto:peter@apache.org">Peter Donald</a>'s 137 * RedirectingStreamHandler. It's package-protected, so it had to be 138 * basically copied and pasted. 139 * @version $Revision: 1.1 $ 140 * @see org.apache.tools.ant.taskdefs.cvslib.RedirectingStreamHandler 141 */ 142 public class RedirectingStreamHandler 143 extends PumpStreamHandler 144 { 145 /*** 146 * Creates a RedirectingStreamHandler for given parser. 147 * @param parser the parser. 148 */ 149 public RedirectingStreamHandler(ChangeLogParser parser) 150 { 151 super( 152 new RedirectingOutputStream(parser), 153 new ByteArrayOutputStream()); 154 } 155 156 /*** 157 * Retrieves the errors. 158 * @return such errors. 159 */ 160 public String getErrors() 161 { 162 String result = ""; 163 164 try 165 { 166 ByteArrayOutputStream t_baosErrors = 167 (ByteArrayOutputStream) getErr(); 168 169 result = t_baosErrors.toString("ASCII"); 170 } 171 catch (IOException ioException) 172 { 173 LogFactory.getLog(RedirectingStreamHandler.class).warn( 174 "Error redirecting the stream", 175 ioException); 176 } 177 178 return result; 179 } 180 181 /*** 182 * Stops the stream flow. 183 */ 184 public void stop() 185 throws BuildException 186 { 187 super.stop(); 188 189 try 190 { 191 getErr().close(); 192 getOut().close(); 193 } 194 catch (IOException ioException) 195 { 196 // plain impossible 197 throw new BuildException(ioException); 198 } 199 } 200 } 201

This page was automatically generated by Maven