Class PackOutputStream

Object
de.sayayi.lib.pack.PackOutputStream
All Implemented Interfaces:
Closeable, AutoCloseable

public class PackOutputStream extends Object implements Closeable
Since:
0.1.0
  • Constructor Details

  • Method Details

    • writeBoolean

      public void writeBoolean(boolean value) throws IOException
      Write a boolean value to the output stream.
      Parameters:
      value - boolean value to write
      Throws:
      IOException - if an I/O error occurs
    • writeEnum

      public <T extends Enum<T>> void writeEnum(@NotNull T value, @org.jetbrains.annotations.Range(from=1L, to=16L) int bitWidth) throws IOException
      Write an enumerated value to the output stream.
      Parameters:
      value - enumerated value to write, not null
      bitWidth - number of bits to use for the enumerated value
      Throws:
      IllegalArgumentException - if bitWidth is not in the range 1..16 or if the ordinal of the enumerated value exceeds the bitWidth
      IOException - if an I/O error occurs
    • writeEnum

      public <T extends Enum<T>> void writeEnum(@NotNull T value) throws IOException
      Write an enumerated value to the output stream.
      Parameters:
      value - enumerated value to write, not null
      Throws:
      IOException - if an I/O error occurs
    • writeUnsignedShort

      public void writeUnsignedShort(@org.jetbrains.annotations.Range(from=0L, to=65535L) int value) throws IOException
      Parameters:
      value - unsigned value (0..65535)
      Throws:
      IOException - if an I/O error occurs
    • writeInt

      public void writeInt(int value) throws IOException
      Throws:
      IOException
    • writeLong

      public void writeLong(long value) throws IOException
      Throws:
      IOException
    • writeString

      public void writeString(String str) throws IOException
      Throws:
      IOException
    • writeSmallVar

      public void writeSmallVar(@org.jetbrains.annotations.Range(from=0L, to=255L) int value) throws IOException
      Ranges: 0..7 (4 bit), 8..15 (5 bit), 16..255 (10 bit)
      Parameters:
      value - unsigned value (0..255)
      Throws:
      IOException - if an I/O error occurs
    • writeSmall

      public void writeSmall(@org.jetbrains.annotations.Range(from=0L, to=255L) int value, @org.jetbrains.annotations.Range(from=1L, to=8L) int bitWidth) throws IOException
      Parameters:
      value - unsigned value (0..255)
      bitWidth - range 1..8 bits
      Throws:
      IOException - if an I/O error occurs
    • writeLarge

      public void writeLarge(long value, @org.jetbrains.annotations.Range(from=9L, to=64L) int bitWidth) throws IOException
      Parameters:
      value - signed value
      bitWidth - range 9..64 bits
      Throws:
      IOException - if an I/O error occurs
    • forceByteAlignment

      protected void forceByteAlignment() throws IOException
      Throws:
      IOException
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException