Module com.s8.api

Interface ByteOutflow


public interface ByteOutflow

/!\ All array or String lengths are encoded as UInt32 to reflect their maximum possible length in JAVA.

Author:
Pierre Convert Copyright (C) 2022, Pierre Convert. All rights reserved.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Default capacity for underlybing buffer.
  • Method Summary

    Modifier and Type
    Method
    Description
    default void
    putBool8(boolean value)
    Hack for js part
    void
    putByte(byte b)
    Directly put byte
    void
    putByteArray(byte[] bytes)
    Write bytes array.
    void
    putByteArray(byte[] array, int offset, int length)
    Put an array of bytes from an array from a given offset for a given length.
    void
    putFlags8(boolean[] flags)
    Auto-feed underlying ByteBuffer as necessary.
    void
    putFloat32(float value)
    Auto-feed underlying ByteBuffer as necessary.
    default void
    putFloat32Array(float[] value)
    Write an float[] array into the flow.
    void
    putFloat64(double value)
    Auto-feed underlying ByteBuffer as necessary.
    default void
    putFloat64Array(double[] value)
    Write double[] value to the outflow.
    void
    putInt16(short value)
    Auto-feed underlying ByteBuffer as necessary.
    void
    putInt32(int value)
    Auto-feed underlying ByteBuffer as necessary.
    default void
    putInt32Array(int[] value)
    Push an Int32[] array into the flow.
    void
    putInt64(long value)
    Auto-feed underlying ByteBuffer as necessary.
    default void
    putInt64Array(long[] value)
    Put value in thr flow
    void
    putInt8(byte value)
    Write value to the flow (Auto-feed underlying ByteBuffer as necessary).
    void
    String is encoded in UTF8.
    void
    putUInt16(int value)
    Auto-feed underlying ByteBuffer as necessary.
    void
    putUInt24(int value)
    Auto-feed underlying ByteBuffer as necessary.
    void
    putUInt31(int value)
    Auto-feed underlying ByteBuffer as necessary.
    void
    putUInt32(long value)
    Auto-feed underlying ByteBuffer as necessary.
    void
    putUInt40(long value)
    Auto-feed underlying ByteBuffer as necessary.
    void
    putUInt48(long value)
    Auto-feed underlying ByteBuffer as necessary.
    void
    putUInt53(long value)
    Auto-feed underlying ByteBuffer as necessary.
    void
    putUInt56(long value)
    Auto-feed underlying ByteBuffer as necessary.
    void
    putUInt64(long value)
    Auto-feed underlying ByteBuffer as necessary.
    void
    putUInt7x(long value)
    Put a flexible encoding int to the flow
    void
    putUInt8(int value)
    Auto-feed underlying ByteBuffer as necessary.
    void
    setCapacity(int capacity)
    Set the capacity of the underlying buffer.
  • Field Details

    • DEFAULT_CAPACITY

      static final int DEFAULT_CAPACITY
      Default capacity for underlybing buffer. Highly dependent of implementations and purposes. Basic value only.
      See Also:
  • Method Details

    • setCapacity

      void setCapacity(int capacity)
      Set the capacity of the underlying buffer.
      Parameters:
      capacity - the capacity of the underlying buffer
    • putByteArray

      void putByteArray(byte[] bytes) throws IOException
      Write bytes array. Auto-feed underlying ByteBuffer as necessary.
      Parameters:
      bytes - the bytes to be written
      Throws:
      IOException - exception while writing to the flow
    • putByteArray

      void putByteArray(byte[] array, int offset, int length) throws IOException
      Put an array of bytes from an array from a given offset for a given length.
      Parameters:
      array - the byte array to be pushed to the outlfow
      offset - offset
      length - length to be read of the array argument
      Throws:
      IOException - exception while writing to the flow
    • putFlags8

      void putFlags8(boolean[] flags) throws IOException
      Auto-feed underlying ByteBuffer as necessary.
      Parameters:
      flags - the flags to be wirtten in the outflow
      Throws:
      IOException - exception while writing to the flow
    • putBool8

      default void putBool8(boolean value) throws IOException
      Hack for js part
      Parameters:
      value - the boolean value to be writtent to the flow
      Throws:
      IOException - exception while writing to the flow
    • putByte

      void putByte(byte b) throws IOException
      Directly put byte
      Parameters:
      b - the value to write
      Throws:
      IOException - exception while writing to the flow
    • putUInt7x

      void putUInt7x(long value) throws IOException
      Put a flexible encoding int to the flow
      Parameters:
      value - the value to write
      Throws:
      IOException - exception while writing to the flow
    • putUInt8

      void putUInt8(int value) throws IOException
      Auto-feed underlying ByteBuffer as necessary.
      Parameters:
      value - the value to write
      Throws:
      IOException - exception while writing to the flow
    • putUInt16

      void putUInt16(int value) throws IOException
      Auto-feed underlying ByteBuffer as necessary.
      Parameters:
      value - the value to write
      Throws:
      IOException - exception while writing to the flow
    • putUInt24

      void putUInt24(int value) throws IOException
      Auto-feed underlying ByteBuffer as necessary.
      Parameters:
      value - the value to write
      Throws:
      IOException - exception while writing to the flow
    • putUInt31

      void putUInt31(int value) throws IOException
      Auto-feed underlying ByteBuffer as necessary.
      Parameters:
      value - the value to write
      Throws:
      IOException - exception while writing to the flow
    • putUInt32

      void putUInt32(long value) throws IOException
      Auto-feed underlying ByteBuffer as necessary.
      Parameters:
      value - the value to write
      Throws:
      IOException - exception while writing to the flow
    • putUInt40

      void putUInt40(long value) throws IOException
      Auto-feed underlying ByteBuffer as necessary.
      Parameters:
      value - the value to write
      Throws:
      IOException - exception while writing to the flow
    • putUInt48

      void putUInt48(long value) throws IOException
      Auto-feed underlying ByteBuffer as necessary.
      Parameters:
      value - the value to write
      Throws:
      IOException - exception while writing to the flow
    • putUInt53

      void putUInt53(long value) throws IOException
      Auto-feed underlying ByteBuffer as necessary. This format is adequate to send JAVA long to JS (since JS MAX_INTEGER is 2^53).
      Parameters:
      value - the value to write
      Throws:
      IOException - exception while writing to the flow
    • putUInt56

      void putUInt56(long value) throws IOException
      Auto-feed underlying ByteBuffer as necessary.
      Parameters:
      value - the value to write
      Throws:
      IOException - exception while writing to the flow
    • putUInt64

      void putUInt64(long value) throws IOException
      Auto-feed underlying ByteBuffer as necessary.
      Parameters:
      value - the value to write
      Throws:
      IOException - exception while writing to the flow
    • putInt8

      void putInt8(byte value) throws IOException
      Write value to the flow (Auto-feed underlying ByteBuffer as necessary).
      Parameters:
      value - the value to write
      Throws:
      IOException - exception while writing to the flow
    • putInt16

      void putInt16(short value) throws IOException
      Auto-feed underlying ByteBuffer as necessary.
      Parameters:
      value - the value to write
      Throws:
      IOException - exception while writing to the flow
    • putInt32

      void putInt32(int value) throws IOException
      Auto-feed underlying ByteBuffer as necessary.
      Parameters:
      value - the value to write
      Throws:
      IOException - exception while writing to the flow
    • putInt32Array

      default void putInt32Array(int[] value) throws IOException
      Push an Int32[] array into the flow. Auto-feed underlying ByteBuffer as necessary.
      Parameters:
      value - the value written
      Throws:
      IOException - the exception rasied in the writing process
    • putInt64

      void putInt64(long value) throws IOException
      Auto-feed underlying ByteBuffer as necessary.
      Parameters:
      value - the value to write
      Throws:
      IOException - exception while writing to the flow
    • putInt64Array

      default void putInt64Array(long[] value) throws IOException
      Put value in thr flow
      Parameters:
      value - the value to write
      Throws:
      IOException - exception while writing to the flow
    • putFloat32

      void putFloat32(float value) throws IOException
      Auto-feed underlying ByteBuffer as necessary.
      Parameters:
      value - the value to write
      Throws:
      IOException - exception while writing to the flow
    • putFloat32Array

      default void putFloat32Array(float[] value) throws IOException
      Write an float[] array into the flow.
      Parameters:
      value - the value to write
      Throws:
      IOException - exception while writing to the flow
    • putFloat64

      void putFloat64(double value) throws IOException
      Auto-feed underlying ByteBuffer as necessary.
      Parameters:
      value - the value to write
      Throws:
      IOException - exception while writing to the flow
    • putFloat64Array

      default void putFloat64Array(double[] value) throws IOException
      Write double[] value to the outflow.
      Parameters:
      value - the value to write
      Throws:
      IOException - exception while writing to the flow
    • putStringUTF8

      void putStringUTF8(String str) throws IOException
      String is encoded in UTF8.
      Parameters:
      str - the value to write
      Throws:
      IOException - exception while writing to the flow