Package net.sf.saxon.str
Class TwineBuilder
java.lang.Object
net.sf.saxon.str.TwineBuilder
A builder class for unicode strings. This is a simpler and more efficient
alternative to
UnicodeBuilder for use when small strings (especially
strings consisting exclusively of 8-bit characters) are constructed one
character at a time.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract TwineBuilderappend(int codepoint) Append a codepoint to the Unicode stringfinal TwineBuilderappend(CharSequence chars) Append a string or other CharSequenceappend(UnicodeString chars) Append a unicode stringbooleanisEmpty()Ask if the buffer is emptyabstract intlength()Get the length, in codepointsstatic TwineBuildermake(int initialSize) Create a builder for strings with an estimate of the string sizefinal StringtoString()Get the completed result as a Java stringabstract UnicodeStringGet the completed Unicode string
-
Constructor Details
-
TwineBuilder
public TwineBuilder()
-
-
Method Details
-
make
Create a builder for strings with an estimate of the string size- Parameters:
initialSize- the expected size of the string, once built- Returns:
- a new builder
-
append
Append a codepoint to the Unicode string- Parameters:
codepoint- the codepoint to be appended- Returns:
- a replacement builder. NOTE: although this will often be the original builder, it will sometimes be a new one, so it is important to use the returned builder for future calls.
-
append
Append a string or other CharSequence- Parameters:
chars- the string to be appended- Returns:
- the new TwineBuilder to be used for subsequent calls
-
append
Append a unicode string- Parameters:
chars- the string to be appended- Returns:
- the new TwineBuilder to be used for subsequent calls
-
length
public abstract int length()Get the length, in codepoints- Returns:
- the length in codepoints
-
isEmpty
public boolean isEmpty()Ask if the buffer is empty- Returns:
- true if it is empty
-
toUnicodeString
Get the completed Unicode string- Returns:
- the unicode string that has been built.
-
toString
Get the completed result as a Java string
-