Path: blob/master/test/jdk/sun/util/calendar/zi/Checksum.java
41153 views
/*1* Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223import java.util.zip.CRC32;2425/**26* Checksum provides methods for calculating a CRC32 value for a27* transitions table.28*29* @since 1.430*/31public class Checksum extends CRC3232{33/**34* Updates the CRC32 value from each byte of the given int35* value. The bytes are used in the big endian order.36* @param val the int value37*/38public void update(int val) {39byte[] b = new byte[4];40b[0] = (byte)((val >>> 24) & 0xff);41b[1] = (byte)((val >>> 16) & 0xff);42b[2] = (byte)((val >>> 8) & 0xff);43b[3] = (byte)(val & 0xff);44update(b);45}4647/**48* Updates the CRC32 value from each byte of the given long49* value. The bytes are used in the big endian order.50* @param val the long value51*/52void update(long val) {53byte[] b = new byte[8];54b[0] = (byte)((val >>> 56) & 0xff);55b[1] = (byte)((val >>> 48) & 0xff);56b[2] = (byte)((val >>> 40) & 0xff);57b[3] = (byte)((val >>> 32) & 0xff);58b[4] = (byte)((val >>> 24) & 0xff);59b[5] = (byte)((val >>> 16) & 0xff);60b[6] = (byte)((val >>> 8) & 0xff);61b[7] = (byte)(val & 0xff);62update(b);63}64}656667