public class BMPString extends UnicodeString
UnicodeString
that wraps a Java string which is known to contain
no surrogates. That is, all the characters in the string are in the Basic Multilingual
Plane (their codepoints are in the range 0-65535).Modifier | Constructor and Description |
---|---|
protected |
BMPString(java.lang.String baseString)
Protected constructor
|
Modifier and Type | Method and Description |
---|---|
int |
codePointAt(long index)
Get the code point at a given position in the string
|
IntIterator |
codePoints()
Get an iterator over the code points present in the string.
|
int |
compareTo(UnicodeString other)
Compare this string to another using codepoint comparison
|
UnicodeString |
concat(UnicodeString other)
Concatenate with another string, returning a new string
|
boolean |
equals(java.lang.Object obj) |
int |
getWidth()
Get the number of bits needed to hold all the characters in this string
|
int |
hashCode()
Compute a hashCode.
|
long |
indexOf(int codePoint)
Get the position of the first occurrence of the specified codepoint,
starting the search at the beginning
|
long |
indexOf(int codePoint,
long from)
Get the position of the first occurrence of the specified codepoint,
starting the search at a given position in the string
|
long |
indexWhere(java.util.function.IntPredicate predicate,
long from)
Get the position of the first occurrence of the specified codepoint,
starting the search at a given position in the string
|
boolean |
isEmpty()
Ask whether the string is empty
|
long |
length()
Get the length of the string
|
static UnicodeString |
of(java.lang.String base)
Wrap a String, which must contain no surrogates
|
UnicodeString |
substring(long start,
long end)
Get a substring of this string, with a given start and end position
|
java.lang.String |
toString() |
asAtomic, checkSubstringBounds, economize, estimatedLength, hasSubstring, indexOf, length32, prefix, requireInt, substring, tidy, verifyCharacters
protected BMPString(java.lang.String baseString)
baseString
- the string to be wrapped: the caller is responsible for ensuring this
contains no surrogatespublic static UnicodeString of(java.lang.String base)
base
- the string. The caller warrants that this string contains no surrogates;
this condition is checked only if Java assertions are enabled.public long length()
UnicodeString
length
in class UnicodeString
public boolean isEmpty()
UnicodeString
isEmpty
in class UnicodeString
public int getWidth()
UnicodeString
getWidth
in class UnicodeString
public IntIterator codePoints()
UnicodeString
codePoints
in class UnicodeString
public long indexOf(int codePoint)
UnicodeString
indexOf
in class UnicodeString
codePoint
- the sought codePointpublic long indexOf(int codePoint, long from)
UnicodeString
indexOf
in class UnicodeString
codePoint
- the sought codePointfrom
- the position from which the search should start (0-based)public long indexWhere(java.util.function.IntPredicate predicate, long from)
indexWhere
in class UnicodeString
predicate
- condition that the codepoint must satisfyfrom
- the position from which the search should start (0-based)java.lang.UnsupportedOperationException
- if the UnicodeString
has not been prepared
for codePoint accesspublic int codePointAt(long index)
UnicodeString
codePointAt
in class UnicodeString
index
- the given position (0-based)public UnicodeString substring(long start, long end)
UnicodeString
substring
in class UnicodeString
start
- the start position (0-based): that is, the position of the first
code point to be includedend
- the end position (0-based): specifically, the position of the first
code point not to be includedpublic UnicodeString concat(UnicodeString other)
UnicodeString
concat
in class UnicodeString
other
- the string to be appendedpublic int compareTo(UnicodeString other)
UnicodeString
compareTo
in interface java.lang.Comparable<UnicodeString>
compareTo
in class UnicodeString
other
- the other stringpublic boolean equals(java.lang.Object obj)
equals
in class UnicodeString
public int hashCode()
UnicodeString
UnicodeString
use compatible hash codes and the
hashing algorithm is therefore identical to that for java.lang.String
. This means
that for strings containing Astral characters, the hash code needs to be computed by decomposing
an Astral character into a surrogate pair.hashCode
in class UnicodeString
public java.lang.String toString()
toString
in class java.lang.Object
Copyright (c) 2004-2022 Saxonica Limited. All rights reserved.