Package net.sf.saxon.str
Class Slice24
- java.lang.Object
-
- net.sf.saxon.str.UnicodeString
-
- net.sf.saxon.str.Slice24
-
- All Implemented Interfaces:
java.lang.Comparable<UnicodeString>
,AtomicMatchKey
public class Slice24 extends UnicodeString
A Unicode string consisting of 24-bit characters, implemented as a range of an underlying byte array holding three bytes per codepoint
-
-
Constructor Summary
Constructors Constructor Description Slice24(byte[] bytes, int start, int end)
Create a slice of an underlying byte array
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
codePointAt(long index)
Get the code point at a given position in the stringIntIterator
codePoints()
Get an iterator over the code points present in the string.int
getWidth()
Get the number of bits needed to hold all the characters in this stringint
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 stringlong
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 stringlong
length()
Get the length of the stringUnicodeString
substring(long start, long end)
Get a substring of this string, with a given start and end positionjava.lang.String
toString()
Display as a string.-
Methods inherited from class net.sf.saxon.str.UnicodeString
asAtomic, checkSubstringBounds, compareTo, concat, economize, equals, estimatedLength, hasSubstring, indexOf, indexOf, isEmpty, length32, prefix, requireInt, requireNonNegativeInt, substring, tidy, verifyCharacters
-
-
-
-
Constructor Detail
-
Slice24
public Slice24(byte[] bytes, int start, int end)
Create a slice of an underlying byte array- Parameters:
bytes
- the byte array, containing Unicode codepoints in the range 0-255start
- the codepoint offset of the first character within the byte arrayend
- the codepoint offset of the first excluded character, so the length of the string isend-start
-
-
Method Detail
-
length
public long length()
Description copied from class:UnicodeString
Get the length of the string- Specified by:
length
in classUnicodeString
- Returns:
- the number of code points in the string
-
getWidth
public int getWidth()
Description copied from class:UnicodeString
Get the number of bits needed to hold all the characters in this string- Specified by:
getWidth
in classUnicodeString
- Returns:
- 7 for ascii characters (not used??), 8 for latin-1, 16 for BMP, 24 for general Unicode.
-
indexOf
public long indexOf(int codePoint, long from)
Description copied from class:UnicodeString
Get the position of the first occurrence of the specified codepoint, starting the search at a given position in the string- Specified by:
indexOf
in classUnicodeString
- Parameters:
codePoint
- the sought codePointfrom
- 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 occurrence found, or -1 if not found
-
indexWhere
public 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- Specified by:
indexWhere
in classUnicodeString
- Parameters:
predicate
- condition that the codepoint must satisfyfrom
- the position from which the search should start (0-based)- Returns:
- the position (0-based) of the first codepoint to match the predicate, or -1 if not found
-
codePointAt
public int codePointAt(long index)
Description copied from class:UnicodeString
Get the code point at a given position in the string- Specified by:
codePointAt
in classUnicodeString
- Parameters:
index
- the given position (0-based)- Returns:
- the code point at the given position
-
substring
public UnicodeString substring(long start, long end)
Description copied from class:UnicodeString
Get a substring of this string, with a given start and end position- Specified by:
substring
in classUnicodeString
- Parameters:
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 included- Returns:
- the requested substring
-
codePoints
public IntIterator codePoints()
Description copied from class:UnicodeString
Get an iterator over the code points present in the string.- Specified by:
codePoints
in classUnicodeString
- Returns:
- an iterator that delivers the individual code points
-
hashCode
public int hashCode()
Compute a hashCode. All implementations ofUnicodeString
use 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:
hashCode
in classUnicodeString
- Returns:
- the hash code
-
toString
public java.lang.String toString()
Display as a string.- Overrides:
toString
in classjava.lang.Object
-
-