Package ej.ecom.io

Interface BitsOutput


  • public interface BitsOutput
    This interface defines methods for writing data bits.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      int getLength()
      Returns the data length in bits (1 to 32 bits).
      void writeBits​(byte[] data, boolean signExtends)
      Writes data.length data from the specified short array to this output stream.
      void writeBits​(byte[] data, int off, int len, boolean signExtends)
      Writes len data from the specified short array starting at offset off to this output stream.
      void writeBits​(int val)
      The data to send is masked using the following formula:
      val &= (1 << getLength()) - 1
      void writeBits​(int[] data)
      Writes data.length data from the specified integer array to this output stream.
      void writeBits​(int[] data, int off, int len)
      Writes len data from the specified integer array starting at offset off to this output stream.
      void writeBits​(short[] data, boolean signExtends)
      Writes data.length data from the specified short array to this output stream.
      void writeBits​(short[] data, int off, int len, boolean signExtends)
      Writes len data from the specified short array starting at offset off to this output stream.
    • Method Detail

      • getLength

        int getLength()
        Returns the data length in bits (1 to 32 bits).
        Returns:
        the data length in bits (1 to 32 bits).
      • writeBits

        void writeBits​(int val)
                throws IOException
        The data to send is masked using the following formula:
        val &= (1 << getLength()) - 1
        Throws:
        IOException - if an I/O error occurs. In particular, an IOException may be thrown if the output stream has been closed.
      • writeBits

        void writeBits​(int[] data)
                throws IOException
        Writes data.length data from the specified integer array to this output stream. The general contract for writeBits(data) is that it should have exactly the same effect as the call writeBits(data, 0, data.length).
        Parameters:
        data - the data to send
        Throws:
        IOException - if an I/O error occurs. In particular, an IOException may be thrown if the output stream has been closed.
      • writeBits

        void writeBits​(int[] data,
                       int off,
                       int len)
                throws IOException
        Writes len data from the specified integer array starting at offset off to this output stream. The general contract for writeBits(b, off, len) is that some of the data in the array data are written to the output stream in order; element data[off] is the first byte written and b[off+len-1] is the last data written by this operation.

        The write method of OutputStream calls the write method of one argument on each of the data to be written out. Subclasses are encouraged to override this method and provide a more efficient implementation.

        If data is null, a NullPointerException is thrown.

        If off is negative, or len is negative, or off+len is greater than the length of the array data, then an IndexOutOfBoundsException is thrown.
        Parameters:
        data - the data to send
        off - the start offset in the data.
        len - the number of data to write.
        Throws:
        IOException - if an I/O error occurs. In particular, an IOException is thrown if the output stream is closed.
      • writeBits

        void writeBits​(short[] data,
                       boolean signExtends)
                throws IOException
        Writes data.length data from the specified short array to this output stream. The general contract for writeBits(data, signExtends) is that it should have exactly the same effect as the call writeBits(b, 0, b.length, signExtends).
        Parameters:
        data - the data to send
        signExtends - true to sign-extend the data in case of getLength() > 16 (short size)
        Throws:
        IOException - if an I/O error occurs. In particular, an IOException may be thrown if the output stream has been closed.
      • writeBits

        void writeBits​(short[] data,
                       int off,
                       int len,
                       boolean signExtends)
                throws IOException
        Writes len data from the specified short array starting at offset off to this output stream. The general contract for writeBits(b, off, len, signExtends) is that some of the data in the array data are written to the output stream in order; element data[off] is the first byte written and b[off+len-1] is the last data written by this operation.

        The write method of OutputStream calls the write method of one argument on each of the data to be written out. Subclasses are encouraged to override this method and provide a more efficient implementation.

        If data is null, a NullPointerException is thrown.

        If off is negative, or len is negative, or off+len is greater than the length of the array data, then an IndexOutOfBoundsException is thrown.
        If getLength() is higher than 16 (short size), the data will are sign extended or not according signExtends boolean.
        Parameters:
        data - the data to send
        off - the start offset in the data.
        len - the number of data to write.
        signExtends - true to sign-extend the data in case of getLength() > 16 (short size)
        Throws:
        IOException - if an I/O error occurs. In particular, an IOException is thrown if the output stream is closed.
      • writeBits

        void writeBits​(byte[] data,
                       boolean signExtends)
                throws IOException
        Writes data.length data from the specified short array to this output stream. The general contract for writeBits(data, signExtends) is that it should have exactly the same effect as the call writeBits(b, 0, b.length, signExtends).
        Parameters:
        data - the data to send
        signExtends - true to sign-extend the data in case of getLength() > 8 (byte size)
        Throws:
        IOException - if an I/O error occurs. In particular, an IOException may be thrown if the output stream has been closed.
      • writeBits

        void writeBits​(byte[] data,
                       int off,
                       int len,
                       boolean signExtends)
                throws IOException
        Writes len data from the specified short array starting at offset off to this output stream. The general contract for writeBits(b, off, len, signExtends) is that some of the data in the array data are written to the output stream in order; element data[off] is the first byte written and b[off+len-1] is the last data written by this operation.

        The write method of OutputStream calls the write method of one argument on each of the data to be written out. Subclasses are encouraged to override this method and provide a more efficient implementation.

        If data is null, a NullPointerException is thrown.

        If off is negative, or len is negative, or off+len is greater than the length of the array data, then an IndexOutOfBoundsException is thrown.
        If getLength() is higher than 8 (byte size), the data will are sign extended or not according signExtends boolean.
        Parameters:
        data - the data to send
        off - the start offset in the data.
        len - the number of data to write.
        signExtends - true to sign-extend the data in case of getLength() > 8 (byte size)
        Throws:
        IOException - if an I/O error occurs. In particular, an IOException is thrown if the output stream is closed.