Debian Codegraph @

net/sf/saxon/lib/StringCollator.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.lib;
9
10 import net.sf.saxon.expr.sort.AtomicMatchKey;
11
12 /**
13 * This interface represents a "collation" as defined in XPath, that is, a set of rules for comparing strings
14 * <p>Note: an implementation of this interface that wraps a Java {@link java.text.RuleBasedCollator} is
15 * available: see {@link net.sf.saxon.expr.sort.RuleBasedSubstringMatcher}.</p>
16 */
17 public interface StringCollator {
18
19 /**
20 * Get the collation URI. It must be possible to use this collation URI to reconstitute the collation
21 * @return a collation URI that can be used to reconstruct the collation when an XSLT package is reloaded.
22 */
23
24 String getCollationURI();
25
26 /**
27 * Compare two strings
28 *
29 * @param o1 the first string
30 * @param o2 the second string
31 * @return 0 if the strings are considered equal, a negative integer if the first string is less than the second,
32 * a positive integer if the first string is greater than the second
33 */
34
35 int compareStrings(CharSequence o1, CharSequence o2);
36
37 /**
38 * Compare two strings for equality. This may be more efficient than using compareStrings and
39 * testing whether the result is zero, but it must give the same result
40 *
41 * @param s1 the first string
42 * @param s2 the second string
43 * @return true if and only if the strings are considered equal,
44 */
45
46 boolean comparesEqual(CharSequence s1, CharSequence s2);
47
48 /**
49 * Get a collation key for a String. The essential property of collation keys
50 * is that if (and only if) two strings are equal under the collation, then
51 * comparing the collation keys using the equals() method must return true.
52 *
53 * @param s the string whose collation key is required
54 * @return the collation key
55 */
56
57 AtomicMatchKey getCollationKey(CharSequence s);
58
59
60 }
61