public class StringView extends UnicodeString
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
|
UnicodeString |
economize() |
boolean |
equals(java.lang.Object obj) |
long |
estimatedLength()
Get the estimated length of the string, suitable for space allocation.
|
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,
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) |
UnicodeString |
substring(long start,
long end)
Get a substring of this codepoint sequence, with a given start and end position
|
UnicodeString |
tidy()
Ensure that the implementation is capable of counting codepoints in the string.
|
static UnicodeString |
tidy(java.lang.String base) |
java.lang.String |
toString() |
static UnicodeString |
wrap(java.lang.String base) |
asAtomic, checkSubstringBounds, hasSubstring, indexOf, indexOf, indexWhere, length32, prefix, requireInt, substring, verifyCharacters
public static UnicodeString of(java.lang.String base)
public static UnicodeString wrap(java.lang.String base)
public static UnicodeString tidy(java.lang.String base)
public UnicodeString tidy()
UnicodeString
tidy
in class UnicodeString
UnicodeString
, or another that represents the same sequence
of characters.public boolean isEmpty()
UnicodeString
isEmpty
in class UnicodeString
public long estimatedLength()
UnicodeString
estimatedLength
in class UnicodeString
UnicodeString
, the actual length of the string in codepointspublic long length()
length
in class UnicodeString
public int getWidth()
getWidth
in class UnicodeString
public long indexOf(int codePoint, long from)
indexOf
in class UnicodeString
codePoint
- the sought codepointfrom
- the position from which the search should start (0-based). There
is no restriction on the value. Negative values are treated as zero;
values greater than or equal to length() return -1.public int codePointAt(long index)
codePointAt
in class UnicodeString
index
- the given position (0-based)java.lang.IndexOutOfBoundsException
- if the index is out of rangepublic UnicodeString substring(long start, long end)
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 includedjava.lang.UnsupportedOperationException
- if the UnicodeString
has not been prepared
for codePoint accesspublic IntIterator codePoints()
UnicodeString
codePoints
in class UnicodeString
public 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 UnicodeString economize()
economize
in class UnicodeString
public java.lang.String toString()
toString
in class java.lang.Object
Copyright (c) 2004-2022 Saxonica Limited. All rights reserved.