Debian Codegraph @

net/sf/saxon/regex/charclass/PredicateCharacterClass.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
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. A predicate
17 * character class is one where the determination of membership is established by executing
18 * a function.
19 */
20
21 public class PredicateCharacterClass implements CharacterClass {
22
23 private IntPredicate predicate;
24
25 public PredicateCharacterClass(IntPredicate predicate) {
26 this.predicate = predicate;
27 }
28
29 public boolean test(int value) {
30 return predicate.test(value);
31 }
32
33 public boolean isDisjoint(CharacterClass other) {
34 return other instanceof InverseCharacterClass && other.isDisjoint(this);
35 }
36
37 public IntSet getIntSet() {
38 return null; // Not known
39 }
40 }