public class TextWire extends YamlWireOut<TextWire>
This class utilizes bit sets, thread locals, and regular expressions to efficiently handle the YAML formatting nuances.
Important: Some configurations and methods in this class are marked as deprecated and are slated for removal in future versions, suggesting that its behavior might evolve in future releases.
| Modifier and Type | Class and Description |
|---|---|
class |
TextWire.TextValueIn
Represents a textual input value for deserialization.
|
WireIn.HeaderTypeWireOut.EndOfWire| Modifier and Type | Field and Description |
|---|---|
static net.openhft.chronicle.bytes.BytesStore<?,?> |
BINARY |
protected long |
lineStart
Represents the start of the current line being processed in the wire format.
|
protected ReadDocumentContext |
readContext
Context for reading documents from the wire format.
|
static @NotNull net.openhft.chronicle.bytes.Bytes<byte[]> |
TYPE_STR |
protected TextWire.TextValueIn |
valueIn
Input value parser specifically for text-based wire format.
|
protected WriteDocumentContext |
writeContext
Context for writing documents in the wire format.
|
sb, TYPE, valueOutbytes, classLookup, commentListener, DEFAULT_USE_PADDING, parent, use8bitMARSHALLABLE_IN_INTERN_SIZE| Constructor and Description |
|---|
TextWire()
Default constructor initializing the `TextWire` with elastic on-heap bytes, assume text documents.
|
TextWire(@NotNull net.openhft.chronicle.bytes.Bytes<?> bytes)
Constructor that initializes the `TextWire` with bytes representation
with default 8-bit encoding turned off.
|
TextWire(@NotNull net.openhft.chronicle.bytes.Bytes<?> bytes,
boolean use8bit)
Constructor to initialize the `TextWire` with a specific bytes representation
and a flag to determine if 8-bit encoding is to be used.
|
| Modifier and Type | Method and Description |
|---|---|
DocumentContext |
acquireWritingDocument(boolean metaData)
Obtains a
DocumentContext for writing. |
static String |
asText(@NotNull Wire wire)
Converts any wire format into a text representation.
|
net.openhft.chronicle.core.pool.ClassLookup |
classLookup()
Returns the current
ClassLookup implementation being used for class lookup. |
void |
classLookup(net.openhft.chronicle.core.pool.ClassLookup classLookup)
Sets the
ClassLookup implementation to be used for class lookup. |
void |
clear()
Clears the WireIn, effectively resetting its state.
|
protected void |
consumeDocumentStart()
Consumes the start of a document in the byte stream.
|
void |
consumePadding()
Consumes and discards any padding that may exist between the current read position and the next piece of meaningful data.
|
void |
consumePadding(int commas)
Consumes padding characters from the current reading position.
|
void |
consumeWhiteSpace()
Consumes and skips over white space characters from the current position in the byte stream.
|
void |
copyTo(@NotNull WireOut wire)
Copies the content from the current WireIn source to the provided WireOut destination.
|
protected @NotNull TextWire.TextValueIn |
createValueIn()
Creates and returns a new instance of TextValueIn.
|
protected Class<?> |
defaultKeyClass()
Returns the default class to be used as a key.
|
static @NotNull TextWire |
from(@NotNull String text)
Factory method to create a `TextWire` from a string representation.
|
static @NotNull TextWire |
fromFile(String filePath)
Factory method to create a `TextWire` from a file.
|
protected @NotNull net.openhft.chronicle.bytes.StopCharsTester |
getEscapingEndEventName() |
protected @NotNull net.openhft.chronicle.bytes.StopCharTester |
getEscapingEndOfText()
Retrieves the StopCharTester that determines the end of text with escaping.
|
protected @Nullable net.openhft.chronicle.bytes.StopCharTester |
getEscapingQuotes()
Retrieves the StopCharTester that determines the end of a quoted text section with escaping.
|
protected @NotNull net.openhft.chronicle.bytes.StopCharsTester |
getStrictEscapingEndOfText()
Retrieves the StopCharsTester that determines the end of text with strict escaping.
|
@NotNull ValueIn |
getValueIn()
Obtains the value associated with a field or event for more advanced use cases.
|
boolean |
hasMetaDataPrefix()
Checks if the current position in the stream has a metadata prefix.
|
protected void |
initReadContext()
Initializes the read context for this TextWire instance.
|
boolean |
isBinary()
Determine whether direct access to the underlying byte() makes sense or should it be treated as text
|
static <T> T |
load(String filename)
Loads an Object from a file
|
@NotNull VanillaMethodReaderBuilder |
methodReaderBuilder()
Provides a builder instance that can be used to construct and configure a
MethodReader
suitable for this reader's content. |
<T> T |
methodWriter(@NotNull Class<T> tClass,
Class<?>... additional)
Creates a proxy of the specified interfaces, where each method call on the proxy is written for replay.
|
<T> @NotNull net.openhft.chronicle.bytes.MethodWriterBuilder<T> |
methodWriterBuilder(@NotNull Class<T> tClass)
Returns a
MethodWriterBuilder that can be used to create a proxy for an interface. |
@NotNull net.openhft.chronicle.core.values.BooleanValue |
newBooleanReference()
Creates and returns a new
BooleanValue. |
@NotNull net.openhft.chronicle.core.values.IntArrayValues |
newIntArrayReference()
Creates and returns a new
IntArrayValues. |
@NotNull net.openhft.chronicle.core.values.IntValue |
newIntReference()
Creates and returns a new
IntValue. |
@NotNull net.openhft.chronicle.core.values.LongArrayValues |
newLongArrayReference()
Creates and returns a new
LongArrayValues. |
@NotNull net.openhft.chronicle.core.values.LongValue |
newLongReference()
Creates and returns a new
LongValue. |
void |
parseUntil(@NotNull StringBuilder sb,
@NotNull net.openhft.chronicle.bytes.StopCharsTester stopTester)
Clears the StringBuilder and then parses characters from the current byte position
until one of the specified stop characters in the tester is encountered.
|
void |
parseUntil(@NotNull StringBuilder sb,
@NotNull net.openhft.chronicle.bytes.StopCharTester stopTester)
Parses characters from the current byte position until one of the specified stop characters
in the tester is encountered.
|
void |
parseWord(@NotNull StringBuilder sb)
Parses a word from the current byte position until it encounters a space or stop character.
|
protected boolean |
peekStringIgnoreCase(@NotNull String source)
returns
true if the next string is str |
@NotNull ValueIn |
read()
Reads the next field if present, or returns an empty string if not present.
|
@NotNull ValueIn |
read(@NotNull StringBuilder name)
Reads a specific field based on the provided field name.
|
@NotNull ValueIn |
read(@NotNull WireKey key)
Reads the next field if present.
|
protected ValueIn |
read2(CharSequence keyName,
int keyCode,
Object defaultValue,
@NotNull net.openhft.chronicle.wire.ValueInState currentState,
@NotNull StringBuilder tempNameBuilder,
@NotNull CharSequence name)
Deprecated.
|
protected ValueIn |
read2(Object defaultValue,
@NotNull net.openhft.chronicle.wire.ValueInState currentState,
@NotNull StringBuilder tempNameBuilder,
@NotNull CharSequence name)
Attempts to read the value, continuing the read operation from the primary `read` method.
|
protected int |
readCode()
Reads the next byte as an unsigned integer.
|
@NotNull Wire |
readComment(@NotNull StringBuilder s)
Reads a comment from the Wire data and appends it to the provided StringBuilder.
|
<K> K |
readEvent(@NotNull Class<K> expectedClass)
Reads a field which may contain an object of any specified type.
|
long |
readEventNumber()
Reads the next event number.
|
protected @NotNull StringBuilder |
readField(@NotNull StringBuilder sb)
Reads the field from the current position of the wire and appends it to the given StringBuilder.
|
@NotNull DocumentContext |
readingDocument()
Provides a
DocumentContext that can be used to read data from a source. |
@NotNull DocumentContext |
readingDocument(long readLocation)
Provides a context for reading a document starting at a specific position.
|
@NotNull String |
readingPeekYaml()
Peeks at the content in the current WireIn instance and returns it as a YAML string.
|
@Nullable Object |
readObject()
Reads and returns an object from the current position in the bytes stream.
|
void |
reset()
Reset the state of the wire
|
void |
rollbackIfNotComplete()
Rolls back the current operation if it is not complete.
|
boolean |
strict()
Retrieves the current strict mode setting for this TextWire instance.
|
TextWire |
strict(boolean strict)
Sets the strict mode for this TextWire instance.
|
String |
to8bitString()
Converts the underlying bytes of this TextWire to its ISO-8859-1 string representation.
|
String |
toString()
Converts the underlying bytes of this TextWire to its string representation.
|
String |
toUtf8String()
Converts the underlying bytes of this TextWire to its UTF-8 string representation.
|
static <ACS extends Appendable & CharSequence> |
unescape(ACS sb)
Processes and unescapes the provided
CharSequence containing escaped sequences. |
@NotNull TextWire |
useBinaryDocuments()
Configures this TextWire instance to use binary document contexts for reading and writing.
|
boolean |
useSelfDescribingMessage(@NotNull net.openhft.chronicle.bytes.CommonMarshallable object)
Should this wire write the object as a Marshallable or BytesMarshallable
|
@NotNull TextWire |
useTextDocuments()
Configures this TextWire instance to use textual document contexts for reading and writing.
|
@NotNull DocumentContext |
writingDocument(boolean metaData)
Initiates a new
DocumentContext for writing, with an option to include
metadata. |
boolean |
writingIsComplete()
Checks if the current writing operation is complete.
|
acquireStringBuilder, addPadding, addTimeStamps, addTimeStamps, append, append, appendU4, bytes, createValueOut, dropDefault, escape0, getValueOut, needsQuotes, trimFirstCurly, trimFirstCurly, write, write, write, writeComment, writeEndEvent, writeEvent, writeObject, writeStartEventbytesComment, commentListener, endOfWire, enterHeader, forceNotInsideHeader, generateTuples, generateTuples, headerNumber, headerNumber, headNumberCheck, isInsideHeader, notCompleteIsNotPresent, notCompleteIsNotPresent, objectInput, objectOutput, parent, parent, pauser, pauser, readAndSetLength, readDataHeader, readFirstHeader, readFirstHeader, readMetaDataHeader, updateFirstHeader, updateFirstHeader, updateHeader, usePadding, usePadding, writeEndOfWire, writeFirstHeaderclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitnewYamlWireOnHeapendEvent, hasMore, hintReadInputOrder, isEmpty, isEndEvent, isNotEmptyAfterPadding, rawReadData, read, readAlignTo, readAllAsMap, readDataHeader, readDocument, readDocument, readEventName, startEventmethodReader, readBytes, readBytes, readDocument, readMap, readText, readTextpadToCacheAlign, writeAlignTo, writeAllAsMap, writeDocument, writeEventId, writeEventId, writeEventName, writeEventName, writeNotCompleteDocument, writingDocumentnewTwoLongReferencebuilder, methodWriterBuilder, recordHistory, writeBytes, writeDocument, writeDocument, writeMap, writeMessage, writeMessage, writeTextpublic static final net.openhft.chronicle.bytes.BytesStore<?,?> BINARY
@NotNull public static final @NotNull net.openhft.chronicle.bytes.Bytes<byte[]> TYPE_STR
protected final TextWire.TextValueIn valueIn
protected long lineStart
protected WriteDocumentContext writeContext
protected ReadDocumentContext readContext
public TextWire()
public TextWire(@NotNull
@NotNull net.openhft.chronicle.bytes.Bytes<?> bytes,
boolean use8bit)
bytes - Bytes representation.use8bit - Flag to determine if 8-bit encoding is to be used.public TextWire(@NotNull
@NotNull net.openhft.chronicle.bytes.Bytes<?> bytes)
bytes - Bytes representation.@NotNull public static @NotNull TextWire fromFile(String filePath) throws IOException
filePath - Name of the file.IOException - if any I/O error occurs.@NotNull public static @NotNull TextWire from(@NotNull @NotNull String text)
text - String representation of the wire format.public static String asText(@NotNull @NotNull Wire wire)
wire - The wire format to be converted.public static <ACS extends Appendable & CharSequence> void unescape(@NotNull ACS sb)
CharSequence containing escaped sequences.
For instance, "\\n" is converted to a newline character, "\\t" to a tab, etc.
This method modifies the given sequence directly and adjusts its length if needed.sb - A CharSequence that is also an Appendable, containing potentially escaped sequences.
This sequence will be modified directly.public static <T> T load(String filename) throws IOException, net.openhft.chronicle.core.io.InvalidMarshallableException
T - the type of the object to loadfilename - the file-path containing the objectIOException - if the file can not be found or readnet.openhft.chronicle.core.io.InvalidMarshallableExceptionpublic boolean isBinary()
WireCommonpublic boolean strict()
public TextWire strict(boolean strict)
strict - A boolean value to set the strict mode. True to enable, false to disable.@NotNull
public <T> T methodWriter(@NotNull
@NotNull Class<T> tClass,
Class<?>... additional)
MarshallableOuttClass - primary interfaceadditional - any additional interfaces@NotNull
public <T> @NotNull net.openhft.chronicle.bytes.MethodWriterBuilder<T> methodWriterBuilder(@NotNull
@NotNull Class<T> tClass)
MarshallableOutMethodWriterBuilder that can be used to create a proxy for an interface.
Each message called on the proxy will be written for replay. This is a convenience method
that assumes metadata is not required.tClass - The primary interface that the builder will cater to.MethodWriterBuilder tailored for the given interface class.@NotNull public @NotNull VanillaMethodReaderBuilder methodReaderBuilder()
MarshallableInMethodReader
suitable for this reader's content. The builder offers flexibility in configuring the
MethodReader to suit specific requirements.VanillaMethodReaderBuilder for creating and customizing a MethodReader.public void classLookup(net.openhft.chronicle.core.pool.ClassLookup classLookup)
WireCommonClassLookup implementation to be used for class lookup.classLookup in interface WireCommonclassLookup in class AbstractWireclassLookup - implementation to be used for class lookup.public net.openhft.chronicle.core.pool.ClassLookup classLookup()
WireCommonClassLookup implementation being used for class lookup.classLookup in interface WireCommonclassLookup in class AbstractWireClassLookup implementation being used for class lookup@NotNull public @NotNull DocumentContext writingDocument(boolean metaData)
DocumentWrittenDocumentContext for writing, with an option to include
metadata. It is imperative to always invoke the close() method on the context
after completing the write operation.metaData - A boolean indicating if metadata should be included during writing.DocumentContext tailored to the metadata preference.public DocumentContext acquireWritingDocument(boolean metaData)
DocumentWrittenDocumentContext for writing. This method either initiates a new context
or reuses an existing one. Depending on the use case, calling the close() method
on the context might be optional.metaData - A boolean indicating if metadata should be included during writing.DocumentContext tailored to the metadata preference.@NotNull public @NotNull DocumentContext readingDocument()
MarshallableInDocumentContext that can be used to read data from a source. The specific
source and the means of reading are determined by the concrete implementation.DocumentContext appropriate for reading from the underlying source.protected void initReadContext()
@NotNull public @NotNull TextWire useBinaryDocuments()
@NotNull public @NotNull TextWire useTextDocuments()
@NotNull public @NotNull DocumentContext readingDocument(long readLocation)
WireInreadLocation - The position from which to start reading the document.@NotNull protected @NotNull TextWire.TextValueIn createValueIn()
public String toString()
public String to8bitString()
public String toUtf8String()
public void copyTo(@NotNull
@NotNull WireOut wire)
throws net.openhft.chronicle.core.io.InvalidMarshallableException
WireInwire - The WireOut instance where the content will be copied to.net.openhft.chronicle.core.io.InvalidMarshallableException - If there's an error in the marshalling process.public long readEventNumber()
WireInreadEventNumber in interface WireInreadEventNumber in class AbstractWire@NotNull public @NotNull ValueIn read()
WireInValueIn instance.@NotNull protected @NotNull StringBuilder readField(@NotNull @NotNull StringBuilder sb)
sb - The StringBuilder to which the field value should be appended.@Nullable
public <K> K readEvent(@NotNull
@NotNull Class<K> expectedClass)
throws net.openhft.chronicle.core.io.InvalidMarshallableException
WireInK - The type of object expected.expectedClass - The class type hint of the expected object. If no hint is available, use Object.class.net.openhft.chronicle.core.io.InvalidMarshallableException - If there's an error in the marshalling process.protected Class<?> defaultKeyClass()
Object.@NotNull protected @NotNull net.openhft.chronicle.bytes.StopCharTester getEscapingEndOfText()
@NotNull protected @NotNull net.openhft.chronicle.bytes.StopCharsTester getStrictEscapingEndOfText()
@NotNull protected @NotNull net.openhft.chronicle.bytes.StopCharsTester getEscapingEndEventName()
@Nullable protected @Nullable net.openhft.chronicle.bytes.StopCharTester getEscapingQuotes()
public void consumePadding()
WireIn@NotNull public @NotNull String readingPeekYaml()
WireInpublic void consumePadding(int commas)
commas - The number of comma characters to consume. Once this count is reached, the method will return.protected void consumeDocumentStart()
protected boolean peekStringIgnoreCase(@NotNull
@NotNull String source)
true if the next string is strsource - stringprotected int readCode()
@NotNull public @NotNull ValueIn read(@NotNull @NotNull WireKey key)
WireInWireKey.key - The WireKey that should match the next field.ValueIn instance.@Deprecated protected ValueIn read2(CharSequence keyName, int keyCode, Object defaultValue, @NotNull @NotNull net.openhft.chronicle.wire.ValueInState currentState, @NotNull @NotNull StringBuilder tempNameBuilder, @NotNull @NotNull CharSequence name)
keyName - The name of the key for which the value needs to be read.keyCode - The code for the key.defaultValue - The default value to return if the key isn't found.currentState - The current state of the ValueIn.tempNameBuilder - The StringBuilder used to capture the field name.name - The name of the key (same as keyName, possibly added for clarity in some cases).protected ValueIn read2(Object defaultValue, @NotNull @NotNull net.openhft.chronicle.wire.ValueInState currentState, @NotNull @NotNull StringBuilder tempNameBuilder, @NotNull @NotNull CharSequence name)
defaultValue - The default value to return if the key isn't found.currentState - The current state of the ValueIn.tempNameBuilder - The StringBuilder used to capture the field name.name - The name of the key (same as keyName, possibly added for clarity in some cases).@NotNull public @NotNull ValueIn read(@NotNull @NotNull StringBuilder name)
WireInname - The name of the field to read.ValueIn instance.@NotNull public @NotNull ValueIn getValueIn()
WireInWireIn.readEvent(Class).ValueIn instance.@NotNull public @NotNull Wire readComment(@NotNull @NotNull StringBuilder s)
WireIns - StringBuilder to which the comment will be appended.public void consumeWhiteSpace()
public void clear()
WireInclear in interface WireCommonclear in interface WireInclear in interface WireOutclear in class AbstractWire@NotNull public @NotNull net.openhft.chronicle.core.values.LongValue newLongReference()
WireCommonLongValue. The LongValue implementation that is
returned depends on the wire implementation.LongValue@NotNull public @NotNull net.openhft.chronicle.core.values.BooleanValue newBooleanReference()
WireCommonBooleanValue. The BooleanValue implementation that is
returned depends on the wire implementation.BooleanValue.public boolean useSelfDescribingMessage(@NotNull
@NotNull net.openhft.chronicle.bytes.CommonMarshallable object)
WireCommon@NotNull public @NotNull net.openhft.chronicle.core.values.IntValue newIntReference()
WireCommonIntValue. The IntValue implementation that is
returned depends on the wire implementation.IntValue.@NotNull public @NotNull net.openhft.chronicle.core.values.LongArrayValues newLongArrayReference()
WireCommonLongArrayValues. The LongArrayValues implementation that
is returned depends on the wire implementation.LongArrayValues@NotNull public @NotNull net.openhft.chronicle.core.values.IntArrayValues newIntArrayReference()
WireCommonIntArrayValues. The IntArrayValues implementation that
is returned depends on the wire implementation.IntArrayValuespublic void parseWord(@NotNull
@NotNull StringBuilder sb)
sb - The StringBuilder to which the parsed word will be appended.public void parseUntil(@NotNull
@NotNull StringBuilder sb,
@NotNull
@NotNull net.openhft.chronicle.bytes.StopCharTester stopTester)
sb - The StringBuilder to which the parsed characters will be appended.stopTester - A StopCharTester which determines which characters should stop the parsing.public void parseUntil(@NotNull
@NotNull StringBuilder sb,
@NotNull
@NotNull net.openhft.chronicle.bytes.StopCharsTester stopTester)
sb - The StringBuilder to which the parsed characters will be appended.stopTester - A StopCharsTester which determines which characters should stop the parsing.@Nullable public @Nullable Object readObject() throws net.openhft.chronicle.core.io.InvalidMarshallableException
net.openhft.chronicle.core.io.InvalidMarshallableException - If the object could not be properly unmarshalled.public void reset()
WireCommonpublic boolean hasMetaDataPrefix()
WireInpublic boolean writingIsComplete()
RollbackIfNotCompleteNotifiertrue
by default, indicating completion. Implementations should override this to
reflect the actual completion status of their write operation (for
example, the inverse of DocumentContext.isNotComplete()).public void rollbackIfNotComplete()
RollbackIfNotCompleteNotifierDocumentContext.isNotComplete()), this
method should attempt to roll back any changes made within the current
context, effectively discarding them. If rollback is not supported or not
applicable, an UnsupportedOperationException may be thrown.Copyright © 2026 Chronicle Software Ltd. All rights reserved.