Class PendingBuffer

  • Direct Known Subclasses:
    DeflaterPending

    class PendingBuffer
    extends java.lang.Object
    This class is general purpose class for writing data to a buffer. It allows you to write bits as well as bytes Based on DeflaterPending.java
    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) int bitCount  
      (package private) int bits  
      protected byte[] buf  
      (package private) int end  
      (package private) int start  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void alignToByte()  
      int flush​(byte[] output, int offset, int length)
      Flushes the pending buffer into the given output array.
      int getBitCount()  
      boolean isFlushed()  
      void reset()  
      byte[] toByteArray()
      Flushes the pending buffer and returns that data in a new array
      void writeBits​(int b, int count)  
      void writeBlock​(byte[] block, int offset, int len)  
      void writeByte​(int b)  
      void writeInt​(int s)  
      void writeShort​(int s)  
      void writeShortMSB​(int s)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • buf

        protected byte[] buf
      • start

        int start
      • end

        int end
      • bits

        int bits
      • bitCount

        int bitCount
    • Constructor Detail

      • PendingBuffer

        public PendingBuffer()
      • PendingBuffer

        public PendingBuffer​(int bufsize)
    • Method Detail

      • reset

        public final void reset()
      • writeByte

        public final void writeByte​(int b)
      • writeShort

        public final void writeShort​(int s)
      • writeInt

        public final void writeInt​(int s)
      • writeBlock

        public final void writeBlock​(byte[] block,
                                     int offset,
                                     int len)
      • getBitCount

        public final int getBitCount()
      • alignToByte

        public final void alignToByte()
      • writeBits

        public final void writeBits​(int b,
                                    int count)
      • writeShortMSB

        public final void writeShortMSB​(int s)
      • isFlushed

        public final boolean isFlushed()
      • flush

        public final int flush​(byte[] output,
                               int offset,
                               int length)
        Flushes the pending buffer into the given output array. If the output array is to small, only a partial flush is done.
        Parameters:
        output - the output array;
        offset - the offset into output array;
        length - the maximum number of bytes to store;
        Throws:
        java.lang.IndexOutOfBoundsException - if offset or length are invalid.
      • toByteArray

        public final byte[] toByteArray()
        Flushes the pending buffer and returns that data in a new array
        Parameters:
        output - the output stream