| 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 | /** |
| 11 | * A precondition that must be true if a regular expression is to match |
| 12 | */ |
| 13 | public class RegexPrecondition { |
| 14 | |
| 15 | public Operation operation; |
| 16 | public int fixedPosition; |
| 17 | public int minPosition; |
| 18 | |
| 19 | /** |
| 20 | * Create a precondition for a regular expression to be true |
| 21 | * @param op the operation to be performed. The precondition is true if |
| 22 | * op.iterateMatches(p).hasNext() is true at some position p, |
| 23 | * subject to the constraints in the other two arguments |
| 24 | * @param fixedPos indicates that the operation only needs to be tested |
| 25 | * at this position. Used when all previous parts of the |
| 26 | * regular expression are fixed length, and the regex |
| 27 | * starts with a "^" anchor. Defaults to -1, indicating |
| 28 | * that the operation needs to be tested at every position. |
| 29 | * @param minPos indicates that the operation needs to be tested at this |
| 30 | * position and all subsequent positions within the input |
| 31 | * string (until a match is found or the end of the string |
| 32 | * is reached). Defaults to 0. |
| 33 | */ |
| 34 | |
| 35 | public RegexPrecondition(Operation op, int fixedPos, int minPos) { |
| 36 | this.operation = op; |
| 37 | this.fixedPosition = fixedPos; |
| 38 | this.minPosition = minPos; |
| 39 | } |
| 40 | } |
| 41 |