KickJava   Java API By Example, From Geeks To Geeks.

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


1 package com.icl.saxon.sort;
2 import com.icl.saxon.om.NodeInfo;
3
4 /**
5  * A Comparer used for comparing nodes in document order. This
6  * comparer assumes that the nodes being compared come from the same document
7  *
8  * @author Michael H. Kay (mhkay@iclway.co.uk)
9  *
10  */

11
12 public final class LocalOrderComparer implements NodeOrderComparer {
13        
14     private static LocalOrderComparer instance = new LocalOrderComparer();
15
16     /**
17     * Get an instance of a LocalOrderComparer. The class maintains no state
18     * so this returns the same instance every time.
19     */

20     
21     public static LocalOrderComparer getInstance() {
22         return instance;
23     }
24        
25     public int compare(NodeInfo a, NodeInfo b) {
26         NodeInfo n1 = (NodeInfo)a;
27         NodeInfo n2 = (NodeInfo)b;
28         return n1.compareOrder(n2);
29     }
30 }
31
32
Popular Tags