KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mc4j > console > connection > MBeanNameComparator


1 /*
2  * Copyright 2002-2004 Greg Hinkle
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.mc4j.console.connection;
18
19 import java.util.Comparator JavaDoc;
20
21 import javax.management.ObjectName JavaDoc;
22
23 /**
24  * @author Corby Page 09.07.02
25  */

26 public class MBeanNameComparator implements Comparator JavaDoc {
27     
28     /**
29      * Constructor for MBeanNameComparator.
30      */

31     public MBeanNameComparator() {
32         super();
33     }
34     
35     /**
36      * @see java.util.Comparator#compare(Object, Object)
37      */

38     public int compare(Object JavaDoc arg0, Object JavaDoc arg1) {
39         if ( arg0 instanceof ObjectName JavaDoc && arg1 instanceof ObjectName JavaDoc ) {
40             ObjectName JavaDoc thisName = (ObjectName JavaDoc)arg0;
41             ObjectName JavaDoc thatName = (ObjectName JavaDoc)arg1;
42             return thisName.getCanonicalName().compareTo(
43             thatName.getCanonicalName());
44         }
45         return 0;
46     }
47     
48 }
Popular Tags