Package net.sf.saxon.str
Class StringView
java.lang.Object
net.sf.saxon.str.UnicodeString
net.sf.saxon.str.StringView
- All Implemented Interfaces:
- Comparable<UnicodeString>,- AtomicMatchKey
An implementation of the UnicodeString interface that wraps an ordinary Java string.
- 
Method SummaryModifier and TypeMethodDescriptionintcodePointAt(long index) Get the code point at a given position in the stringGet an iterator over the code points present in the string.intcompareTo(UnicodeString other) Compare this string to another using codepoint comparisonconcat(UnicodeString other) Concatenate with another string, returning a new stringbooleanlongGet the estimated length of the string, suitable for space allocation.intgetWidth()Get the number of bits needed to hold all the characters in this stringinthashCode()Compute a hashCode.longindexOf(int codePoint, long from) Get the position of the first occurrence of the specified codepoint, starting the search at a given position in the stringlongindexWhere(IntPredicate predicate, long from) Get the position of the first occurrence of a codepoint that matches a supplied predicate, starting the search at a given position in the stringbooleanisEmpty()Ask whether the string is emptylonglength()Get the length of the stringstatic UnicodeStringsubstring(long start, long end) Get a substring of this codepoint sequence, with a given start and end positiontidy()Ensure that the implementation is capable of counting codepoints in the string.static UnicodeStringtoString()static UnicodeStringMethods inherited from class net.sf.saxon.str.UnicodeStringasAtomic, checkSubstringBounds, hasSubstring, indexOf, indexOf, length32, prefix, requireInt, requireNonNegativeInt, substring, verifyCharacters
- 
Method Details- 
of
- 
wrap
- 
tidy
- 
tidyDescription copied from class:UnicodeStringEnsure that the implementation is capable of counting codepoints in the string. This is normally a null operation, but it may cause internal reorganisation.- Overrides:
- tidyin class- UnicodeString
- Returns:
- this UnicodeString, or another that represents the same sequence of characters.
 
- 
isEmptypublic boolean isEmpty()Description copied from class:UnicodeStringAsk whether the string is empty- Overrides:
- isEmptyin class- UnicodeString
- Returns:
- true if the length of the string is zero
 
- 
estimatedLengthpublic long estimatedLength()Description copied from class:UnicodeStringGet the estimated length of the string, suitable for space allocation.- Overrides:
- estimatedLengthin class- UnicodeString
- Returns:
- for a UnicodeString, the actual length of the string in codepoints
 
- 
lengthpublic long length()Get the length of the string- Specified by:
- lengthin class- UnicodeString
- Returns:
- the number of code points in the string
 
- 
getWidthpublic int getWidth()Get the number of bits needed to hold all the characters in this string- Specified by:
- getWidthin class- UnicodeString
- Returns:
- 7 for ascii characters, 8 for latin-1, 16 for BMP, 24 for general Unicode.
 
- 
indexOfpublic 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- Specified by:
- indexOfin class- UnicodeString
- Parameters:
- codePoint- the sought codepoint
- from- 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.
- Returns:
- the position (zero-based) of the first occurrence found, or -1 if not found
 
- 
indexWhereDescription copied from class:UnicodeStringGet the position of the first occurrence of a codepoint that matches a supplied predicate, starting the search at a given position in the string- Specified by:
- indexWherein class- UnicodeString
- Parameters:
- predicate- condition that the codepoint must satisfy
- from- the position from which the search should start (0-based). A negative value is treated as zero. A position beyond the end of the string results in a return value of -1 (meaning not found).
- Returns:
- the position (0-based) of the first codepoint to match the predicate, or -1 if not found
 
- 
codePointAtpublic int codePointAt(long index) Get the code point at a given position in the string- Specified by:
- codePointAtin class- UnicodeString
- Parameters:
- index- the given position (0-based)
- Returns:
- the code point at the given position
- Throws:
- IndexOutOfBoundsException- if the index is out of range
 
- 
substringGet a substring of this codepoint sequence, with a given start and end position- Specified by:
- substringin class- UnicodeString
- Parameters:
- start- the start position (0-based): that is, the position of the first code point to be included
- end- the end position (0-based): specifically, the position of the first code point not to be included
- Returns:
- the requested substring
- Throws:
- UnsupportedOperationException- if the- UnicodeStringhas not been prepared for codePoint access
 
- 
codePointsDescription copied from class:UnicodeStringGet an iterator over the code points present in the string.- Specified by:
- codePointsin class- UnicodeString
- Returns:
- an iterator that delivers the individual code points
 
- 
concatDescription copied from class:UnicodeStringConcatenate with another string, returning a new string- Overrides:
- concatin class- UnicodeString
- Parameters:
- other- the string to be appended
- Returns:
- the result of concatenating this string followed by the other
 
- 
compareToDescription copied from class:UnicodeStringCompare this string to another using codepoint comparison- Specified by:
- compareToin interface- Comparable<UnicodeString>
- Overrides:
- compareToin class- UnicodeString
- Parameters:
- other- the other string
- Returns:
- -1 if this string comes first, 0 if they are equal, +1 if the other string comes first
 
- 
equals- Overrides:
- equalsin class- UnicodeString
 
- 
hashCodepublic int hashCode()Description copied from class:UnicodeStringCompute a hashCode. All implementations ofUnicodeStringuse compatible hash codes and the hashing algorithm is therefore identical to that forjava.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.- Overrides:
- hashCodein class- UnicodeString
- Returns:
- the hash code
 
- 
economize- Overrides:
- economizein class- UnicodeString
 
- 
toString
 
-