KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > saxon > sort > DescendingComparer


1 package net.sf.saxon.sort;
2 import java.util.Comparator JavaDoc;
3
4 /**
5  * A Comparer used for comparing descending keys
6  *
7  *
8  */

9
10 public class DescendingComparer implements Comparator JavaDoc, java.io.Serializable JavaDoc {
11
12     private Comparator JavaDoc baseComparer;
13
14     public DescendingComparer(Comparator JavaDoc base) {
15         baseComparer = base;
16     }
17
18     /**
19     * Compare two objects.
20     * @return <0 if a<b, 0 if a=b, >0 if a>b
21     * @throws ClassCastException if the objects are of the wrong type for this Comparer
22     */

23
24     public int compare(Object JavaDoc a, Object JavaDoc b) {
25         return 0 - baseComparer.compare(a, b);
26     }
27
28 }
29
30
31 //
32
// The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
33
// you may not use this file except in compliance with the License. You may obtain a copy of the
34
// License at http://www.mozilla.org/MPL/
35
//
36
// Software distributed under the License is distributed on an "AS IS" basis,
37
// WITHOUT WARRANTY OF ANY KIND, either express or implied.
38
// See the License for the specific language governing rights and limitations under the License.
39
//
40
// The Original Code is: all this file.
41
//
42
// The Initial Developer of the Original Code is Michael H. Kay
43
//
44
// Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
45
//
46
// Contributor(s): none
47
//
Popular Tags