public final class UnicodeBuilder extends java.lang.Object implements UniStringConsumer, UnicodeWriter
| Constructor and Description |
|---|
UnicodeBuilder()
Create a Unicode builder with an initial allocation of 256 codepoints
|
UnicodeBuilder(int allocate)
Create a Unicode builder with an initial space allocation
|
| Modifier and Type | Method and Description |
|---|---|
UnicodeBuilder |
accept(UnicodeString chars)
Process a supplied string
|
UnicodeBuilder |
append(char ch)
Append a character, which must not be a surrogate.
|
UnicodeBuilder |
append(java.lang.CharSequence str)
Append a Java CharSequence to the content.
|
UnicodeBuilder |
append(int codePoint)
Append a single unicode character to the content
|
UnicodeBuilder |
append(IntIterator codePoints)
Append multiple unicode characters to the content
|
UnicodeBuilder |
append(UnicodeString str)
Append a UnicodeString object to the content.
|
UnicodeBuilder |
appendAll(SequenceIterator iter)
Append the string values of all the items in a sequence, with no separator
|
UnicodeBuilder |
appendLatin(java.lang.String str)
Append a Java string to the content.
|
void |
clear()
Reset the contents of this builder to be empty
|
void |
close()
Complete the writing of characters to the result.
|
static byte[] |
expand(byte[] in,
int start,
int end,
int oldWidth,
int newWidth,
int allocate)
Expand the width of the characters in a byte array
|
static byte[] |
expand1to2(byte[] in,
int start,
int used,
int allocate)
Expand a byte array from 1-byte-per-character to 2-bytes-per-character
|
static byte[] |
expand1to3(byte[] in,
int start,
int used,
int allocate)
Expand a byte array from 1-byte-per-character to 3-bytes-per-character
|
static byte[] |
expand2to3(byte[] in,
int start,
int used,
int allocate)
Expand a byte array from 2-bytes-per-character to 3-bytes-per-character
|
static char[] |
expandBytesToChars(byte[] in,
int start,
int end) |
boolean |
isEmpty()
Ask whether the content of the builder is empty
|
long |
length()
Get the number of codepoints currently in the builder
|
java.lang.String |
toString()
Return a string containing the character content of this builder
|
StringValue |
toStringItem(AtomicType type)
Construct a StringValue whose value is formed from the contents of this builder
|
UnicodeString |
toUnicodeString()
Construct a UnicodeString whose value is formed from the contents of this builder
|
void |
trimToSize() |
void |
write(java.lang.String chars)
Process a supplied string
|
void |
write(UnicodeString chars)
Process a supplied string
|
void |
writeAscii(byte[] content)
Write a supplied string known to consist entirely of ASCII characters,
supplied as a byte array
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitopenflush, writeCodePoint, writeRepeatedAsciipublic UnicodeBuilder()
public UnicodeBuilder(int allocate)
allocate - the initial space allocation, in codepoints (32-bit integers)public UnicodeBuilder append(char ch)
ch - the characterpublic UnicodeBuilder append(int codePoint)
codePoint - the unicode codepoint. The caller is responsible for ensuring that this
is not a surrogatepublic UnicodeBuilder append(IntIterator codePoints)
codePoints - an iterator delivering the codepoints to be added.public UnicodeBuilder appendLatin(java.lang.String str)
str - the string to be appendedpublic UnicodeBuilder appendAll(SequenceIterator iter)
iter - the sequence of itemspublic UnicodeBuilder append(java.lang.CharSequence str)
str - the string to be appendedpublic UnicodeBuilder append(UnicodeString str)
str - the string to be appended. The length is currently restricted to 2^31.public long length()
public boolean isEmpty()
public UnicodeString toUnicodeString()
UnicodeStringpublic StringValue toStringItem(AtomicType type)
type - the required type, for example BuiltInAtomicType.STRING or
BuiltInAtomicType.UNTYPED_ATOMIC. The caller warrants that the value is
a valid instance of this type. No validation or whitespace normalization
is carried outpublic java.lang.String toString()
toString in class java.lang.Objectpublic void clear()
public static byte[] expand1to2(byte[] in,
int start,
int used,
int allocate)
in - the input byte arraystart - the start offset in bytesused - the end offset in bytesallocate - the number of code points to allow for in the output byte arraypublic static char[] expandBytesToChars(byte[] in,
int start,
int end)
public static byte[] expand1to3(byte[] in,
int start,
int used,
int allocate)
in - the input byte arraystart - the start offset in bytesused - the end offset in bytesallocate - the number of code points to allow for in the output byte arraypublic static byte[] expand2to3(byte[] in,
int start,
int used,
int allocate)
in - the input byte arraystart - the start offset in bytesused - the end offset in bytesallocate - the number of code points to allow for in the output byte arraypublic static byte[] expand(byte[] in,
int start,
int end,
int oldWidth,
int newWidth,
int allocate)
in - the input byte arraystart - the start offset in bytesend - the end offset in bytesoldWidth - the width of the characters (number of bytes per character) in the input arraynewWidth - the width of the characters (number of bytes per character) in the output array. If
newWidth LE oldWidth then the input array is copied; the width is never reducedallocate - the number of code points to allow for in the output byte array; if zero (or insufficient)
the output array will have no spare space for expansionpublic UnicodeBuilder accept(UnicodeString chars)
accept in interface UniStringConsumerchars - the characters to be processedpublic void write(UnicodeString chars)
UnicodeWriterwrite in interface UnicodeWriterchars - the characters to be processedpublic void writeAscii(byte[] content)
throws java.io.IOException
writeAscii in interface UnicodeWritercontent - byte array holding ASCII characters onlyjava.io.IOException - if processing fails for any reasonpublic void write(java.lang.String chars)
throws java.io.IOException
write in interface UnicodeWriterchars - the characters to be processedjava.io.IOException - if processing fails for any reasonpublic void trimToSize()
public void close()
close in interface UnicodeWriterclose in interface UniStringConsumerCopyright (c) 2004-2022 Saxonica Limited. All rights reserved.