public final class LargeStringBuffer extends java.lang.Object implements AppendableCharSequence
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 and Description |
---|
LargeStringBuffer()
Create an empty LargeStringBuffer with default space allocation
|
Modifier and Type | Method and Description |
---|---|
void |
append(java.lang.CharSequence s)
Append a CharSequence to this LargeStringBuffer
|
char |
charAt(int index)
Returns the character at the specified index.
|
boolean |
equals(java.lang.Object other)
Compare equality
|
int |
hashCode()
Generate a hash code
|
int |
length()
Returns the length of this character sequence.
|
void |
setLength(int length)
Set the length.
|
java.lang.CharSequence |
subSequence(int start,
int end)
Returns a new character sequence that is a subsequence of this sequence.
|
java.lang.String |
substring(int start,
int end)
Returns a new character sequence that is a subsequence of this sequence.
|
java.lang.String |
toString()
Convert to a string
|
void |
write(java.io.Writer writer)
Write the value to a writer
|
public LargeStringBuffer()
public void append(java.lang.CharSequence s)
append
in interface AppendableCharSequence
s
- the data to be appendedpublic int length()
length
in interface java.lang.CharSequence
public void setLength(int length)
setLength
in interface AppendableCharSequence
length
- the new lengthpublic char charAt(int index)
charAt
in interface java.lang.CharSequence
index
- the index of the character to be returnedjava.lang.IndexOutOfBoundsException
- if the index argument is negative or not less than
length()public java.lang.CharSequence subSequence(int start, int end)
subSequence
in interface java.lang.CharSequence
start
- the start index, inclusiveend
- the end index, exclusivejava.lang.IndexOutOfBoundsException
- if start or end are negative,
if end is greater than length(),
or if start is greater than endpublic java.lang.String toString()
toString
in interface java.lang.CharSequence
toString
in class java.lang.Object
public boolean equals(java.lang.Object other)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String substring(int start, int end)
start
- index of the first character to be includedend
- index of the character after the last one to be includedpublic void write(java.io.Writer writer) throws java.io.IOException
writer
- the writer to which the value is to be writtenjava.io.IOException
- if an error occurs downstreamCopyright (c) 2004-2020 Saxonica Limited. All rights reserved.