public class IndentWhitespace extends WhitespaceString
CompressedWhitespace
class, and is specifically used for constructing indentation and passing
it to a UTF8Writer
, which recognizes it specially. Unlike CompressedWhitespace
, it can't
handle arbitrary whitespace strings, only those consisting of newlines followed by spaces.Modifier and Type | Method and Description |
---|---|
int |
codePointAt(long index)
Returns the codepoint value at the specified index.
|
IntIterator |
codePoints()
Get an iterator over the code points present in the string.
|
int |
getNewlines()
Get the number of newlines at the start
|
int |
getSpaces()
Get the number of spaces following the newlines
|
long |
length()
Get the length of the string
|
int |
length32()
Get the length of the string, provided it is less than 2^31 characters
|
static IndentWhitespace |
of(int newlines,
int spaces)
Create an IndentWhitespace object
|
java.lang.String |
toString()
Returns a string representation of the object.
|
UnicodeString |
uncompress()
Uncompress the whitespace to a (normal) UnicodeString
|
void |
write(UnicodeWriter writer)
Write the value to a UnicodeWriter
|
void |
writeEscape(boolean[] specialChars,
UnicodeWriter writer)
Write the value to a Writer with escaping of special characters
|
getWidth, indexOf, substring
asAtomic, checkSubstringBounds, compareTo, concat, economize, equals, estimatedLength, hashCode, hasSubstring, indexOf, indexOf, indexWhere, isEmpty, prefix, requireInt, substring, tidy, verifyCharacters
public static IndentWhitespace of(int newlines, int spaces)
newlines
- the number of newlines at the startspaces
- the number of spaces following the newlinespublic UnicodeString uncompress()
uncompress
in class WhitespaceString
public long length()
UnicodeString
length
in class UnicodeString
public int length32()
UnicodeString
length32
in class UnicodeString
int
public int getNewlines()
public int getSpaces()
public int codePointAt(long index)
codePointAt
in class UnicodeString
index
- the index of the codepoint value to be returnedjava.lang.IndexOutOfBoundsException
- if the index argument is negative or not less than
length()public IntIterator codePoints()
UnicodeString
codePoints
in class UnicodeString
public java.lang.String toString()
toString
in class WhitespaceString
public void write(UnicodeWriter writer) throws java.io.IOException
write
in class WhitespaceString
writer
- the writer to write tojava.io.IOException
- if an error occurs downstreampublic void writeEscape(boolean[] specialChars, UnicodeWriter writer) throws java.io.IOException
writeEscape
in class WhitespaceString
specialChars
- identifies which characters are considered specialwriter
- the writer to write tojava.io.IOException
- if an error occurs downstreamCopyright (c) 2004-2022 Saxonica Limited. All rights reserved.