You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by le...@apache.org on 2002/03/29 17:08:53 UTC

cvs commit: jakarta-avalon-excalibur/instrument-manager/src/java/org/apache/avalon/excalibur/instrument/manager DefaultInstrumentManager.java InstrumentableProxy.java InstrumentProxy.java

leif        02/03/29 08:08:53

  Modified:    instrument-manager/src/java/org/apache/avalon/excalibur/instrument/manager
                        DefaultInstrumentManager.java
                        InstrumentableProxy.java InstrumentProxy.java
  Log:
  Sort the child arrays to make it easier for clients.
  
  Revision  Changes    Path
  1.4       +20 -1     jakarta-avalon-excalibur/instrument-manager/src/java/org/apache/avalon/excalibur/instrument/manager/DefaultInstrumentManager.java
  
  Index: DefaultInstrumentManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/instrument-manager/src/java/org/apache/avalon/excalibur/instrument/manager/DefaultInstrumentManager.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DefaultInstrumentManager.java	28 Mar 2002 04:06:18 -0000	1.3
  +++ DefaultInstrumentManager.java	29 Mar 2002 16:08:53 -0000	1.4
  @@ -12,6 +12,8 @@
   import java.io.FileOutputStream;
   import java.io.InputStream;
   import java.io.OutputStream;
  +import java.util.Arrays;
  +import java.util.Comparator;
   import java.util.HashMap;
   
   import org.apache.avalon.excalibur.instrument.AbstractInstrument;
  @@ -38,7 +40,7 @@
   /**
    *
    * @author <a href="mailto:leif@silveregg.co.jp">Leif Mortenson</a>
  - * @version CVS $Revision: 1.3 $ $Date: 2002/03/28 04:06:18 $
  + * @version CVS $Revision: 1.4 $ $Date: 2002/03/29 16:08:53 $
    * @since 4.1
    */
   public class DefaultInstrumentManager
  @@ -778,6 +780,23 @@
               m_instrumentableProxyArray = new InstrumentableProxy[ m_instrumentableProxies.size() ];
               m_instrumentableProxies.values().toArray( m_instrumentableProxyArray );
   
  +            // Sort the array.  This is not a performance problem because this
  +            //  method is rarely called and doing it here saves cycles in the
  +            //  client.
  +            Arrays.sort( m_instrumentableProxyArray, new Comparator()
  +                {
  +                    public int compare( Object o1, Object o2 )
  +                    {
  +                        return ((InstrumentableProxy)o1).getDescription().
  +                            compareTo( ((InstrumentableProxy)o2).getDescription() );
  +                    }
  +                    
  +                    public boolean equals( Object obj )
  +                    {
  +                        return false;
  +                    }
  +                } );
  +            
               return m_instrumentableProxyArray;
           }
       }
  
  
  
  1.3       +20 -1     jakarta-avalon-excalibur/instrument-manager/src/java/org/apache/avalon/excalibur/instrument/manager/InstrumentableProxy.java
  
  Index: InstrumentableProxy.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/instrument-manager/src/java/org/apache/avalon/excalibur/instrument/manager/InstrumentableProxy.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- InstrumentableProxy.java	28 Mar 2002 04:06:18 -0000	1.2
  +++ InstrumentableProxy.java	29 Mar 2002 16:08:53 -0000	1.3
  @@ -7,6 +7,8 @@
    */
   package org.apache.avalon.excalibur.instrument.manager;
   
  +import java.util.Arrays;
  +import java.util.Comparator;
   import java.util.HashMap;
   
   import org.apache.avalon.excalibur.instrument.manager.interfaces.InstrumentDescriptor;
  @@ -26,7 +28,7 @@
    * Not Synchronized.
    *
    * @author <a href="mailto:leif@silveregg.co.jp">Leif Mortenson</a>
  - * @version CVS $Revision: 1.2 $ $Date: 2002/03/28 04:06:18 $
  + * @version CVS $Revision: 1.3 $ $Date: 2002/03/29 16:08:53 $
    * @since 4.1
    */
   class InstrumentableProxy
  @@ -279,6 +281,23 @@
               m_instrumentProxyArray = new InstrumentProxy[ m_instrumentProxies.size() ];
               m_instrumentProxies.values().toArray( m_instrumentProxyArray );
   
  +            // Sort the array.  This is not a performance problem because this
  +            //  method is rarely called and doing it here saves cycles in the
  +            //  client.
  +            Arrays.sort( m_instrumentProxyArray, new Comparator()
  +                {
  +                    public int compare( Object o1, Object o2 )
  +                    {
  +                        return ((InstrumentProxy)o1).getDescription().
  +                            compareTo( ((InstrumentProxy)o2).getDescription() );
  +                    }
  +                    
  +                    public boolean equals( Object obj )
  +                    {
  +                        return false;
  +                    }
  +                } );
  +            
               return m_instrumentProxyArray;
           }
       }
  
  
  
  1.3       +20 -1     jakarta-avalon-excalibur/instrument-manager/src/java/org/apache/avalon/excalibur/instrument/manager/InstrumentProxy.java
  
  Index: InstrumentProxy.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/instrument-manager/src/java/org/apache/avalon/excalibur/instrument/manager/InstrumentProxy.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- InstrumentProxy.java	28 Mar 2002 04:06:18 -0000	1.2
  +++ InstrumentProxy.java	29 Mar 2002 16:08:53 -0000	1.3
  @@ -8,6 +8,8 @@
   package org.apache.avalon.excalibur.instrument.manager;
   
   import java.util.ArrayList;
  +import java.util.Arrays;
  +import java.util.Comparator;
   import java.util.HashMap;
   import java.util.Iterator;
   
  @@ -36,7 +38,7 @@
    *  It is resolved when the Instrumentable actually registers the Instrument.
    *
    * @author <a href="mailto:leif@silveregg.co.jp">Leif Mortenson</a>
  - * @version CVS $Revision: 1.2 $ $Date: 2002/03/28 04:06:18 $
  + * @version CVS $Revision: 1.3 $ $Date: 2002/03/29 16:08:53 $
    * @since 4.1
    */
   public class InstrumentProxy
  @@ -674,6 +676,23 @@
           {
               m_sampleArray = new InstrumentSample[ m_samples.size() ];
               m_samples.values().toArray( m_sampleArray );
  +            
  +            // Sort the array.  This is not a performance problem because this
  +            //  method is rarely called and doing it here saves cycles in the
  +            //  client.
  +            Arrays.sort( m_sampleArray, new Comparator()
  +                {
  +                    public int compare( Object o1, Object o2 )
  +                    {
  +                        return ((InstrumentSample)o1).getDescription().
  +                            compareTo( ((InstrumentSample)o2).getDescription() );
  +                    }
  +                    
  +                    public boolean equals( Object obj )
  +                    {
  +                        return false;
  +                    }
  +                } );
               
               return m_sampleArray;
           }
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>