Class BinaryWire

java.lang.Object
io.fluxzero.common.api.internal.BinaryWire

public final class BinaryWire extends Object
Allocation-bounded primitive I/O shared by compact transports and persisted messages.
  • Method Details

    • peekInt

      public static int peekInt(byte[] bytes, int offset)
    • utf8Length

      public static int utf8Length(String value)
    • stringSize

      public static int stringSize(String value)
      Returns the encoded size of one nullable length-prefixed UTF-8 string.
    • nullableLongSize

      public static int nullableLongSize(Long value)
      Returns the encoded size of one nullable long.
    • bytesSize

      public static int bytesSize(byte[] value)
      Returns the encoded size of one nullable length-prefixed byte array.
    • longsSize

      public static int longsSize(long[] values)
      Returns the encoded size of one nullable length-prefixed long array.
    • envelopeSize

      public static int envelopeSize(SerializedMessage message)
      Returns the complete encoded size of one native message envelope.
    • nestedEnvelopeSize

      public static int nestedEnvelopeSize(SerializedMessage message)
      Returns the size of a native envelope when embedded as one length-delimited wire value.
    • prepareEnvelope

      public static SerializedMessage prepareEnvelope(SerializedMessage message)
      Prepares a message once for reuse by an enclosing transport codec.
    • prepareEnvelopes

      public static List<SerializedMessage> prepareEnvelopes(List<SerializedMessage> messages)
      Prepares a message sequence, retaining the original list when every envelope is reusable.
    • encodeEnvelopes

      public static byte[] encodeEnvelopes(List<SerializedMessage> messages)
      Encodes a sequence of concatenated native message envelopes.
    • encodeEnvelope

      public static byte[] encodeEnvelope(SerializedMessage message)
      Encodes one native message envelope.
    • decodeEnvelope

      public static SerializedMessage decodeEnvelope(byte[] bytes, int maximumValueSize) throws IOException
      Decodes exactly one native message envelope while retaining zero-copy payload and metadata views.
      Throws:
      IOException
    • decodeEnvelopes

      public static List<SerializedMessage> decodeEnvelopes(byte[] bytes, int maximumValueSize) throws IOException
      Decodes a sequence while retaining zero-copy payload and metadata views.
      Throws:
      IOException
    • decodeEnvelopes

      public static List<SerializedMessage> decodeEnvelopes(byte[] bytes, int offset, int length, int maximumValueSize) throws IOException
      Decodes a native-envelope sequence from a byte range.
      Throws:
      IOException
    • isEnvelopeSequence

      public static boolean isEnvelopeSequence(byte[] bytes)
      Returns whether the byte sequence starts with this codec's native-envelope signature.
    • isEnvelopeSequence

      public static boolean isEnvelopeSequence(byte[] bytes, int offset, int length)
      Returns whether a byte range starts with this codec's native-envelope signature.
    • readEnvelopeSize

      public static int readEnvelopeSize(byte[] bytes, int offset, int length, int maximumValueSize) throws IOException
      Returns the complete size of the next native message envelope in a byte range.
      Throws:
      IOException
    • readEnvelopeIndex

      public static Long readEnvelopeIndex(byte[] bytes, int offset, int length, int maximumValueSize) throws IOException
      Reads only the indexed routing field from one native message without materializing application data.
      Throws:
      IOException
    • utf8Equals

      public static boolean utf8Equals(byte[] bytes, int offset, int byteLength, String value)