private void update ( ByteBuffer buffer ) { int pos = buffer . position ( ) ; int limit = buffer . limit ( ) ; assert ( pos <= limit ) ; int rem = limit - pos ; if ( rem <= 0 ) return ; if ( buffer instanceof DirectBuffer ) { adler = updateByteBuffer ( adler , ( ( DirectBuffer ) buffer ) . address ( ) , pos , rem ) ; } else if ( buffer . hasArray ( ) ) { adler = updateBytes ( adler , buffer . array ( ) , pos + buffer . arrayOffset ( ) , rem ) ; } else { byte [ ] b = new byte [ rem ] ; buffer . get ( b ) ; adler = updateBytes ( adler , b , 0 , b . length ) ; } buffer . position ( limit ) ; }
Updates the checksum with the bytes from the specified buffer .