KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > icl > saxon > sort > Comparer


1 package com.icl.saxon.sort;
2 import com.icl.saxon.*;
3
4 /**
5  * A Comparer used for comparing keys
6  *
7  * @author Michael H. Kay (mhkay@iclway.co.uk)
8  *
9  */

10
11 public abstract class Comparer {
12
13     /**
14     * Compare two objects.
15     * @return <0 if a<b, 0 if a=b, >0 if a>b
16     * @throws ClassCastException if the objects are of the wrong type for this Comparer
17     */

18
19     public abstract int compare(Object JavaDoc a, Object JavaDoc b);
20
21     /**
22     * Set data type. The comparer has the option of returning a different comparer
23     * once it knows the data type
24     */

25
26     public Comparer setDataType(String JavaDoc dataTypeURI, String JavaDoc dataTypeLocalName) {
27         return this;
28     }
29
30     /**
31     * Set order. The comparer has the option of returning a different comparer
32     */

33
34     public Comparer setOrder(boolean isAscending) {
35         return (isAscending ? this : new DescendingComparer(this) );
36     }
37
38 }
39
Popular Tags