Class UnicodeChar
java.lang.Object
net.sf.saxon.str.UnicodeString
net.sf.saxon.str.UnicodeChar
- All Implemented Interfaces:
Comparable<UnicodeString>, AtomicMatchKey
A UnicodeString containing a single codepoint
-
Constructor Summary
Constructors -
Method Summary
Modifier 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.(package private) voidcopy16bit(char[] target, int offset) Copy this string, as a sequence of 16-bit characters, to a specified array(package private) voidcopy24bit(byte[] target, int offset) Copy this string, as a sequence of 24-bit characters, to a specified array(package private) voidcopy32bit(int[] target, int offset) Copy this string, as a sequence of 32-bit codepoints, to a specified array(package private) voidcopy8bit(byte[] target, int offset) Copy this string, as a sequence of 8-bit characters, to a specified arrayintGet the codepoint represented by thisUnicodeCharintgetWidth()Get the number of bits needed to hold all the characters in this stringlongindexOf(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 the specified codepoint, starting the search at a given position in the stringlonglength()Get the length of the stringsubstring(long start, long end) Get a substring of this codepoint sequence, with a given start and end positiontoString()Methods inherited from class UnicodeString
asAtomic, checkSubstringBounds, compareTo, concat, economize, equals, estimatedLength, hashCode, hasSubstring, indexOf, indexOf, isEmpty, length32, prefix, requireInt, requireNonNegativeInt, substring, tidy, verifyCharacters
-
Constructor Details
-
UnicodeChar
public UnicodeChar(int codepoint)
-
-
Method Details
-
codePoints
Get an iterator over the code points present in the string. Note that this method is always available, whether or not theUnicodeStringhas been prepared for codePoint access.- Specified by:
codePointsin classUnicodeString- Returns:
- an iterator that delivers the individual code points
-
getCodepoint
public int getCodepoint()Get the codepoint represented by thisUnicodeChar- Returns:
- the relevant codepoint
-
length
public long length()Get the length of the string- Specified by:
lengthin classUnicodeString- Returns:
- the number of code points in the string
-
getWidth
public int getWidth()Get the number of bits needed to hold all the characters in this string- Specified by:
getWidthin classUnicodeString- Returns:
- 7 for ascii characters, 8 for latin-1, 16 for BMP, 24 for general Unicode.
-
indexOf
public 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 classUnicodeString- Parameters:
codePoint- the sought codePointfrom- the position from which the search should start (0-based)- Returns:
- the position (0-based) of the first occurrence found, or -1 if not found
-
codePointAt
public int codePointAt(long index) Get the code point at a given position in the string- Specified by:
codePointAtin classUnicodeString- Parameters:
index- the given position (0-based)- Returns:
- the code point at the given position
- Throws:
IndexOutOfBoundsException- if index is not zero
-
substring
Get a substring of this codepoint sequence, with a given start and end position- Specified by:
substringin 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
- Throws:
IndexOutOfBoundsException- if the start/end positions are out of range
-
indexWhere
Get the position of the first occurrence of the specified codepoint, starting the search at a given position in the string- Specified by:
indexWherein 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
-
toString
-
copy8bit
void copy8bit(byte[] target, int offset) Description copied from class:UnicodeStringCopy this string, as a sequence of 8-bit characters, to a specified array- Overrides:
copy8bitin classUnicodeString- Parameters:
target- the target array: the caller must ensure there is sufficient capacityoffset- the position in the target array
-
copy16bit
void copy16bit(char[] target, int offset) Description copied from class:UnicodeStringCopy this string, as a sequence of 16-bit characters, to a specified array- Overrides:
copy16bitin classUnicodeString- Parameters:
target- the target array: the caller must ensure there is sufficient capacityoffset- the position in the target array
-
copy24bit
void copy24bit(byte[] target, int offset) Description copied from class:UnicodeStringCopy this string, as a sequence of 24-bit characters, to a specified array- Overrides:
copy24bitin classUnicodeString- Parameters:
target- the target array: the caller must ensure there is sufficient capacityoffset- the position in the target array as a byte offset (that is, the character offset times 3)
-
copy32bit
void copy32bit(int[] target, int offset) Description copied from class:UnicodeStringCopy this string, as a sequence of 32-bit codepoints, to a specified array- Overrides:
copy32bitin classUnicodeString- Parameters:
target- the target array: the caller must ensure there is sufficient capacityoffset- the position in the target array as a codepoint offset
-