Package com.oracle.truffle.api.strings
Class MutableTruffleString
java.lang.Object
com.oracle.truffle.api.strings.AbstractTruffleString
com.oracle.truffle.api.strings.MutableTruffleString
Represents a mutable variant of a
TruffleString
. This class also accepts all operations
of TruffleString. This class is not thread-safe and allows overwriting bytes in its internal byte
array or native pointer via MutableTruffleString.WriteByteNode
. The internal array or native pointer may also
be modified externally, but the corresponding MutableTruffleString must be notified of this via
notifyExternalMutation()
. MutableTruffleString is not a Truffle interop type, and must
be converted to an immutable TruffleString
via TruffleString.AsTruffleStringNode
before passing
a language boundary.- Since:
- 22.1
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Node to get the givenAbstractTruffleString
as a managedMutableTruffleString
, meaning that the resulting string's backing memory is not a native pointer.static class
Node to get aAbstractTruffleString
as aMutableTruffleString
.static class
Node to create a newMutableTruffleString
by concatenating two strings.static class
Node to forcibly assign any encoding to a string.static class
Node to create a newMutableTruffleString
from a byte array.static class
Node to create a newMutableTruffleString
from an interop object representing a native pointer.static class
MutableTruffleString.SubstringNode
, but with byte indices.static class
Node to create a new mutable substring of a string.static class
Node to get a given string in a specific encoding.static class
Node to write a byte into a mutable string. -
Method Summary
Modifier and TypeMethodDescriptionconcatUncached
(AbstractTruffleString b, TruffleString.Encoding expectedEncoding) Shorthand for calling the uncached version ofMutableTruffleString.ConcatNode
.static MutableTruffleString
fromByteArrayUncached
(byte[] value, int byteOffset, int byteLength, TruffleString.Encoding encoding, boolean copy) Shorthand for calling the uncached version ofMutableTruffleString.FromByteArrayNode
.static MutableTruffleString
fromNativePointerUncached
(Object pointerObject, int byteOffset, int byteLength, TruffleString.Encoding encoding, boolean copy) Shorthand for calling the uncached version ofMutableTruffleString.FromNativePointerNode
.void
Notify this mutable string of an external modification of its internal content.substringByteIndexUncached
(int byteOffset, int byteLength, TruffleString.Encoding expectedEncoding) Shorthand for calling the uncached version ofMutableTruffleString.SubstringByteIndexNode
.substringUncached
(int byteOffset, int byteLength, TruffleString.Encoding expectedEncoding) Shorthand for calling the uncached version ofMutableTruffleString.SubstringNode
.void
writeByteUncached
(int byteIndex, byte value, TruffleString.Encoding expectedEncoding) Shorthand for calling the uncached version ofMutableTruffleString.WriteByteNode
.Methods inherited from class com.oracle.truffle.api.strings.AbstractTruffleString
asManagedMutableTruffleStringUncached, asManagedTruffleStringUncached, asManagedTruffleStringUncached, asMutableTruffleStringUncached, asTruffleStringUncached, byteIndexOfAnyByteUncached, byteIndexOfCodePointUncached, byteIndexOfStringUncached, byteIndexOfStringUncached, byteIndexToCodePointIndexUncached, byteLength, byteLengthOfCodePointUncached, byteLengthOfCodePointUncached, charIndexOfAnyCharUTF16Uncached, codePointAtByteIndexUncached, codePointAtByteIndexUncached, codePointAtIndexUncached, codePointAtIndexUncached, codePointIndexToByteIndexUncached, codePointLengthUncached, codeRangeEqualsUncached, compareBytesUncached, compareCharsUTF16Uncached, compareIntsUTF32Uncached, concatUncached, copyToByteArrayNodeUncached, copyToByteArrayUncached, copyToByteArrayUncached, copyToNativeMemoryNodeUncached, copyToNativeMemoryUncached, createBackwardCodePointIteratorUncached, createCodePointIteratorUncached, equals, equalsUncached, forceEncodingUncached, getByteCodeRangeUncached, getCodeRangeImpreciseUncached, getCodeRangeUncached, getInternalByteArrayUncached, getInternalNativePointerUncached, getStringCompactionLevelUncached, hashCode, hashCodeUncached, indexOfCodePointUncached, indexOfStringUncached, intIndexOfAnyIntUTF32Uncached, isCompatibleTo, isCompatibleToUncached, isEmpty, isImmutable, isManaged, isMutable, isNative, isValidUncached, lastByteIndexOfCodePointUncached, lastByteIndexOfStringUncached, lastByteIndexOfStringUncached, lastIndexOfCodePointUncached, lastIndexOfStringUncached, materializeUncached, parseDoubleUncached, parseIntUncached, parseIntUncached, parseLongUncached, parseLongUncached, readByteUncached, readCharUTF16Uncached, regionEqualByteIndexUncached, regionEqualByteIndexUncached, regionEqualsUncached, repeatUncached, substringByteIndexUncached, substringUncached, switchEncodingUncached, switchEncodingUncached, toJavaStringUncached, toString, toStringDebug, toValidStringUncached
-
Method Details
-
notifyExternalMutation
public void notifyExternalMutation()Notify this mutable string of an external modification of its internal content. This method must be called after every direct write (not viaMutableTruffleString.WriteByteNode
) to the byte array or native pointer the string is using as internal storage. Exemplary usage scenario: Suppose aMutableTruffleString
was created by wrapping a native pointer viaMutableTruffleString.FromNativePointerNode
. If the native pointer is passed to a native function that may modify the pointer's contents, this method must be called afterwards, to ensure consistency.- Since:
- 22.1
-
fromByteArrayUncached
public static MutableTruffleString fromByteArrayUncached(byte[] value, int byteOffset, int byteLength, TruffleString.Encoding encoding, boolean copy) Shorthand for calling the uncached version ofMutableTruffleString.FromByteArrayNode
.- Since:
- 22.1
-
fromNativePointerUncached
public static MutableTruffleString fromNativePointerUncached(Object pointerObject, int byteOffset, int byteLength, TruffleString.Encoding encoding, boolean copy) Shorthand for calling the uncached version ofMutableTruffleString.FromNativePointerNode
.- Since:
- 22.1
-
writeByteUncached
Shorthand for calling the uncached version ofMutableTruffleString.WriteByteNode
.- Since:
- 22.1
-
concatUncached
public MutableTruffleString concatUncached(AbstractTruffleString b, TruffleString.Encoding expectedEncoding) Shorthand for calling the uncached version ofMutableTruffleString.ConcatNode
.- Since:
- 22.1
-
substringUncached
public MutableTruffleString substringUncached(int byteOffset, int byteLength, TruffleString.Encoding expectedEncoding) Shorthand for calling the uncached version ofMutableTruffleString.SubstringNode
.- Since:
- 22.1
-
substringByteIndexUncached
public MutableTruffleString substringByteIndexUncached(int byteOffset, int byteLength, TruffleString.Encoding expectedEncoding) Shorthand for calling the uncached version ofMutableTruffleString.SubstringByteIndexNode
.- Since:
- 22.1
-