question: private static int calculateChecksum ( final String tagString , final ByteBuffer data ) { int sum = 0 ; data . mark ( ) ; if ( tagString . equals ( "head" ) ) { data . putInt ( 8 , 0 ) ; } for ( int i = 0 , nlongs = ( data . remaining ( ) + 3 ) / 4 ; i < nlongs ; ++ i ) { switch ( data . remaining ( ) ) { case 3 : sum += ( ( data . getShort ( ) << 16 ) + ( data . get ( ) << 8 ) ) ; break ; case 2 : sum += ( data . getShort ( ) << 16 ) ; break ; case 1 : sum += ( ( data . get ( ) & 0xff ) << 24 ) ; break ; default : sum += data . getInt ( ) ; } } data . reset ( ) ; return sum ; }
target:  Calculate the checksum for a given table