Debian Codegraph @

net/sf/saxon/regex/RegularExpression.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.regex;
9
10 import net.sf.saxon.om.SequenceIterator;
11 import net.sf.saxon.trans.XPathException;
12 import net.sf.saxon.value.StringValue;
13
14 /**
15 * This interface represents a compiled regular expression. There are different
16 * implementations for different regex engines
17 */
18 public interface RegularExpression {
19
20 /**
21 * Determine whether the regular expression matches a given string in its entirety
22 *
23 * @param input the string to match
24 * @return true if the string matches, false otherwise
25 */
26
27 boolean matches(CharSequence input);
28
29 /**
30 * Determine whether the regular expression contains a match of a given string
31 *
32 * @param input the string to match
33 * @return true if the string matches, false otherwise
34 */
35
36 boolean containsMatch(CharSequence input);
37
38 /**
39 * Use this regular expression to tokenize an input string.
40 *
41 * @param input the string to be tokenized
42 * @return a SequenceIterator containing the resulting tokens, as objects of type StringValue
43 */
44
45 SequenceIterator<StringValue> tokenize(CharSequence input);
46
47 /**
48 * Use this regular expression to analyze an input string, in support of the XSLT
49 * analyze-string instruction. The resulting RegexIterator provides both the matching and
50 * non-matching substrings, and allows them to be distinguished. It also provides access
51 * to matched subgroups.
52 *
53 * @param input the character string to be analyzed using the regular expression
54 * @return an iterator over matched and unmatched substrings
55 */
56
57 /*@NotNull*/
58 RegexIterator analyze(CharSequence input);
59
60 /**
61 * Replace all substrings of a supplied input string that match the regular expression
62 * with a replacement string.
63 *
64 * @param input the input string on which replacements are to be performed
65 * @param replacement the replacement string in the format of the XPath replace() function
66 * @return the result of performing the replacement
67 * @throws XPathException if the replacement string is invalid
68 */
69
70 CharSequence replace(CharSequence input, CharSequence replacement) throws XPathException;
71
72 /**
73 * Get the flags used at the time the regular expression was compiled.
74 *
75 * @return a string containing the flags
76 */
77
78 String getFlags();
79
80
81 }
82