| 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 | |
| 9 | package net.sf.saxon.regex.charclass; |
| 10 | |
| 11 | import net.sf.saxon.z.IntSet; |
| 12 | |
| 13 | import java.util.function.IntPredicate; |
| 14 | |
| 15 | /** |
| 16 | * A character class represents a set of characters for regex matching purposes. It extends IntPredicate, |
| 17 | * so there is a mechanism for testing whether a particular codepoint is a member of the class. In |
| 18 | * addition it provides a method for testing whether two classes are disjoint, which is used when |
| 19 | * optimizing regular expressions. |
| 20 | */ |
| 21 | |
| 22 | public interface CharacterClass extends IntPredicate { |
| 23 | |
| 24 | /** |
| 25 | * Ask whether this character class is known to be disjoint with another character class |
| 26 | * (that is, the two classes have no characters in common). If in doubt, return false. |
| 27 | * @param other the other character class |
| 28 | * @return true if the character classes are known to be disjoint; false if there may |
| 29 | * be characters in common between the two classes |
| 30 | */ |
| 31 | |
| 32 | boolean isDisjoint(CharacterClass other); |
| 33 | |
| 34 | /** |
| 35 | * Get the set of matching characters if available. If not available, return null |
| 36 | */ |
| 37 | |
| 38 | IntSet getIntSet(); |
| 39 | } |