Package net.sf.saxon.str
Class WhitespaceString
- java.lang.Object
-
- net.sf.saxon.str.UnicodeString
-
- net.sf.saxon.str.WhitespaceString
-
- All Implemented Interfaces:
Comparable<UnicodeString>,AtomicMatchKey
- Direct Known Subclasses:
CompressedWhitespace,IndentWhitespace
public abstract class WhitespaceString extends UnicodeString
This abstract class represents a couple of different implementations of strings containing whitespace only.
-
-
Constructor Summary
Constructors Constructor Description WhitespaceString()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description (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 arrayintgetWidth()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 a codepoint that matches a supplied predicate, starting the search at a given position in the stringUnicodeStringsubstring(long start, long end)Returns a newUnicodeStringthat is a subsequence of this sequence.StringtoString()Returns a string representation of the object.abstract UnicodeStringuncompress()Uncompress the whitespace to a (normal) UnicodeStringabstract voidwrite(UnicodeWriter writer)Write the value to a UnicodeWriterabstract voidwriteEscape(boolean[] specialChars, UnicodeWriter writer)Write the value to a Writer with escaping of special characters-
Methods inherited from class net.sf.saxon.str.UnicodeString
asAtomic, checkSubstringBounds, codePointAt, codePoints, compareTo, concat, economize, equals, estimatedLength, hashCode, hasSubstring, indexOf, indexOf, isEmpty, length, length32, prefix, requireInt, requireNonNegativeInt, substring, tidy, verifyCharacters
-
-
-
-
Method Detail
-
uncompress
public abstract UnicodeString uncompress()
Uncompress the whitespace to a (normal) UnicodeString- Returns:
- the uncompressed value
-
getWidth
public int getWidth()
Description copied from class:UnicodeStringGet the number of bits needed to hold all the characters in this string- Specified by:
getWidthin classUnicodeString- Returns:
- 7 for ascii characters (not used??), 8 for latin-1, 16 for BMP, 24 for general Unicode.
-
substring
public UnicodeString substring(long start, long end)
Returns a newUnicodeStringthat is a subsequence of this sequence. The subsequence starts with the codepoint value at the specified index and ends with the codepoint value at indexend - 1. The length (in codepoints) of thereturned sequence isend - start, so ifstart == endthen an empty sequence is returned.- Specified by:
substringin classUnicodeString- Parameters:
start- the start index, inclusiveend- the end index, exclusive- Returns:
- the specified subsequence
- Throws:
IndexOutOfBoundsException- ifstartorendare negative, ifendis greater thanlength(), or ifstartis greater thanend
-
indexOf
public long indexOf(int codePoint, long from)Description copied from class:UnicodeStringGet 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). 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(IntPredicate predicate, long from)
Description 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 classUnicodeString- Parameters:
predicate- condition that the codepoint must satisfyfrom- 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
-
toString
public String toString()
Returns a string representation of the object.
-
write
public abstract void write(UnicodeWriter writer) throws IOException
Write the value to a UnicodeWriter- Parameters:
writer- the writer to write to- Throws:
IOException- if an error occurs downstream
-
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
-
writeEscape
public abstract void writeEscape(boolean[] specialChars, UnicodeWriter writer) throws IOExceptionWrite the value to a Writer with escaping of special characters- Parameters:
specialChars- identifies which characters are considered specialwriter- the writer to write to- Throws:
IOException- if an error occurs downstream
-
-