01: package net.sf.saxon.sort;
02:
03: import net.sf.saxon.om.NodeInfo;
04:
05: import java.io.Serializable;
06:
07: /**
08: * A Comparer used for comparing nodes in document order. This
09: * comparer assumes that the nodes being compared come from the same document
10: *
11: * @author Michael H. Kay
12: *
13: */
14:
15: public final class LocalOrderComparer implements NodeOrderComparer,
16: Serializable {
17:
18: private static LocalOrderComparer instance = new LocalOrderComparer();
19:
20: /**
21: * Get an instance of a LocalOrderComparer. The class maintains no state
22: * so this returns the same instance every time.
23: */
24:
25: public static LocalOrderComparer getInstance() {
26: return instance;
27: }
28:
29: public int compare(NodeInfo a, NodeInfo b) {
30: NodeInfo n1 = (NodeInfo) a;
31: NodeInfo n2 = (NodeInfo) b;
32: return n1.compareOrder(n2);
33: }
34: }
35:
36: //
37: // The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
38: // you may not use this file except in compliance with the License. You may obtain a copy of the
39: // License at http://www.mozilla.org/MPL/
40: //
41: // Software distributed under the License is distributed on an "AS IS" basis,
42: // WITHOUT WARRANTY OF ANY KIND, either express or implied.
43: // See the License for the specific language governing rights and limitations under the License.
44: //
45: // The Original Code is: all this file.
46: //
47: // The Initial Developer of the Original Code is Michael H. Kay
48: //
49: // Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
50: //
51: // Contributor(s): none
52: //
|