KickJava   Java API By Example, From Geeks To Geeks.

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


1 package net.sf.saxon.sort;
2 import net.sf.saxon.om.NodeInfo;
3
4 import java.io.Serializable JavaDoc;
5
6 /**
7  * A Comparer used for comparing nodes in document order. This
8  * comparer assumes that the nodes being compared come from the same document
9  *
10  * @author Michael H. Kay
11  *
12  */

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

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