Interface BitCodec<T>

  • Type Parameters:
    T - data series type to be read or written
    All Known Implementing Classes:
    AbstractBitCodec, ByteArrayStopEncoding.ByteArrayStopCodec

    public interface BitCodec<T>
    An interface that defines requirements for serializing/deserializing objects into and from a bit stream.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      long numberOfBits​(T object)
      Calculate the number of bits that the object would take in bit serialized form.
      T read​(BitInputStream bitInputStream)
      Read a single object from the bit stream.
      T read​(BitInputStream bitInputStream, int valueLen)
      Read a array of specified length from the bit stream.
      void readInto​(BitInputStream bitInputStream, byte[] array, int offset, int valueLen)
      Read a array of specified length from the bit stream into a given byte array.
      void skip​(BitInputStream bitInputStream)
      Skip the next object in the bit stream.
      void skip​(BitInputStream bitInputStream, int length)
      Skip the next length objects in the bit stream.
      long write​(BitOutputStream bitOutputStream, T object)
      Write an object into the bit stream
    • Method Detail

      • read

        T read​(BitInputStream bitInputStream)
        throws IOException
        Read a single object from the bit stream.
        Parameters:
        bitInputStream - the bit input stream to rad from
        Returns:
        an object from the stream
        Throws:
        IOException - as per java IO contract
      • read

        T read​(BitInputStream bitInputStream,
               int valueLen)
        throws IOException
        Read a array of specified length from the bit stream.
        Parameters:
        bitInputStream - the bit input stream to rad from param valueLen the number of elements to read
        Returns:
        an object from the stream
        Throws:
        IOException - as per java IO contract
      • readInto

        void readInto​(BitInputStream bitInputStream,
                      byte[] array,
                      int offset,
                      int valueLen)
               throws IOException
        Read a array of specified length from the bit stream into a given byte array. This method is a way to optimize byte array IO operations by bypassing abstraction. Leaky, I know.
        Parameters:
        bitInputStream - the bit input stream to rad from
        array - the array to read into
        offset - offset in the array
        valueLen - number of elements to read
        Throws:
        IOException - as per java IO contract
      • skip

        void skip​(BitInputStream bitInputStream)
           throws IOException
        Skip the next object in the bit stream.
        Parameters:
        bitInputStream - the bit stream to operate on
        Throws:
        IOException - as per java IO contract
      • skip

        void skip​(BitInputStream bitInputStream,
                  int length)
           throws IOException
        Skip the next length objects in the bit stream.
        Parameters:
        bitInputStream - the bit stream to operate on
        length - the number of objects to skip
        Throws:
        IOException - as per java IO contract
      • write

        long write​(BitOutputStream bitOutputStream,
                   T object)
            throws IOException
        Write an object into the bit stream
        Parameters:
        bitOutputStream - the output bit stream to write to
        object - the object to write
        Returns:
        the number of bits written out
        Throws:
        IOException - as per java IO contract
      • numberOfBits

        long numberOfBits​(T object)
        Calculate the number of bits that the object would take in bit serialized form.
        Parameters:
        object - an object
        Returns:
        the number of bits