All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.sf.saxon.lib.SubstringMatcher Maven / Gradle / Ivy

There is a newer version: 10.5
Show newest version
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2013 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;

/**
 * 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
     */

    public boolean contains(String s1, String 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
     */

    public boolean startsWith(String s1, String 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
     */

    public boolean endsWith(String s1, String 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
     */

    public String substringBefore(String s1, String 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
     */

    public String substringAfter(String s1, String s2);

}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy