KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ejtools > jmx > MBeanSorter


1 /*
2  * EJTools, the Enterprise Java Tools
3  *
4  * Distributable under LGPL license.
5  * See terms of license at www.gnu.org.
6  */

7 package org.ejtools.jmx;
8
9 import java.util.Collections JavaDoc;
10 import java.util.Comparator JavaDoc;
11 import java.util.List JavaDoc;
12
13 import javax.management.MBeanFeatureInfo JavaDoc;
14
15 /**
16  * A utility class for sorting attributes of MBean
17  *
18  * @author Laurent Etiemble
19  * @version $Revision: 1.1 $
20  */

21 public class MBeanSorter
22 {
23    /**
24     * Sort features info by their name
25     *
26     * @param infos Features to sort
27     */

28    public static void sortByName(List JavaDoc infos)
29    {
30       Collections.sort(infos,
31          new Comparator JavaDoc()
32          {
33             public int compare(Object JavaDoc o1, Object JavaDoc o2)
34             {
35                MBeanFeatureInfo JavaDoc mbfi1 = (MBeanFeatureInfo JavaDoc) o1;
36                MBeanFeatureInfo JavaDoc mbfi2 = (MBeanFeatureInfo JavaDoc) o2;
37
38                return mbfi1.getName().compareTo(mbfi2.getName());
39             }
40
41
42             public boolean equals(Object JavaDoc obj)
43             {
44                // Never called ?
45
return false;
46             }
47          });
48    }
49 }
50
Popular Tags