Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/sun/util/calendar/zi/Checksum.java
38855 views
/*1* Copyright (c) 2000, 2013, 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. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425import java.util.zip.CRC32;2627/**28* Checksum provides methods for calculating a CRC32 value for a29* transitions table.30*31* @since 1.432*/33public class Checksum extends CRC3234{35/**36* Updates the CRC32 value from each byte of the given int37* value. The bytes are used in the big endian order.38* @param val the int value39*/40public void update(int val) {41byte[] b = new byte[4];42b[0] = (byte)((val >>> 24) & 0xff);43b[1] = (byte)((val >>> 16) & 0xff);44b[2] = (byte)((val >>> 8) & 0xff);45b[3] = (byte)(val & 0xff);46update(b);47}4849/**50* Updates the CRC32 value from each byte of the given long51* value. The bytes are used in the big endian order.52* @param val the long value53*/54void update(long val) {55byte[] b = new byte[8];56b[0] = (byte)((val >>> 56) & 0xff);57b[1] = (byte)((val >>> 48) & 0xff);58b[2] = (byte)((val >>> 40) & 0xff);59b[3] = (byte)((val >>> 32) & 0xff);60b[4] = (byte)((val >>> 24) & 0xff);61b[5] = (byte)((val >>> 16) & 0xff);62b[6] = (byte)((val >>> 8) & 0xff);63b[7] = (byte)(val & 0xff);64update(b);65}66}676869