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
Nested ClassesModifier and TypeClassDescriptionstatic classNode to append a single byte to a string builder.static classNode to append a single char to a string builder.static classNode to append a codepoint to a string builder.static classNode to append an integer to a string builder.static classNode to append a substring of a givenStringto a string builder.static classNode to append alongvalue to a string builder.static classNode to append a givenTruffleStringto a string builder.static classNode to append a substring of a givenTruffleStringto a string builder.static classNode to materialize a string builder as aTruffleString. -
Method Summary
Modifier and TypeMethodDescriptionfinal voidappendByteUncached(byte value) Shorthand for calling the uncached version ofTruffleStringBuilder.AppendByteNode.final voidappendCharUTF16Uncached(char value) Shorthand for calling the uncached version ofTruffleStringBuilder.AppendCharUTF16Node.final voidappendCodePointUncached(int codepoint) Shorthand for calling the uncached version ofTruffleStringBuilder.AppendCodePointNode.final voidappendCodePointUncached(int codepoint, int repeat) Shorthand for calling the uncached version ofTruffleStringBuilder.AppendCodePointNode.final voidappendCodePointUncached(int codepoint, int repeat, boolean allowUTF16Surrogates) Shorthand for calling the uncached version ofTruffleStringBuilder.AppendCodePointNode.final voidappendIntNumberUncached(int value) Shorthand for calling the uncached version ofTruffleStringBuilder.AppendIntNumberNode.final voidShorthand for calling the uncached version ofTruffleStringBuilder.AppendJavaStringUTF16Node.final voidappendJavaStringUTF16Uncached(String a, int fromCharIndex, int charLength) Shorthand for calling the uncached version ofTruffleStringBuilder.AppendJavaStringUTF16Node.final voidappendLongNumberUncached(long value) Shorthand for calling the uncached version ofTruffleStringBuilder.AppendLongNumberNode.final voidShorthand for calling the uncached version ofTruffleStringBuilder.AppendStringNode.final voidappendSubstringByteIndexUncached(TruffleString a, int fromByteIndex, int byteLength) Shorthand for calling the uncached version ofTruffleStringBuilder.AppendSubstringByteIndexNode.final intReturns this string builder's byte length.static TruffleStringBuildercreate(TruffleString.Encoding encoding) Create a new string builder with the given encoding.static TruffleStringBuildercreate(TruffleString.Encoding encoding, int initialCapacity) Create a new string builder with the given encoding, and pre-allocate the given number of bytes.static TruffleStringBuilderUTF16Create a new UTF-16 string builder.static TruffleStringBuilderUTF16createUTF16(int initialCapacity) Create a new UTF-16 string builder and pre-allocate the given number of chars.static TruffleStringBuilderUTF32Create a new UTF-32 string builder.static TruffleStringBuilderUTF32createUTF32(int initialCapacity) Create a new UTF-32 string builder and pre-allocate the given number of codepoints.static TruffleStringBuilderUTF8Create a new UTF-8 string builder.static TruffleStringBuilderUTF8createUTF8(int initialCapacity) Create a new UTF-8 string builder and pre-allocate the given number of bytes.final booleanisEmpty()Returns true if this string builder is empty.final StringtoString()Convert the string builder's content to a java string.final TruffleStringShorthand 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
-
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
-