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 TypeMethodDescriptionint
codePointAt
(long index) Get the code point at a given position in the stringGet an iterator over the code points present in the string.static UnicodeString
compressWS
(char[] in, int start, int len) boolean
Indicates whether some other object is "equal to" this one.long
int
hashCode()
Compute a hashCode.long
length()
Get the length of the stringstatic int
length
(long value) int
length32()
Get the length of the string, provided it is less than 2^31 charactersUncompress the whitespace to a (normal) UnicodeStringstatic UnicodeString
uncompress
(long value) void
write
(UnicodeWriter writer) Write the value to a Writervoid
writeEscape
(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, toString
Methods 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:
uncompress
in classWhitespaceString
- Returns:
- the uncompressed value
-
uncompress
-
getCompressedValue
public long getCompressedValue() -
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
-
length32
public int length32()Description copied from class:UnicodeString
Get the length of the string, provided it is less than 2^31 characters- Overrides:
length32
in 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:
codePointAt
in 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: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
-
equals
Indicates whether some other object is "equal to" this one.- Overrides:
equals
in classUnicodeString
-
hashCode
public int hashCode()Description copied from class:UnicodeString
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
-
write
Write the value to a Writer- Specified by:
write
in 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:
writeEscape
in classWhitespaceString
- Parameters:
specialChars
- identifies which characters are considered specialwriter
- the writer to write to- Throws:
IOException
- if an error occurs downstream
-