KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > directory > ldapstudio > schemas > view > editors > attributeType > ATEMatchingRulesComboComparator


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  *
19  */

20 package org.apache.directory.ldapstudio.schemas.view.editors.attributeType;
21
22
23 import java.util.Comparator JavaDoc;
24
25 import org.apache.directory.ldapstudio.schemas.model.MatchingRule;
26
27
28 /**
29  * This class implements the Comparator used to compare elements in the Matching Rules Content Providers.
30  *
31  * @author <a HREF="mailto:dev@directory.apache.org">Apache Directory Project</a>
32  * @version $Rev$, $Date$
33  */

34 public class ATEMatchingRulesComboComparator implements Comparator JavaDoc<Object JavaDoc>
35 {
36     /* (non-Javadoc)
37      * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
38      */

39     public int compare( Object JavaDoc o1, Object JavaDoc o2 )
40     {
41         if ( o1 instanceof MatchingRule && o2 instanceof MatchingRule )
42         {
43             return ( ( MatchingRule ) o1 ).getName().compareToIgnoreCase( ( ( MatchingRule ) o2 ).getName() );
44         }
45         else if ( o1 instanceof MatchingRule && o2 instanceof NonExistingMatchingRule )
46         {
47             return ( ( MatchingRule ) o1 ).getName().compareToIgnoreCase( ( ( NonExistingMatchingRule ) o2 ).getName() );
48         }
49         else if ( o1 instanceof NonExistingMatchingRule && o2 instanceof MatchingRule )
50         {
51             return ( ( NonExistingMatchingRule ) o1 ).getName().compareToIgnoreCase( ( ( MatchingRule ) o2 ).getName() );
52         }
53         else if ( o1 instanceof NonExistingMatchingRule && o2 instanceof NonExistingMatchingRule )
54         {
55             return ( ( NonExistingMatchingRule ) o1 ).getName().compareToIgnoreCase(
56                 ( ( NonExistingMatchingRule ) o2 ).getName() );
57         }
58
59         return 0;
60     }
61 }
62
Popular Tags