Class BufferedChecksum

  • All Implemented Interfaces:
    java.util.zip.Checksum

    public class BufferedChecksum
    extends java.lang.Object
    implements java.util.zip.Checksum
    Wraps another Checksum with an internal buffer to speed up checksum calculations.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private byte[] buffer  
      static int DEFAULT_BUFFERSIZE
      Default buffer size: 1024
      private java.util.zip.Checksum in  
      private int upto  
    • Constructor Summary

      Constructors 
      Constructor Description
      BufferedChecksum​(java.util.zip.Checksum in)
      Create a new BufferedChecksum with DEFAULT_BUFFERSIZE
      BufferedChecksum​(java.util.zip.Checksum in, int bufferSize)
      Create a new BufferedChecksum with the specified bufferSize
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private void flush()  
      long getValue()  
      void reset()  
      void update​(byte[] b, int off, int len)  
      void update​(int b)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.util.zip.Checksum

        update, update
    • Field Detail

      • in

        private final java.util.zip.Checksum in
      • buffer

        private final byte[] buffer
      • upto

        private int upto
      • DEFAULT_BUFFERSIZE

        public static final int DEFAULT_BUFFERSIZE
        Default buffer size: 1024
        See Also:
        Constant Field Values
    • Constructor Detail

      • BufferedChecksum

        public BufferedChecksum​(java.util.zip.Checksum in)
        Create a new BufferedChecksum with DEFAULT_BUFFERSIZE
      • BufferedChecksum

        public BufferedChecksum​(java.util.zip.Checksum in,
                                int bufferSize)
        Create a new BufferedChecksum with the specified bufferSize
    • Method Detail

      • update

        public void update​(int b)
        Specified by:
        update in interface java.util.zip.Checksum
      • update

        public void update​(byte[] b,
                           int off,
                           int len)
        Specified by:
        update in interface java.util.zip.Checksum
      • getValue

        public long getValue()
        Specified by:
        getValue in interface java.util.zip.Checksum
      • reset

        public void reset()
        Specified by:
        reset in interface java.util.zip.Checksum
      • flush

        private void flush()