/** * Checks whether the arguments are valid. * * @param version the IP address version * @param value the IP address value stored in a byte array * @param offset the offset in bytes from the beginning of the byte * array with the address * @throws IllegalArgumentException if any of the arguments is invalid */ static void checkArguments(Version version, byte[] value, int offset) { // Check the offset and byte array length int addrByteLength = byteLength(version); if ((offset < 0) || (offset + addrByteLength > value.length)) { String msg; if (value.length < addrByteLength) { msg = "Invalid " + addressName(version) + " address array: array length: " + value.length + ". Must be at least " + addrByteLength; } else { msg = "Invalid " + addressName(version) + " address array: array offset: " + offset + ". Must be in the interval [0, " + (value.length - addrByteLength) + "]"; } throw new IllegalArgumentException(msg); } }