ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adammurd...@apache.org
Subject cvs commit: jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/event DefaultTaskEventManager.java
Date Fri, 17 May 2002 07:33:24 GMT
adammurdoch    02/05/17 00:33:24

  Modified:    container/src/java/org/apache/myrmidon/components/event
                        DefaultTaskEventManager.java
  Log:
  removeListener() was broken.  Now uses a List instead of messing with arrays.
  
  Revision  Changes    Path
  1.2       +8 -26     jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/event/DefaultTaskEventManager.java
  
  Index: DefaultTaskEventManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/event/DefaultTaskEventManager.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DefaultTaskEventManager.java	23 Apr 2002 07:21:39 -0000	1.1
  +++ DefaultTaskEventManager.java	17 May 2002 07:33:24 -0000	1.2
  @@ -10,16 +10,19 @@
   import org.apache.myrmidon.api.event.TaskEvent;
   import org.apache.myrmidon.api.event.TaskListener;
   import org.apache.myrmidon.interfaces.event.TaskEventManager;
  +import java.util.List;
  +import java.util.ArrayList;
   
   /**
    * Support for the task listener event dispatching.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.1 $ $Date: 2002/04/23 07:21:39 $
  + * @version $Revision: 1.2 $ $Date: 2002/05/17 07:33:24 $
    */
   public class DefaultTaskEventManager
       implements TaskEventManager
   {
  +    private final List m_listenerList = new ArrayList();
       private TaskListener[] m_listeners = new TaskListener[ 0 ];
   
       /**
  @@ -29,10 +32,8 @@
        */
       public void addTaskListener( final TaskListener listener )
       {
  -        final TaskListener[] listeners = new TaskListener[ m_listeners.length + 1 ];
  -        System.arraycopy( m_listeners, 0, listeners, 0, m_listeners.length );
  -        listeners[ m_listeners.length ] = listener;
  -        m_listeners = listeners;
  +        m_listenerList.add( listener );
  +        m_listeners = (TaskListener[])m_listenerList.toArray( new TaskListener[ m_listenerList.size()
] );
       }
   
       /**
  @@ -42,29 +43,10 @@
        */
       public void removeTaskListener( final TaskListener listener )
       {
  -        int found = -1;
  -
  -        for( int i = 0; i < m_listeners.length; i++ )
  -        {
  -            if( listener == m_listeners[ i ] )
  -            {
  -                found = i;
  -                break;
  -            }
  -        }
  -
  -        if( -1 == found )
  +        if( m_listenerList.remove( listener ) )
           {
  -            return;
  +            m_listeners = (TaskListener[])m_listenerList.toArray( new TaskListener[ m_listenerList.size()
] );
           }
  -
  -        final TaskListener[] listeners = new TaskListener[ m_listeners.length - 1 ];
  -        System.arraycopy( m_listeners, 0, listeners, 0, found );
  -
  -        final int count = m_listeners.length - found - 1;
  -        System.arraycopy( m_listeners, found, listeners, found + 1, count );
  -
  -        m_listeners = listeners;
       }
   
       /**
  
  
  

--
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