Debian Codegraph @

net/sf/saxon/regex/EmptyString.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 /**
11 * An implementation of UnicodeString representing a zero-length string. This
12 * is a singleton class with only one instance.
13 */
14 public final class EmptyString extends UnicodeString {
15
16 public final static EmptyString THE_INSTANCE = new EmptyString();
17
18 private EmptyString() {};
19
20
21 public EmptyString uSubstring(int beginIndex, int endIndex) {
22 if (beginIndex == 0 && endIndex == 0) {
23 return this;
24 } else {
25 throw new IndexOutOfBoundsException();
26 }
27 }
28
29 public int uCharAt(int pos) {
30 throw new IndexOutOfBoundsException();
31 }
32
33 public int uIndexOf(int search, int pos) {
34 return -1;
35 }
36
37 public int uLength() {
38 return 0;
39 }
40
41 public boolean isEnd(int pos) {
42 return pos == 0;
43 }
44
45 public String toString() {
46 return "";
47 }
48
49 public int length() {
50 return 0;
51 }
52
53 public char charAt(int index) {
54 throw new IndexOutOfBoundsException();
55 }
56
57 public CharSequence subSequence(int start, int end) {
58 if (start == 0 && end == 0) {
59 return "";
60 } else {
61 throw new IndexOutOfBoundsException();
62 }
63 }
64
65 }