donaldp     01/12/22 22:17:57

  Modified:    proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/exec
                        LogOutputStream.java
  Log:
  Removed some cruft and cleaned up file
  
  Revision  Changes    Path
  1.3       +26 -35    
jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/exec/LogOutputStream.java
  
  Index: LogOutputStream.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/exec/LogOutputStream.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- LogOutputStream.java      2001/12/19 11:48:46     1.2
  +++ LogOutputStream.java      2001/12/23 06:17:57     1.3
  @@ -10,7 +10,6 @@
   import java.io.ByteArrayOutputStream;
   import java.io.IOException;
   import java.io.OutputStream;
  -import org.apache.tools.ant.Project;
   import org.apache.tools.ant.Task;
   
   /**
  @@ -21,13 +20,14 @@
    *
    * @author [EMAIL PROTECTED]
    */
  -public class LogOutputStream extends OutputStream
  +public class LogOutputStream
  +    extends OutputStream
   {
  -    private ByteArrayOutputStream buffer = new ByteArrayOutputStream();
  -    private boolean skip = false;
  -    private int level = Project.MSG_INFO;
  +    private final int m_level;
  +    private final Task m_task;
   
  -    private Task task;
  +    private ByteArrayOutputStream m_buffer = new ByteArrayOutputStream();
  +    private boolean m_skip;
   
       /**
        * Creates a new instance of this class.
  @@ -35,17 +35,12 @@
        * @param task the task for whom to log
        * @param level loglevel used to log data written to this stream.
        */
  -    public LogOutputStream( Task task, int level )
  +    public LogOutputStream( final Task task, final int level )
       {
  -        this.task = task;
  -        this.level = level;
  +        m_task = task;
  +        m_level = level;
       }
   
  -    public int getMessageLevel()
  -    {
  -        return level;
  -    }
  -
       /**
        * Writes all remaining
        *
  @@ -54,8 +49,10 @@
       public void close()
           throws IOException
       {
  -        if( buffer.size() > 0 )
  +        if( m_buffer.size() > 0 )
  +        {
               processBuffer();
  +        }
           super.close();
       }
   
  @@ -66,37 +63,31 @@
        * @param cc data to log (byte).
        * @exception IOException Description of Exception
        */
  -    public void write( int cc )
  +    public void write( final int ch )
           throws IOException
       {
  -        final byte c = (byte)cc;
  -        if( ( c == '\n' ) || ( c == '\r' ) )
  +        if( ( ch == '\n' ) || ( ch == '\r' ) )
           {
  -            if( !skip )
  +            if( !m_skip )
  +            {
                   processBuffer();
  +            }
           }
           else
  -            buffer.write( cc );
  -        skip = ( c == '\r' );
  -    }
  +        {
  +            m_buffer.write( (byte)ch );
  +        }
   
  -    /**
  -     * Converts the buffer to a string and sends it to 
<code>processLine</code>
  -     */
  -    protected void processBuffer()
  -    {
  -        processLine( buffer.toString() );
  -        buffer.reset();
  +        m_skip = ( ch == '\r' );
       }
   
       /**
  -     * Logs a line to the log system of ant.
  -     *
  -     * @param line the line to log.
  +     * Converts the buffer to a string and sends it to 
<code>processLine</code>
        */
  -    protected void processLine( String line )
  +    private void processBuffer()
       {
  -        processLine( line, level );
  +        processLine( m_buffer.toString(), m_level );
  +        m_buffer.reset();
       }
   
       /**
  @@ -107,6 +98,6 @@
        */
       protected void processLine( String line, int level )
       {
  -        task.log( line, level );
  +        m_task.log( line, level );
       }
   }
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to