public class BinaryWire extends AbstractWire implements Wire
| Modifier and Type | Class and Description |
|---|---|
protected class |
BinaryWire.BinaryValueIn
Represents a binary input value and provides methods to read and manage the state
of this binary input.
|
protected class |
BinaryWire.BinaryValueOut
Extends the FixedBinaryValueOut class to support binary value outputs with additional logic for converting
and writing different types of numbers, namely integers and longs.
|
protected class |
BinaryWire.FixedBinaryValueOut
Implementation of the ValueOut interface, providing methods to write values in a fixed binary format.
|
WireIn.HeaderTypeWireOut.EndOfWire| Modifier and Type | Field and Description |
|---|---|
protected @NotNull BinaryWire.BinaryValueIn |
valueIn |
bytes, classLookup, commentListener, DEFAULT_USE_PADDING, parent, use8bitMARSHALLABLE_IN_INTERN_SIZE| Constructor and Description |
|---|
BinaryWire(@NotNull net.openhft.chronicle.bytes.Bytes<?> bytes)
Constructs a BinaryWire with default settings.
|
BinaryWire(@NotNull net.openhft.chronicle.bytes.Bytes<?> bytes,
boolean fixed,
boolean numericFields,
boolean fieldLess,
int compressedSize,
String compression,
boolean supportDelta)
Constructs a BinaryWire with specified configurations.
|
| Modifier and Type | Method and Description |
|---|---|
protected @NotNull StringBuilder |
acquireStringBuilder()
Acquires and clears the internal StringBuilder for use.
|
DocumentContext |
acquireWritingDocument(boolean metaData)
Retrieves a context for writing either data or metadata, reusing an existing context if available.
|
@NotNull WireOut |
addPadding(int paddingToAdd)
Adds padding to the wire.
|
protected void |
anchor(@NotNull WireOut wire)
Placeholder or handler for anchor processing in the WireOut stream.
|
static @NotNull BinaryWire |
binaryOnly(@NotNull net.openhft.chronicle.bytes.Bytes<?> bytes)
Creates and returns a new instance of BinaryWire with the delta support disabled.
|
void |
clear()
Clears the WireIn, effectively resetting its state.
|
void |
consumePadding()
Consumes and discards any padding that may exist between the current read position and the next piece of meaningful data.
|
void |
copyOne(@NotNull WireOut wire)
Copies one unit of data from this BinaryWire to the provided WireOut instance.
|
void |
copyTo(@NotNull WireOut wire)
Copies the content from the current WireIn source to the provided WireOut destination.
|
protected void |
fieldAnchor(@NotNull WireOut wire)
Placeholder or handler for field anchor processing in the WireOut stream.
|
boolean |
fieldLess()
Checks and returns if this BinaryWire instance is field-less.
|
protected @NotNull BinaryWire.BinaryValueIn |
getBinaryValueIn()
Creates and returns a new DeltaValueIn instance.
|
protected @NotNull BinaryWire.FixedBinaryValueOut |
getFixedBinaryValueOut(boolean fixed)
Provides a FixedBinaryValueOut instance based on the given boolean parameter.
|
Boolean |
getOverrideSelfDescribing()
Retrieves the current override setting for the self-describing nature of this BinaryWire.
|
@NotNull ValueIn |
getValueIn()
Obtains the value associated with a field or event for more advanced use cases.
|
@NotNull ValueOut |
getValueOut()
Retrieves the interface for defining the output of a value
that will be written to the stream.
|
boolean |
isBinary()
Determine whether direct access to the underlying byte() makes sense or should it be treated as text
|
@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.bytes.ref.BinaryLongArrayReference |
newLongArrayReference()
Creates and returns a new
LongArrayValues. |
@NotNull net.openhft.chronicle.core.values.LongValue |
newLongReference()
Creates and returns a new
LongValue. |
@NotNull net.openhft.chronicle.core.values.TwoLongValue |
newTwoLongReference()
Creates and returns a new
TwoLongValue. |
protected int |
peekCode()
Peeks the code from the current position without advancing the read pointer.
|
@NotNull ValueIn |
read()
Reads the next field if present, or returns an empty string if not present.
|
@NotNull ValueIn |
read(@NotNull String fieldName)
Reads the next field based on the provided field name.
|
@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 <T> ValueIn |
read2(CharSequence keyName,
int keyCode,
T defaultSource,
@NotNull Function<T,Object> defaultLookup,
@NotNull net.openhft.chronicle.wire.ValueInState curr,
@NotNull StringBuilder sb,
CharSequence name)
A secondary method to continue the field search process, specifically to handle cases where the field may
have been missed in a previous pass or if the field still hasn't been found.
|
@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.
|
@NotNull ValueIn |
readEventName(@NotNull StringBuilder name)
Reads a field or string, ensuring the value is always read.
|
long |
readEventNumber()
Reads the next event number.
|
protected @NotNull StringBuilder |
readFieldAnchor(@NotNull StringBuilder sb)
Reads a field anchor from the wire and populates the provided StringBuilder.
|
protected @NotNull StringBuilder |
readFieldNumber(CharSequence keyName,
int keyCode,
@NotNull StringBuilder sb,
long fieldId)
Reads a field number from the wire and populates the provided StringBuilder.
|
@NotNull DocumentContext |
readingDocument()
equivalent to
WireIn.readDocument(net.openhft.chronicle.wire.ReadMarshallable,
net.openhft.chronicle.wire.ReadMarshallable) but with out the use of a lambda expression |
@NotNull DocumentContext |
readingDocument(long readLocation)
Provides a context for reading a document starting at a specific position.
|
@NotNull String |
readingPeekYaml()
Typicality used for debugging, this method does not progress the read position and should
only be used when inside a reading document.
|
void |
readWithLength(@NotNull WireOut wire,
int len)
Reads data of a specified length from the bytes stream and writes to the WireOut stream
while interpreting the type of data (Map, Sequence, or Object).
|
void |
reset()
Reset the state of the wire
|
void |
rollbackIfNotComplete()
Rolls back the current operation if it is not complete.
|
BinaryWire |
setOverrideSelfDescribing(Boolean overrideSelfDescribing)
Sets an override for the self-describing nature of this BinaryWire.
|
@NotNull String |
toString()
Converts the current state of the bytes storage to a debug string.
|
protected static void |
unexpectedCode()
Throws an exception indicating an unexpected code was encountered.
|
protected void |
unknownCode(@NotNull WireOut wire)
Throws an exception indicating an unknown code was encountered.
|
boolean |
useSelfDescribingMessage(@NotNull net.openhft.chronicle.bytes.CommonMarshallable object)
Determines whether a given object should use the self-describing message format.
|
@NotNull ValueOut |
write()
Writes an empty field marker to the stream.
|
@NotNull ValueOut |
write(@NotNull CharSequence key)
Writes a CharSequence key to the stream.
|
@NotNull ValueOut |
write(@NotNull WireKey key)
Writes a WireKey to the stream.
|
protected net.openhft.chronicle.bytes.Bytes<?> |
writeCode(int code)
Writes a byte code to the byte buffer.
|
@NotNull Wire |
writeComment(CharSequence s)
Writes a comment to the wire.
|
void |
writeEndEvent() |
ValueOut |
writeEventId(int methodId)
Writes an event identifier to the stream.
|
ValueOut |
writeEventId(String name,
int methodId)
Writes an event identifier with a name to the stream.
|
@NotNull ValueOut |
writeEventName(@NotNull CharSequence name)
Writes a CharSequence key to the stream.
|
@NotNull ValueOut |
writeEventName(@NotNull WireKey key)
Writes a key to the stream.
|
void |
writeStartEvent()
Start an event object, mostly for internal use.
|
@NotNull DocumentContext |
writingDocument(boolean metaData)
Starts the process of writing a document to the wire with an option for metadata.
|
boolean |
writingIsComplete()
Checks if the current writing operation is complete.
|
bytes, bytesComment, classLookup, classLookup, commentListener, endOfWire, enterHeader, forceNotInsideHeader, 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, waitheaderNumber, newYamlWireOnHeapcommentListener, endEvent, hasMetaDataPrefix, hasMore, hintReadInputOrder, isEmpty, isEndEvent, isNotEmptyAfterPadding, objectInput, rawReadData, readAlignTo, readAllAsMap, readAndSetLength, readDataHeader, readDataHeader, readDocument, readDocument, readFirstHeader, readFirstHeader, readMetaDataHeader, startEventmethodReader, methodReaderBuilder, readBytes, readBytes, readDocument, readMap, readText, readTextdropDefault, endOfWire, enterHeader, objectOutput, padToCacheAlign, updateFirstHeader, updateFirstHeader, updateHeader, writeAlignTo, writeAllAsMap, writeDocument, writeEndOfWire, writeEvent, writeFirstHeader, writeNotCompleteDocument, writingDocumentbytes, bytesComment, classLookup, classLookup, headerNumber, notCompleteIsNotPresent, notCompleteIsNotPresent, parent, parent, pauser, pauser, usePadding, usePaddingbuilder, methodWriter, methodWriterBuilder, methodWriterBuilder, recordHistory, writeBytes, writeDocument, writeDocument, writeMap, writeMessage, writeMessage, writeText@NotNull protected final @NotNull BinaryWire.BinaryValueIn valueIn
public BinaryWire(@NotNull
@NotNull net.openhft.chronicle.bytes.Bytes<?> bytes)
bytes - The bytes to be processed by this wirepublic BinaryWire(@NotNull
@NotNull net.openhft.chronicle.bytes.Bytes<?> bytes,
boolean fixed,
boolean numericFields,
boolean fieldLess,
int compressedSize,
String compression,
boolean supportDelta)
bytes - The bytes to be processed by this wirefixed - Indicates whether the value output is fixednumericFields - Indicates if fields are represented numericallyfieldLess - Indicates if fields are absentcompressedSize - Threshold size for compressioncompression - Type of compression (e.g., "binary")supportDelta - Indicates if delta support is activated@NotNull public static @NotNull BinaryWire binaryOnly(@NotNull @NotNull net.openhft.chronicle.bytes.Bytes<?> bytes)
bytes - The bytes to be processed by this wirepublic void reset()
WireCommonreset in interface WireCommonpublic void rollbackIfNotComplete()
RollbackIfNotCompleteNotifierrollbackIfNotComplete in interface RollbackIfNotCompleteNotifierpublic boolean isBinary()
WireCommonisBinary in interface WireCommonpublic Boolean getOverrideSelfDescribing()
public BinaryWire setOverrideSelfDescribing(Boolean overrideSelfDescribing)
overrideSelfDescribing - null if there's no override, true if it should always use self-describing messages,
false if it should never use self-describing messages.@NotNull protected @NotNull StringBuilder acquireStringBuilder()
@NotNull protected @NotNull BinaryWire.FixedBinaryValueOut getFixedBinaryValueOut(boolean fixed)
fixed - Determines which type of FixedBinaryValueOut to return.@NotNull protected @NotNull BinaryWire.BinaryValueIn getBinaryValueIn()
public void clear()
WireInclear in interface WireCommonclear in interface WireInclear in interface WireOutclear in class AbstractWirepublic boolean fieldLess()
@NotNull public @NotNull DocumentContext writingDocument(boolean metaData)
WireOutwritingDocument in interface DocumentWrittenwritingDocument in interface MarshallableOutwritingDocument in interface WireOutmetaData - If true, the returned document context will be used for writing metadata.public DocumentContext acquireWritingDocument(boolean metaData)
WireOutacquireWritingDocument in interface DocumentWrittenacquireWritingDocument in interface MarshallableOutacquireWritingDocument in interface WireOutmetaData - If true, the returned context will be used for writing metadata.@NotNull public @NotNull DocumentContext readingDocument()
WireInWireIn.readDocument(net.openhft.chronicle.wire.ReadMarshallable,
net.openhft.chronicle.wire.ReadMarshallable) but with out the use of a lambda expressionreadingDocument in interface MarshallableInreadingDocument in interface WireIn@NotNull public @NotNull DocumentContext readingDocument(long readLocation)
WireInreadingDocument in interface WireInreadLocation - The position from which to start reading the document.@NotNull public @NotNull String readingPeekYaml()
readingPeekYaml in interface WireInpublic void copyTo(@NotNull
@NotNull WireOut wire)
throws net.openhft.chronicle.core.io.InvalidMarshallableException
WireInpublic void copyOne(@NotNull
@NotNull WireOut wire)
throws net.openhft.chronicle.core.io.InvalidMarshallableException
wire - The destination WireOut instance.net.openhft.chronicle.core.io.InvalidMarshallableException - if the operation encounters an error during marshalling.protected static void unexpectedCode()
net.openhft.chronicle.core.io.IORuntimeException - Always thrown with a specific message.protected void anchor(@NotNull
@NotNull WireOut wire)
wire - The wire output stream.protected void fieldAnchor(@NotNull
@NotNull WireOut wire)
wire - The wire output stream.public void readWithLength(@NotNull
@NotNull WireOut wire,
int len)
throws net.openhft.chronicle.core.io.InvalidMarshallableException
wire - The wire output stream to write data to.len - The length of data to be read.net.openhft.chronicle.core.io.InvalidMarshallableException - If there's an issue during marshalling.protected void unknownCode(@NotNull
@NotNull WireOut wire)
wire - The wire output stream.IllegalArgumentException - with the corresponding message for the unknown code.@NotNull public @NotNull ValueIn read(@NotNull @NotNull String fieldName)
WireIn@NotNull public @NotNull ValueIn read()
WireIn@NotNull public @NotNull ValueIn read(@NotNull @NotNull WireKey key)
WireInWireKey.protected <T> ValueIn read2(CharSequence keyName, int keyCode, T defaultSource, @NotNull @NotNull Function<T,Object> defaultLookup, @NotNull @NotNull net.openhft.chronicle.wire.ValueInState curr, @NotNull @NotNull StringBuilder sb, CharSequence name)
T - The type of the default source.keyName - The name of the key to be searched for.keyCode - The code corresponding to the key.defaultSource - The source to revert to if the key isn't found.defaultLookup - The function used to derive a default value based on the defaultSource.curr - The current state of ValueIn.sb - The StringBuilder used for string manipulations during search.name - The actual name of the field being sought.public long readEventNumber()
WireInreadEventNumber in interface WireInreadEventNumber in class AbstractWire@NotNull public @NotNull ValueIn readEventName(@NotNull @NotNull StringBuilder name)
WireInreadEventName in interface WireInname - The StringBuilder that holds the name of the field or string.ValueIn instance.@NotNull public @NotNull ValueIn read(@NotNull @NotNull StringBuilder name)
WireIn@NotNull public @NotNull ValueIn getValueIn()
WireInWireIn.readEvent(Class).getValueIn in interface WireInValueIn instance.@NotNull public @NotNull Wire readComment(@NotNull @NotNull StringBuilder s)
WireInreadComment in interface WireIns - StringBuilder to which the comment will be appended.@Nullable
public <K> K readEvent(@NotNull
@NotNull Class<K> expectedClass)
throws net.openhft.chronicle.core.io.InvalidMarshallableException
WireInreadEvent in interface 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.public void consumePadding()
WireInconsumePadding in interface WireInprotected int peekCode()
@NotNull protected @NotNull StringBuilder readFieldAnchor(@NotNull @NotNull StringBuilder sb)
sb - The StringBuilder to be populated with the read field anchor.UnsupportedOperationException - If the valueIn is not an instance of DeltaValueIn.@NotNull protected @NotNull StringBuilder readFieldNumber(CharSequence keyName, int keyCode, @NotNull @NotNull StringBuilder sb, long fieldId)
keyName - The key name of the field to be matched against.keyCode - The key code of the field to be matched against.sb - The StringBuilder to be populated with the read field number.fieldId - The ID of the field read from the wire.@NotNull public @NotNull ValueOut write()
WireOut@NotNull public @NotNull ValueOut writeEventName(@NotNull @NotNull WireKey key)
WireOutwriteEventName in interface WireOutkey - The key to write to the stream.@NotNull public @NotNull ValueOut writeEventName(@NotNull @NotNull CharSequence name)
WireOutwriteEventName in interface WireOutname - The CharSequence key to write to the stream.public ValueOut writeEventId(int methodId)
WireOutwriteEventId in interface WireOutmethodId - The ID of the method representing the event.public ValueOut writeEventId(String name, int methodId)
WireOutwriteEventId in interface WireOutname - The name of the event.methodId - The ID of the method representing the event.public void writeStartEvent()
WireOutwriteStartEvent in interface WireOutpublic void writeEndEvent()
writeEndEvent in interface WireOut@NotNull public @NotNull ValueOut write(@NotNull @NotNull WireKey key)
WireOut@NotNull public @NotNull ValueOut write(@NotNull @NotNull CharSequence key)
WireOut@NotNull public @NotNull ValueOut getValueOut()
WireOutgetValueOut in interface WireOut@NotNull public @NotNull Wire writeComment(CharSequence s)
WireOutwriteComment in interface WireOuts - The comment to be written to the stream.@NotNull public @NotNull WireOut addPadding(int paddingToAdd)
WireOutaddPadding in interface WireOutpaddingToAdd - The amount of padding to add.protected net.openhft.chronicle.bytes.Bytes<?> writeCode(int code)
code - The byte code to write.@NotNull public @NotNull String toString()
This method provides a string representation of the bytes, useful for debugging purposes.
@NotNull public @NotNull net.openhft.chronicle.core.values.LongValue newLongReference()
WireCommonLongValue. The LongValue implementation that is
returned depends on the wire implementation.newLongReference in interface WireCommonLongValue@NotNull public @NotNull net.openhft.chronicle.core.values.BooleanValue newBooleanReference()
WireCommonBooleanValue. The BooleanValue implementation that is
returned depends on the wire implementation.newBooleanReference in interface WireCommonBooleanValue.@NotNull public @NotNull net.openhft.chronicle.core.values.TwoLongValue newTwoLongReference()
WireCommonTwoLongValue. The TwoLongValue implementation that
is returned depends on the wire implementation.newTwoLongReference in interface WireCommonTwoLongValue@NotNull public @NotNull net.openhft.chronicle.core.values.IntValue newIntReference()
WireCommonIntValue. The IntValue implementation that is
returned depends on the wire implementation.newIntReference in interface WireCommonIntValue.@NotNull public @NotNull net.openhft.chronicle.bytes.ref.BinaryLongArrayReference newLongArrayReference()
WireCommonLongArrayValues. The LongArrayValues implementation that
is returned depends on the wire implementation.newLongArrayReference in interface WireCommonLongArrayValues@NotNull public @NotNull net.openhft.chronicle.core.values.IntArrayValues newIntArrayReference()
WireCommonIntArrayValues. The IntArrayValues implementation that
is returned depends on the wire implementation.newIntArrayReference in interface WireCommonIntArrayValuespublic boolean useSelfDescribingMessage(@NotNull
@NotNull net.openhft.chronicle.bytes.CommonMarshallable object)
This method first checks if an override value for self-describing is set. If not, it uses the self-describing value from the provided object.
useSelfDescribingMessage in interface WireCommonobject - The object whose self-describing status needs to be checked.public boolean writingIsComplete()
RollbackIfNotCompleteNotifierwritingIsComplete in interface RollbackIfNotCompleteNotifierwritingIsComplete in interface WireOutCopyright © 2024. All rights reserved.