ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dona...@apache.org
Subject cvs commit: jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/listeners DefaultProjectListener.java ClassicProjectListener.java
Date Sun, 30 Dec 2001 07:39:56 GMT
donaldp     01/12/29 23:39:56

  Modified:    proposal/myrmidon/src/java/org/apache/myrmidon/listeners
                        DefaultProjectListener.java
                        ClassicProjectListener.java
  Log:
  Refactored to work well with new AbstractProjectListener
  
  Revision  Changes    Path
  1.8       +19 -42    jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/listeners/DefaultProjectListener.java
  
  Index: DefaultProjectListener.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/listeners/DefaultProjectListener.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- DefaultProjectListener.java	23 Dec 2001 06:25:37 -0000	1.7
  +++ DefaultProjectListener.java	30 Dec 2001 07:39:56 -0000	1.8
  @@ -14,38 +14,20 @@
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
    */
  -public class DefaultProjectListener
  +public final class DefaultProjectListener
       extends AbstractProjectListener
   {
  -    private String m_prefix;
  -    private String m_targetName;
  +    private boolean m_targetOutput;
   
       /**
        * Notify listener of targetStarted event.
        *
  -     * @param targetName the name of target
  +     * @param target the name of target
        */
  -    public void targetStarted( final String targetName )
  +    public void targetStarted( final String target )
       {
  -        m_targetName = targetName;
  -    }
  -
  -    /**
  -     * Notify listener of taskStarted event.
  -     *
  -     * @param taskName the name of task
  -     */
  -    public void taskStarted( final String taskName )
  -    {
  -        setPrefix( taskName );
  -    }
  -
  -    /**
  -     * Notify listener of taskFinished event.
  -     */
  -    public void taskFinished()
  -    {
  -        setPrefix( null );
  +        super.targetStarted( target );
  +        m_targetOutput = false;
       }
   
       /**
  @@ -53,7 +35,7 @@
        *
        * @param message the message
        */
  -    public void log( String message )
  +    public void log( final String message )
       {
           output( message );
       }
  @@ -64,7 +46,7 @@
        * @param message the message
        * @param throwable the throwable
        */
  -    public void log( String message, Throwable throwable )
  +    public void log( final String message, final Throwable throwable )
       {
           output( message + "\n" + ExceptionUtil.printStackTrace( throwable, 5, true ) );
       }
  @@ -75,27 +57,22 @@
        *
        * @param data the data
        */
  -    protected void output( final String data )
  +    private void output( final String data )
       {
  -        if( null != m_targetName )
  +        if( !m_targetOutput )
           {
  -            System.out.println( m_targetName + ":\n" );
  -            m_targetName = null;
  +            System.out.println( getTarget() + ":\n" );
  +            m_targetOutput = true;
           }
   
  -        if( null != getPrefix() )
  -            System.out.println( "\t[" + getPrefix() + "] " + data );
  +        final String task = getTask();
  +        if( null != task )
  +        {
  +            System.out.println( "\t[" + task + "] " + data );
  +        }
           else
  +        {
               System.out.println( data );
  -    }
  -
  -    protected final String getPrefix()
  -    {
  -        return m_prefix;
  -    }
  -
  -    protected final void setPrefix( final String prefix )
  -    {
  -        m_prefix = prefix;
  +        }
       }
   }
  
  
  
  1.4       +13 -36    jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/listeners/ClassicProjectListener.java
  
  Index: ClassicProjectListener.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/listeners/ClassicProjectListener.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ClassicProjectListener.java	23 Dec 2001 06:25:37 -0000	1.3
  +++ ClassicProjectListener.java	30 Dec 2001 07:39:56 -0000	1.4
  @@ -10,11 +10,11 @@
   import org.apache.avalon.framework.ExceptionUtil;
   
   /**
  - * Default listener that emulates the old ant listener notifications.
  + * Classic listener that emulates the default ant1.x listener notifications.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
    */
  -public class ClassicProjectListener
  +public final class ClassicProjectListener
       extends AbstractProjectListener
   {
       private String m_prefix;
  @@ -22,29 +22,11 @@
       /**
        * Notify listener of targetStarted event.
        *
  -     * @param targetName the name of target
  +     * @param target the name of target
        */
  -    public void targetStarted( final String targetName )
  +    public void targetStarted( final String target )
       {
  -        output( targetName + ":\n" );
  -    }
  -
  -    /**
  -     * Notify listener of taskStarted event.
  -     *
  -     * @param taskName the name of task
  -     */
  -    public void taskStarted( final String taskName )
  -    {
  -        setPrefix( taskName );
  -    }
  -
  -    /**
  -     * Notify listener of taskFinished event.
  -     */
  -    public void taskFinished()
  -    {
  -        setPrefix( null );
  +        output( target + ":\n" );
       }
   
       /**
  @@ -74,21 +56,16 @@
        *
        * @param data the data
        */
  -    protected void output( final String data )
  +    private void output( final String data )
       {
  -        if( null != getPrefix() )
  -            System.out.println( "\t[" + getPrefix() + "] " + data );
  +        final String task = getTask();
  +        if( null != task )
  +        {
  +            System.out.println( "\t[" + task + "] " + data );
  +        }
           else
  +        {
               System.out.println( data );
  -    }
  -
  -    protected final String getPrefix()
  -    {
  -        return m_prefix;
  -    }
  -
  -    protected final void setPrefix( final String prefix )
  -    {
  -        m_prefix = prefix;
  +        }
       }
   }
  
  
  

--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message