/** * Checks the parameter range. * * @param l The long integer to check to be in the range of an unsigned * integer ({@value SIZE} bits). * @return {@code true} * @throws IllegalArgumentException If {@code l} is less than * {@link #MIN_VALUE} or greater than {@link #MAX_VALUE}. */ public static boolean check(final long l) { return check(l, "Long integer out of range", null); } }
final void setRawTime(final long dtime) { assert UInt.check(dtime); this.dtime = (int) dtime; setInit(DTIME, true); }
final void setRawCrc(final long crc) { assert UInt.check(crc); this.crc = (int) crc; setInit(CRC, true); }
public final void setCrc(final long crc) { final boolean known = UNKNOWN != crc; if (known) { UInt.check(crc, name, "CRC-32 out of range"); this.crc = (int) crc; } else { this.crc = 0; } setInit(CRC, known); }
final void setRawExternalAttributes(final long eattr) { assert UInt.check(eattr); this.eattr = (int) eattr; setInit(EATTR, true); }
/** * Sets the external file attributes. * * @param eattr the external file attributes. * @since TrueZIP 7.3 */ public final void setExternalAttributes(final long eattr) { final boolean known = UNKNOWN != eattr; if (known) { UInt.check(eattr, name, "external file attributes out of range"); this.eattr = (int) eattr; } else { this.eattr = 0; } setInit(EATTR, known); }
@Test public void testCheck() { try { UInt.check(UInt.MIN_VALUE - 1); fail("Expected IllegalArgumentException!"); } catch (IllegalArgumentException expected) { } UInt.check(UInt.MIN_VALUE); UInt.check(UInt.MAX_VALUE); try { UInt.check(UInt.MAX_VALUE + 1); fail("Expected IllegalArgumentException!"); } catch (IllegalArgumentException expected) { } } }