Package net.sf.saxon.str
Class CompressedWhitespace
java.lang.Object
net.sf.saxon.str.UnicodeString
net.sf.saxon.str.WhitespaceString
net.sf.saxon.str.CompressedWhitespace
- All Implemented Interfaces:
Comparable<UnicodeString>,AtomicMatchKey
This class provides a compressed representation of a sequence of whitespace characters. The representation
is a sequence of bytes: in each byte the top two bits indicate which whitespace character is used
(x9, xA, xD, or x20) and the bottom six bits indicate the number of such characters. A zero byte is a filler.
We don't compress the sequence if it would occupy more than 8 bytes, because that's the space we've got available
in the TinyTree arrays.
-
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.static UnicodeStringcompressWS(char[] in, int start, int len) booleanIndicates whether some other object is "equal to" this one.longinthashCode()Compute a hashCode.longlength()Get the length of the stringstatic intlength(long value) intlength32()Get the length of the string, provided it is less than 2^31 charactersUncompress the whitespace to a (normal) UnicodeStringstatic UnicodeStringuncompress(long value) voidwrite(UnicodeWriter writer) Write the value to a WritervoidwriteEscape(boolean[] specialChars, UnicodeWriter writer) Write the value to a Writer with escaping of special charactersMethods inherited from class net.sf.saxon.str.WhitespaceString
getWidth, indexOf, indexWhere, substring, toStringMethods inherited from class net.sf.saxon.str.UnicodeString
asAtomic, checkSubstringBounds, compareTo, concat, economize, estimatedLength, hasSubstring, indexOf, indexOf, isEmpty, prefix, requireInt, requireNonNegativeInt, substring, tidy, verifyCharacters
-
Constructor Details
-
CompressedWhitespace
public CompressedWhitespace(long compressedValue)
-
-
Method Details
-
compressWS
-
uncompress
Uncompress the whitespace to a (normal) UnicodeString- Specified by:
uncompressin classWhitespaceString- Returns:
- the uncompressed value
-
uncompress
-
getCompressedValue
public long getCompressedValue() -
length
public long length()Description copied from class:UnicodeStringGet the length of the string- Specified by:
lengthin classUnicodeString- Returns:
- the number of code points in the string
-
length32
public int length32()Description copied from class:UnicodeStringGet the length of the string, provided it is less than 2^31 characters- Overrides:
length32in classUnicodeString- Returns:
- the length of the string if it fits within a Java
int
-
length
public static int length(long value) -
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 the index is out of range
-
codePoints
Description copied from class:UnicodeStringGet an iterator over the code points present in the string.- Specified by:
codePointsin classUnicodeString- Returns:
- an iterator that delivers the individual code points
-
equals
Indicates whether some other object is "equal to" this one.- Overrides:
equalsin classUnicodeString
-
hashCode
public 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 classUnicodeString- Returns:
- the hash code
-
write
Write the value to a Writer- Specified by:
writein classWhitespaceString- Parameters:
writer- the writer to write to- Throws:
IOException- if an error occurs downstream
-
writeEscape
Write the value to a Writer with escaping of special characters- Specified by:
writeEscapein classWhitespaceString- Parameters:
specialChars- identifies which characters are considered specialwriter- the writer to write to- Throws:
IOException- if an error occurs downstream
-