| //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
| // Copyright (c) 2018-2023 Saxonica Limited | |
| // This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. | |
| // If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. | |
| // This Source Code Form is "Incompatible With Secondary Licenses", as defined by the Mozilla Public License, v. 2.0. | |
| //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
| package net.sf.saxon.lib; | |
| import net.sf.saxon.str.UnicodeString; | |
| /** | |
| * This interface is implemented by a collation that is capable of supporting | |
| * the XPath functions that require matching of a substring: namely contains(), | |
| * starts-with, ends-with, substring-before, and substring-after. For sorting | |
| * and comparing strings, a collation needs to implement only the {@link StringCollator} | |
| * interface; for matching of substrings, it must also implement this interface. | |
| */ | |
| public interface SubstringMatcher extends StringCollator { | |
| /** | |
| * Test whether one string contains another, according to the rules | |
| * of the XPath contains() function | |
| * | |
| * @param s1 the containing string | |
| * @param s2 the contained string | |
| * @return true iff s1 contains s2 | |
| */ | |
| boolean contains(UnicodeString s1, UnicodeString s2); | |
| /** | |
| * Test whether one string starts with another, according to the rules | |
| * of the XPath starts-with() function | |
| * | |
| * @param s1 the containing string | |
| * @param s2 the contained string | |
| * @return true iff s1 starts with s2 | |
| */ | |
| boolean startsWith(UnicodeString s1, UnicodeString s2); | |
| /** | |
| * Test whether one string ends with another, according to the rules | |
| * of the XPath ends-with() function | |
| * | |
| * @param s1 the containing string | |
| * @param s2 the contained string | |
| * @return true iff s1 ends with s2 | |
| */ | |
| boolean endsWith(UnicodeString s1, UnicodeString s2); | |
| /** | |
| * Return the part of a string before a given substring, according to the rules | |
| * of the XPath substring-before() function | |
| * | |
| * @param s1 the containing string | |
| * @param s2 the contained string | |
| * @return the part of s1 that precedes the first occurrence of s2 | |
| */ | |
| UnicodeString substringBefore(UnicodeString s1, UnicodeString s2); | |
| /** | |
| * Return the part of a string after a given substring, according to the rules | |
| * of the XPath substring-after() function | |
| * | |
| * @param s1 the containing string | |
| * @param s2 the contained string | |
| * @return the part of s1 that follows the first occurrence of s2 | |
| */ | |
| UnicodeString substringAfter(UnicodeString s1, UnicodeString s2); | |
| } | |