Package com.oracle.truffle.api.strings
Class TruffleStringBuilder
java.lang.Object
com.oracle.truffle.api.strings.TruffleStringBuilder
- Direct Known Subclasses:
TruffleStringBuilderUTF16
,TruffleStringBuilderUTF32
,TruffleStringBuilderUTF8
public abstract sealed class TruffleStringBuilder
extends Object
permits TruffleStringBuilderUTF8, TruffleStringBuilderUTF16, TruffleStringBuilderUTF32 (not exhaustive)
The
TruffleString
equivalent to StringBuilder
. This builder eagerly
fills up a byte array with all strings passed to its Append
-nodes. For lazy string
concatenation, use TruffleString.ConcatNode
instead.- Since:
- 22.1
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Node to append a single byte to a string builder.static class
Node to append a single char to a string builder.static class
Node to append a codepoint to a string builder.static class
Node to append an integer to a string builder.static class
Node to append a substring of a givenString
to a string builder.static class
Node to append along
value to a string builder.static class
Node to append a givenTruffleString
to a string builder.static class
Node to append a substring of a givenTruffleString
to a string builder.static class
Node to materialize a string builder as aTruffleString
. -
Method Summary
Modifier and TypeMethodDescriptionfinal void
appendByteUncached
(byte value) Shorthand for calling the uncached version ofTruffleStringBuilder.AppendByteNode
.final void
appendCharUTF16Uncached
(char value) Shorthand for calling the uncached version ofTruffleStringBuilder.AppendCharUTF16Node
.final void
appendCodePointUncached
(int codepoint) Shorthand for calling the uncached version ofTruffleStringBuilder.AppendCodePointNode
.final void
appendCodePointUncached
(int codepoint, int repeat) Shorthand for calling the uncached version ofTruffleStringBuilder.AppendCodePointNode
.final void
appendCodePointUncached
(int codepoint, int repeat, boolean allowUTF16Surrogates) Shorthand for calling the uncached version ofTruffleStringBuilder.AppendCodePointNode
.final void
appendIntNumberUncached
(int value) Shorthand for calling the uncached version ofTruffleStringBuilder.AppendIntNumberNode
.final void
Shorthand for calling the uncached version ofTruffleStringBuilder.AppendJavaStringUTF16Node
.final void
appendJavaStringUTF16Uncached
(String a, int fromCharIndex, int charLength) Shorthand for calling the uncached version ofTruffleStringBuilder.AppendJavaStringUTF16Node
.final void
appendLongNumberUncached
(long value) Shorthand for calling the uncached version ofTruffleStringBuilder.AppendLongNumberNode
.final void
Shorthand for calling the uncached version ofTruffleStringBuilder.AppendStringNode
.final void
appendSubstringByteIndexUncached
(TruffleString a, int fromByteIndex, int byteLength) Shorthand for calling the uncached version ofTruffleStringBuilder.AppendSubstringByteIndexNode
.final int
Returns this string builder's byte length.static TruffleStringBuilder
create
(TruffleString.Encoding encoding) Create a new string builder with the given encoding.static TruffleStringBuilder
create
(TruffleString.Encoding encoding, int initialCapacity) Create a new string builder with the given encoding, and pre-allocate the given number of bytes.static TruffleStringBuilderUTF16
Create a new UTF-16 string builder.static TruffleStringBuilderUTF16
createUTF16
(int initialCapacity) Create a new UTF-16 string builder and pre-allocate the given number of chars.static TruffleStringBuilderUTF32
Create a new UTF-32 string builder.static TruffleStringBuilderUTF32
createUTF32
(int initialCapacity) Create a new UTF-32 string builder and pre-allocate the given number of codepoints.static TruffleStringBuilderUTF8
Create a new UTF-8 string builder.static TruffleStringBuilderUTF8
createUTF8
(int initialCapacity) Create a new UTF-8 string builder and pre-allocate the given number of bytes.final boolean
isEmpty()
Returns true if this string builder is empty.final String
toString()
Convert the string builder's content to a java string.final TruffleString
Shorthand for calling the uncached version ofTruffleStringBuilder.ToStringNode
.
-
Method Details
-
isEmpty
public final boolean isEmpty()Returns true if this string builder is empty.- Since:
- 22.1
-
byteLength
public final int byteLength()Returns this string builder's byte length.- Since:
- 22.1
-
create
Create a new string builder with the given encoding.If the encoding is known ahead of time, use
createUTF8()
,createUTF16()
orcreateUTF32()
instead.- Since:
- 22.1
-
create
Create a new string builder with the given encoding, and pre-allocate the given number of bytes.If the encoding is known ahead of time, use
createUTF8(int)
,createUTF16(int)
orcreateUTF32(int)
instead.- Since:
- 22.1
-
createUTF8
Create a new UTF-8 string builder.- Since:
- 23.1
-
createUTF8
Create a new UTF-8 string builder and pre-allocate the given number of bytes.- Since:
- 23.1
-
createUTF16
Create a new UTF-16 string builder.- Since:
- 23.1
-
createUTF16
Create a new UTF-16 string builder and pre-allocate the given number of chars.- Since:
- 23.1
-
createUTF32
Create a new UTF-32 string builder.- Since:
- 23.1
-
createUTF32
Create a new UTF-32 string builder and pre-allocate the given number of codepoints.- Since:
- 23.1
-
appendByteUncached
public final void appendByteUncached(byte value) Shorthand for calling the uncached version ofTruffleStringBuilder.AppendByteNode
.- Since:
- 22.1
-
appendCharUTF16Uncached
public final void appendCharUTF16Uncached(char value) Shorthand for calling the uncached version ofTruffleStringBuilder.AppendCharUTF16Node
.- Since:
- 22.1
-
appendCodePointUncached
public final void appendCodePointUncached(int codepoint) Shorthand for calling the uncached version ofTruffleStringBuilder.AppendCodePointNode
.- Since:
- 22.1
-
appendCodePointUncached
public final void appendCodePointUncached(int codepoint, int repeat) Shorthand for calling the uncached version ofTruffleStringBuilder.AppendCodePointNode
.- Since:
- 22.2
-
appendCodePointUncached
public final void appendCodePointUncached(int codepoint, int repeat, boolean allowUTF16Surrogates) Shorthand for calling the uncached version ofTruffleStringBuilder.AppendCodePointNode
.- Since:
- 22.2
-
appendIntNumberUncached
public final void appendIntNumberUncached(int value) Shorthand for calling the uncached version ofTruffleStringBuilder.AppendIntNumberNode
.- Since:
- 22.1
-
appendLongNumberUncached
public final void appendLongNumberUncached(long value) Shorthand for calling the uncached version ofTruffleStringBuilder.AppendLongNumberNode
.- Since:
- 22.1
-
appendStringUncached
Shorthand for calling the uncached version ofTruffleStringBuilder.AppendStringNode
.- Since:
- 22.1
-
appendSubstringByteIndexUncached
public final void appendSubstringByteIndexUncached(TruffleString a, int fromByteIndex, int byteLength) Shorthand for calling the uncached version ofTruffleStringBuilder.AppendSubstringByteIndexNode
.- Since:
- 22.1
-
appendJavaStringUTF16Uncached
Shorthand for calling the uncached version ofTruffleStringBuilder.AppendJavaStringUTF16Node
.- Since:
- 22.1
-
appendJavaStringUTF16Uncached
Shorthand for calling the uncached version ofTruffleStringBuilder.AppendJavaStringUTF16Node
.- Since:
- 22.1
-
toStringUncached
Shorthand for calling the uncached version ofTruffleStringBuilder.ToStringNode
.- Since:
- 22.1
-
toString
Convert the string builder's content to a java string. Do not use this on a fast path.
-