Package net.sf.saxon.str
Class LargeTextBuffer
- java.lang.Object
-
- net.sf.saxon.str.LargeTextBuffer
-
public final class LargeTextBuffer extends java.lang.Object
The segments (other than the last) have a fixed size of 65536 codepoints, which may use one byte per codepoint, two bytes per codepoint, or three bytes per codepoint, depending on the largest codepoint present in the segment.This is more efficient than a buffer backed by a contiguous array of characters in cases where the size is likely to grow very large, and where substring operations are rare. As used within the TinyTree, extraction of the string value of a node requires character copying only in the case where the value crosses segment boundaries.
-
-
Constructor Summary
Constructors Constructor Description LargeTextBuffer()
Create an empty LargeTextBuffer with default space allocation
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
appendUnicodeString(UnicodeString chars)
Append a string to the contents of the LargeTextBuffervoid
close()
int
length()
void
setLength(int newLength)
Set the length.UnicodeString
substring(int start, int end)
Returns a new character sequence that is a subsequence of this sequence.
-
-
-
Method Detail
-
appendUnicodeString
public void appendUnicodeString(UnicodeString chars)
Append a string to the contents of the LargeTextBuffer- Parameters:
chars
- the string to be added
-
substring
public UnicodeString substring(int start, int end)
Returns a new character sequence that is a subsequence of this sequence. The subsequence starts with the character at the specified index and ends with the character at index end - 1. The length of the returned sequence is end - start, so if start == end then an empty sequence is returned.- Parameters:
start
- the start index, inclusive (codepoints, not bytes)end
- the end index, exclusive (codepoints, not bytes)- Returns:
- the specified subsequence
- Throws:
java.lang.IndexOutOfBoundsException
- if start or end are negative, if end is greater than length(), or if start is greater than end
-
close
public void close()
-
length
public int length()
-
setLength
public void setLength(int newLength)
Set the length. If this exceeds the current length, this method is a no-op. If this is less than the current length, characters beyond the specified point are deleted.- Parameters:
newLength
- the new length
-
-