01: package net.sf.saxon.sort;
02:
03: import java.util.Comparator;
04:
05: /**
06: * A Comparer used for comparing descending keys
07: *
08: *
09: */
10:
11: public class DescendingComparer implements Comparator,
12: java.io.Serializable {
13:
14: private Comparator baseComparer;
15:
16: public DescendingComparer(Comparator base) {
17: baseComparer = base;
18: }
19:
20: /**
21: * Compare two objects.
22: * @return <0 if a<b, 0 if a=b, >0 if a>b
23: * @throws ClassCastException if the objects are of the wrong type for this Comparer
24: */
25:
26: public int compare(Object a, Object b) {
27: return 0 - baseComparer.compare(a, b);
28: }
29:
30: }
31:
32: //
33: // The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
34: // you may not use this file except in compliance with the License. You may obtain a copy of the
35: // License at http://www.mozilla.org/MPL/
36: //
37: // Software distributed under the License is distributed on an "AS IS" basis,
38: // WITHOUT WARRANTY OF ANY KIND, either express or implied.
39: // See the License for the specific language governing rights and limitations under the License.
40: //
41: // The Original Code is: all this file.
42: //
43: // The Initial Developer of the Original Code is Michael H. Kay
44: //
45: // Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
46: //
47: // Contributor(s): none
48: //
|