| 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.IntEmptySet; |
| 12 | import net.sf.saxon.z.IntSet; |
| 13 | |
| 14 | /** |
| 15 | * A character class represents a set of characters for regex matching purposes. The empty |
| 16 | * character class matches no characters |
| 17 | */ |
| 18 | |
| 19 | public class EmptyCharacterClass implements CharacterClass { |
| 20 | |
| 21 | private final static EmptyCharacterClass THE_INSTANCE = new EmptyCharacterClass(); |
| 22 | |
| 23 | private final static InverseCharacterClass COMPLEMENT = new InverseCharacterClass(THE_INSTANCE); |
| 24 | |
| 25 | public static EmptyCharacterClass getInstance() { |
| 26 | return THE_INSTANCE; |
| 27 | } |
| 28 | |
| 29 | public static CharacterClass getComplement() { |
| 30 | return COMPLEMENT; |
| 31 | } |
| 32 | |
| 33 | private EmptyCharacterClass() { |
| 34 | } |
| 35 | |
| 36 | public boolean test(int value) { |
| 37 | return false; |
| 38 | } |
| 39 | |
| 40 | public boolean isDisjoint(CharacterClass other) { |
| 41 | // the empty set is disjoint with every other set including itself, in the sense that the |
| 42 | // intersection of the two sets is empty |
| 43 | return true; |
| 44 | } |
| 45 | |
| 46 | @Override |
| 47 | public IntSet getIntSet() { |
| 48 | return IntEmptySet.getInstance(); |
| 49 | } |
| 50 | } |