KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > appserv > management > util > jmx > MBeanAttributeInfoComparator


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 package com.sun.appserv.management.util.jmx;
25
26 import javax.management.MBeanAttributeInfo JavaDoc;
27
28 import com.sun.appserv.management.util.jmx.stringifier.MBeanAttributeInfoStringifier;
29 import com.sun.appserv.management.util.jmx.stringifier.MBeanFeatureInfoStringifierOptions;
30
31 /**
32     Caution: this Comparator may be inconsistent with equals() because it ignores the description.
33  */

34 public final class MBeanAttributeInfoComparator implements java.util.Comparator JavaDoc<MBeanAttributeInfo JavaDoc>
35 {
36     private static final MBeanAttributeInfoStringifier ATTRIBUTE_INFO_STRINGIFIER =
37         new MBeanAttributeInfoStringifier( new MBeanFeatureInfoStringifierOptions( false, ",") );
38     
39     public static final MBeanAttributeInfoComparator INSTANCE = new MBeanAttributeInfoComparator();
40     
41     private MBeanAttributeInfoComparator() {}
42     
43         public int
44     compare( final MBeanAttributeInfo JavaDoc o1, final MBeanAttributeInfo JavaDoc o2 )
45     {
46         final String JavaDoc s1 = ATTRIBUTE_INFO_STRINGIFIER.stringify( o1 );
47         final String JavaDoc s2 = ATTRIBUTE_INFO_STRINGIFIER.stringify( o2 );
48         
49         return( s1.compareTo( s2 ) );
50     }
51     
52         public boolean
53     equals( Object JavaDoc other )
54     {
55         return( other instanceof MBeanAttributeInfoComparator );
56     }
57 }
58     
59     
60
61
62
63
Popular Tags