Debian Codegraph @

net/sf/saxon/expr/sort/LocalOrderComparer.java

raw symbols SCIP
1 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2 // Copyright (c) 2018 Saxonica Limited.
3 // This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
4 // If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 // This Source Code Form is "Incompatible With Secondary Licenses", as defined by the Mozilla Public License, v. 2.0.
6 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
7
8 package net.sf.saxon.expr.sort;
9
10 import net.sf.saxon.om.Item;
11 import net.sf.saxon.om.NodeInfo;
12
13 import java.io.Serializable;
14
15 /**
16 * A Comparer used for comparing nodes in document order. This
17 * comparer assumes that the nodes being compared come from the same document
18 *
19 * @author Michael H. Kay
20 */
21
22 public final class LocalOrderComparer implements ItemOrderComparer {
23
24 private static LocalOrderComparer instance = new LocalOrderComparer();
25
26 /**
27 * Get an instance of a LocalOrderComparer. The class maintains no state
28 * so this returns the same instance every time.
29 */
30
31 /*@NotNull*/
32 public static LocalOrderComparer getInstance() {
33 return instance;
34 }
35
36 public int compare(Item a, Item b) {
37 NodeInfo n1 = (NodeInfo) a;
38 NodeInfo n2 = (NodeInfo) b;
39 return n1.compareOrder(n2);
40 }
41 }
42