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:
java.lang.Comparable<UnicodeString>,AtomicMatchKey
public class CompressedWhitespace extends WhitespaceString
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 Constructor Description CompressedWhitespace(long compressedValue)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intcodePointAt(long index)Get the code point at a given position in the stringIntIteratorcodePoints()Get an iterator over the code points present in the string.static UnicodeStringcompressWS(char[] in, int start, int len)booleanequals(java.lang.Object obj)Indicates whether some other object is "equal to" this one.longgetCompressedValue()inthashCode()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 charactersUnicodeStringuncompress()Uncompress 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 characters-
Methods inherited from class net.sf.saxon.str.WhitespaceString
getWidth, indexOf, substring, toString
-
Methods inherited from class net.sf.saxon.str.UnicodeString
asAtomic, checkSubstringBounds, compareTo, concat, economize, estimatedLength, hasSubstring, indexOf, indexOf, indexWhere, isEmpty, prefix, requireInt, substring, tidy, verifyCharacters
-
-
-
-
Method Detail
-
compressWS
public static UnicodeString compressWS(char[] in, int start, int len)
-
uncompress
public UnicodeString uncompress()
Uncompress the whitespace to a (normal) UnicodeString- Specified by:
uncompressin classWhitespaceString- Returns:
- the uncompressed value
-
uncompress
public static UnicodeString uncompress(long value)
-
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:
java.lang.IndexOutOfBoundsException- if the index is out of range
-
codePoints
public IntIterator 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
public boolean equals(java.lang.Object obj)
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
public void write(UnicodeWriter writer) throws java.io.IOException
Write the value to a Writer- Specified by:
writein classWhitespaceString- Parameters:
writer- the writer to write to- Throws:
java.io.IOException- if an error occurs downstream
-
writeEscape
public void writeEscape(boolean[] specialChars, UnicodeWriter writer) throws java.io.IOExceptionWrite 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:
java.io.IOException- if an error occurs downstream
-
-