All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.schlichtherle.util.zip.UInt Maven / Gradle / Ivy

Go to download

TrueZIP is a Java based Virtual File System (VFS) to enable transparent, multi-threaded read/write access to archive files (ZIP, TAR etc.) as if they were directories. Archive files may be arbitrarily nested and the nesting level is only limited by heap and file system size.

The newest version!
/*
 * Copyright (C) 2007-2010 Schlichtherle IT Services
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package de.schlichtherle.util.zip;

/**
 * Provides constants and static utility methods for unsigned integer
 * values ({@value SIZE} bits).
 * 

* This class is safe for multithreading. * * @author Christian Schlichtherle * @version $Id$ * @since TrueZIP 6.7 */ final class UInt { /** * The minimum value of an unsigned integer, * which is {@value MIN_VALUE}. */ public static final long MIN_VALUE = 0x00000000L; /** * The maximum value of an unsigned integer, * which is {@value MAX_VALUE}. */ public static final long MAX_VALUE = 0xffffffffL; /** * The number of bits used to represent an unsigned integer in * binary form, which is {@value SIZE}. */ public static final int SIZE = 32; /** This class cannot get instantiated. */ private UInt() { } /** * Checks the parameter range. * * @param l The long integer to check to be in the range of an unsigned * integer ({@value SIZE} bits). * @param subject The subject of the exception message * - may be {@code null}. * This should not end with a punctuation character. * @param error First sentence of the exception message * - may be {@code null}. * This should not end with a punctuation character. * @throws IllegalArgumentException If {@code l} is less than * {@link #MIN_VALUE} or greater than {@link #MAX_VALUE}. */ public static void check( final long l, final String subject, final String error) throws IllegalArgumentException { if (MIN_VALUE <= l && l <= MAX_VALUE) return; final StringBuffer message = new StringBuffer(); if (subject != null) { message.append(subject); message.append(": "); } if (error != null) { message.append(error); message.append(": "); } message.append(l); message.append(" is not within "); message.append(MIN_VALUE); message.append(" and "); message.append(MAX_VALUE); message.append(" inclusively."); throw new IllegalArgumentException(message.toString()); } /** * Checks the parameter range. * * @param l The long integer to check to be in the range of an unsigned * integer ({@value SIZE} bits). * @throws IllegalArgumentException If {@code l} is less than * {@link #MIN_VALUE} or greater than {@link #MAX_VALUE}. */ public static void check(final long l) throws IllegalArgumentException { check(l, "Long integer out of range", null); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy