Interface BitOutput

    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods 
      Modifier and Type Method Description
      default long align()
      Aligns to a single byte by padding zero bits.
      long align​(int bytes)
      Aligns to specified number of bytes by padding zero bits.
      default void close()
      Closes this output and releases any system resources associated with it.
      default void flush()
      Flushes this output by writing any buffered output to the underlying output.
      default void skip​(int bits)
      Skips specified number of bits by padding zero bits.
      default void writeBoolean​(boolean value)
      Writes specified 1-bit boolean value.
      default void writeByte​(boolean unsigned, int size, byte value)
      Writes specified byte value of specified number of bits.
      default void writeByte​(int size, byte value)
      Writes specified signed byte value of specified number of bits.
      default void writeByte8​(byte value)
      Writes specified 8-bit signed byte value.
      default void writeChar​(int size, char value)
      Writes specified char value of specified bit size.
      default void writeChar16​(char value)
      Writes specified 16-bit char value.
      default void writeDouble64​(double value)
      Writes specified 64-bit double value.
      default void writeFloat32​(float value)
      Writes specified 32-bit float value.
      void writeInt​(boolean unsigned, int size, int value)
      Writes specified int value of specified number of bits.
      default void writeInt​(int size, int value)
      Writes specified signed int value of specified bit size.
      default void writeInt32​(int value)
      Writes specified 32-bit signed value.
      default void writeInt32Le​(int value)
      Deprecated.
      Reverse specified value's bytes using Integer.reverseBytes(int) and write the result with writeInt32(int) method.
      default void writeLong​(boolean unsigned, int size, long value)
      Writes specified long value of specified number of bits.
      default void writeLong​(int size, long value)
      Writes specified signed long value of specified bit size.
      default void writeLong64​(long value)
      Writes specified 64-bit signed long value.
      default void writeLong64Le​(long value)
      Deprecated.
      Reverse specified value's bytes using Long.reverseBytes(long) method and write the result with writeLong64(long) method.
      default void writeShort​(boolean unsigned, int size, short value)
      Writes specified short value of specified number of bits.
      default void writeShort​(int size, short value)
      Writes specified signed short value of specified number of bits.
      default void writeShort16​(short value)
      Writes specified 16-bit signed short value.
      default void writeShort16Le​(short value)
      Deprecated.
      Reverse specified value's bytes with Short.reverseBytes(short) method and writes the result with writeShort16(short) method.
      default void writeUnsignedByte​(int size, byte value)
      Writes specified unsigned byte value of specified bit size.
      default void writeUnsignedInt​(int size, int value)
      Writes specified unsigned int value of specified bit size.
      default void writeUnsignedLong​(int size, long value)
      Writes specified unsigned long value of specified bit size.
      default void writeUnsignedShort​(int size, short value)
      Writes specified unsigned short value of specified bit size.
      default <T> void writeValue​(ValueAdapter<? super T> adapter, T value)
      Writes specified value using specified adapter.
    • Method Detail

      • flush

        default void flush()
                    throws IOException
        Flushes this output by writing any buffered output to the underlying output. The flush() method of BitOutput interface does nothing.
        Specified by:
        flush in interface Flushable
        Throws:
        IOException - if an I/O error occurs.
      • close

        default void close()
                    throws IOException
        Closes this output and releases any system resources associated with it. The close method of BitOutput interface does nothing.
        Specified by:
        close in interface AutoCloseable
        Specified by:
        close in interface Closeable
        Throws:
        IOException - if an I/O error occurs.
      • writeBoolean

        default void writeBoolean​(boolean value)
                           throws IOException
        Writes specified 1-bit boolean value. This method writes 0b1 for true and 0b0 for false.
        Parameters:
        value - the value to write.
        Throws:
        IOException - if an I/O error occurs.
      • writeByte

        default void writeByte​(boolean unsigned,
                               int size,
                               byte value)
                        throws IOException
        Writes specified byte value of specified number of bits.
        Parameters:
        unsigned - a flag for indicating unsigned value; true for unsigned, false for signed.
        size - the number of bits to write; between 1 and (8 - ( unsigned ? 1: 0)), both inclusive.
        value - the value to write.
        Throws:
        IOException - if an I/O error occurs.
      • writeByte

        default void writeByte​(int size,
                               byte value)
                        throws IOException
        Writes specified signed byte value of specified number of bits.
        Parameters:
        size - the number of bits to write; between 1 and 8, both inclusive.
        value - the value to write.
        Throws:
        IOException - if an I/O error occurs.
      • writeByte8

        default void writeByte8​(byte value)
                         throws IOException
        Writes specified 8-bit signed byte value.
        Parameters:
        value - the 8-bit signed byte value to write.
        Throws:
        IOException - if an I/O error occurs.
      • writeUnsignedByte

        default void writeUnsignedByte​(int size,
                                       byte value)
                                throws IOException
        Writes specified unsigned byte value of specified bit size.
        Parameters:
        size - the number of lower bits to write; between 1 (inclusive) and 8 (exclusive).
        value - the value to write.
        Throws:
        IOException - if an I/O error occurs.
      • writeShort

        default void writeShort​(boolean unsigned,
                                int size,
                                short value)
                         throws IOException
        Writes specified short value of specified number of bits.
        Parameters:
        unsigned - a flag for indicating unsigned value; true for unsigned, false for signed.
        size - the number of bits to write; between 1 and (16 - ( unsigned ? 1 : 0)), both inclusive.
        value - the value to write.
        Throws:
        IOException - if an I/O error occurs.
      • writeShort

        default void writeShort​(int size,
                                short value)
                         throws IOException
        Writes specified signed short value of specified number of bits.
        Parameters:
        size - the number of bits to write; between 1 and (16, both inclusive.
        value - the value to write.
        Throws:
        IOException - if an I/O error occurs.
      • writeShort16

        default void writeShort16​(short value)
                           throws IOException
        Writes specified 16-bit signed short value.
        Parameters:
        value - the 16-bit signed short value to write.
        Throws:
        IOException - if an I/O error occurs.
        See Also:
        writeShort(int, short)
      • writeShort16Le

        @Deprecated
        default void writeShort16Le​(short value)
                             throws IOException
        Deprecated.
        Reverse specified value's bytes with Short.reverseBytes(short) method and writes the result with writeShort16(short) method.
        Writes specified 16-bit signed short value in little endian byte order.
        Parameters:
        value - the 16-bit signed short value to write.
        Throws:
        IOException - if an I/O error occurs.
      • writeUnsignedShort

        default void writeUnsignedShort​(int size,
                                        short value)
                                 throws IOException
        Writes specified unsigned short value of specified bit size.
        Parameters:
        size - the number of bits to write; between 1 (inclusive) and 16 (exclusive).
        value - the value to write.
        Throws:
        IOException - if an I/O error occurs.
      • writeInt

        void writeInt​(boolean unsigned,
                      int size,
                      int value)
               throws IOException
        Writes specified int value of specified number of bits.
        Parameters:
        unsigned - a flag for indicating unsigned value; true for unsigned, false for signed.
        size - the number of bits to write; between 1 and (32 - ( unsigned ? 1 : 0)), both inclusive.
        value - the value to write.
        Throws:
        IOException - if an I/O error occurs.
      • writeInt

        default void writeInt​(int size,
                              int value)
                       throws IOException
        Writes specified signed int value of specified bit size.
        Parameters:
        size - the number of bits to write; between 1 and 32, both inclusive.
        value - the value to write.
        Throws:
        IOException - if an I/O error occurs.
      • writeInt32

        default void writeInt32​(int value)
                         throws IOException
        Writes specified 32-bit signed value.
        Parameters:
        value - the value to write.
        Throws:
        IOException - if an I/O error occurs.
      • writeUnsignedInt

        default void writeUnsignedInt​(int size,
                                      int value)
                               throws IOException
        Writes specified unsigned int value of specified bit size.
        Parameters:
        size - the number of bits to write; between 1 (inclusive) and 32 (exclusive).
        value - the value to write.
        Throws:
        IOException - if an I/O error occurs.
      • writeLong

        default void writeLong​(boolean unsigned,
                               int size,
                               long value)
                        throws IOException
        Writes specified long value of specified number of bits.
        Parameters:
        unsigned - a flag for indicating unsigned value; true for unsigned, false for signed.
        size - the number of bits to write; between 1 and (64 - ( unsigned ? 1 : 0)), both inclusive.
        value - the value to write.
        Throws:
        IOException - if an I/O error occurs.
      • writeLong

        default void writeLong​(int size,
                               long value)
                        throws IOException
        Writes specified signed long value of specified bit size.
        Parameters:
        size - the number of bits to write; between 1 and 64, both inclusive.
        value - the value to write.
        Throws:
        IOException - if an I/O error occurs.
      • writeLong64

        default void writeLong64​(long value)
                          throws IOException
        Writes specified 64-bit signed long value.
        Parameters:
        value - the value to write.
        Throws:
        IOException - if an I/O error occurs.
      • writeLong64Le

        @Deprecated
        default void writeLong64Le​(long value)
                            throws IOException
        Deprecated.
        Reverse specified value's bytes using Long.reverseBytes(long) method and write the result with writeLong64(long) method.
        Writes specified 64-bit signed long value in little endian byte order.
        Parameters:
        value - the value to write.
        Throws:
        IOException - if an I/O error occurs.
      • writeUnsignedLong

        default void writeUnsignedLong​(int size,
                                       long value)
                                throws IOException
        Writes specified unsigned long value of specified bit size.
        Parameters:
        size - the number of bits to write; between 1 (inclusive) and 64 (exclusive).
        value - the value to write.
        Throws:
        IOException - if an I/O error occurs.
      • writeChar

        default void writeChar​(int size,
                               char value)
                        throws IOException
        Writes specified char value of specified bit size.
        Parameters:
        size - the number of bits to write; between 1 and 16, both inclusive.
        value - the value to write.
        Throws:
        IOException - if an I/O error occurs.
        See Also:
        writeChar16(char)
      • writeChar16

        default void writeChar16​(char value)
                          throws IOException
        Writes specified 16-bit char value.
        Parameters:
        value - the value to write.
        Throws:
        IOException - if an I/O error occurs.
        See Also:
        writeChar(int, char)
      • writeValue

        default <T> void writeValue​(ValueAdapter<? super T> adapter,
                                    T value)
                             throws IOException
        Writes specified value using specified adapter. The writeValue(ValueAdapter, T) method of BitOutput interface invokes ValueWriter.write(BitOutput, Object) with this and specified value.
        Type Parameters:
        T - value type parameter
        Parameters:
        adapter - the adapter.
        value - the value to write.
        Throws:
        IOException - if an I/O error occurs.
      • skip

        default void skip​(int bits)
                   throws IOException
        Skips specified number of bits by padding zero bits.
        Parameters:
        bits - the number of bit to skip; must be positive.
        Throws:
        IllegalArgumentException - if bits is not positive.
        IOException - if an I/O error occurs.
      • align

        long align​(int bytes)
            throws IOException
        Aligns to specified number of bytes by padding zero bits.
        Parameters:
        bytes - the number of bytes to align; must be positive.
        Returns:
        the number of bits padded while aligning.
        Throws:
        IllegalArgumentException - if bytes is not positive.
        IOException - if an I/O error occurs.
      • align

        default long align()
                    throws IOException
        Aligns to a single byte by padding zero bits. The align() method of BitOutput interface invokes align(int) with 1.
        Returns:
        the number of bits padded while aligning.
        Throws:
        IOException - if an I/O error occurs.
        See Also:
        align(int)