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
Nested ClassesModifier and TypeClassDescriptionstatic classNode to get the givenAbstractTruffleStringas a managedMutableTruffleString, meaning that the resulting string's backing memory is not a native pointer.static classNode to get aAbstractTruffleStringas aMutableTruffleString.static classNode to create a newMutableTruffleStringby concatenating two strings.static classNode to forcibly assign any encoding to a string.static classNode to create a newMutableTruffleStringfrom a byte array.static classNode to create a newMutableTruffleStringfrom an interop object representing a native pointer.static classMutableTruffleString.SubstringNode, but with byte indices.static classNode to create a new mutable substring of a string.static classNode to get a given string in a specific encoding.static classNode 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 MutableTruffleStringfromByteArrayUncached(byte[] value, int byteOffset, int byteLength, TruffleString.Encoding encoding, boolean copy) Shorthand for calling the uncached version ofMutableTruffleString.FromByteArrayNode.static MutableTruffleStringfromNativePointerUncached(Object pointerObject, int byteOffset, int byteLength, TruffleString.Encoding encoding, boolean copy) Shorthand for calling the uncached version ofMutableTruffleString.FromNativePointerNode.voidNotify 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.voidwriteByteUncached(int byteIndex, byte value, TruffleString.Encoding expectedEncoding) Shorthand for calling the uncached version ofMutableTruffleString.WriteByteNode.Methods inherited from class 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, materializeSubstringUncached, materializeUncached, 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 aMutableTruffleStringwas 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
-