public Builder setMaxFrameSize(final int maxFrameSize) { this.maxFrameSize = Args.checkRange(maxFrameSize, FrameConsts.MIN_FRAME_SIZE, FrameConsts.MAX_FRAME_SIZE, "Invalid max frame size"); return this; }
/** * Checks a port number. * * @param port * The port to check. * @return the port * * @throws IllegalArgumentException * If the port parameter is outside the specified range of valid port values, which is between 0 and * 65535, inclusive. */ public static int check(final int port) { return Args.checkRange(port, MIN_VALUE, MAX_VALUE, "Port number"); }
/** * Checks a port number where {@code -1} indicates the scheme default port. * * @param port * The port to check where {@code -1} indicates the scheme default port. * @return the port * * @throws IllegalArgumentException * If the port parameter is outside the specified range of valid port values, which is between 0 and * 65535, inclusive. {@code -1} indicates the scheme default port. */ public static int checkWithDefault(final int port) { return Args.checkRange(port, SCHEME_DEFAULT, MAX_VALUE, "Port number(Use -1 to specify the scheme default port)"); }
/** * Checks a port number. * * @param port * The port to check. * @return the port * * @throws IllegalArgumentException * If the port parameter is outside the specified range of valid port values, which is between 0 and * 65535, inclusive. */ public static int check(final int port) { return Args.checkRange(port, MIN_VALUE, MAX_VALUE, "Port number"); }
/** * Checks a port number where {@code -1} indicates the scheme default port. * * @param port * The port to check where {@code -1} indicates the scheme default port. * @return the port * * @throws IllegalArgumentException * If the port parameter is outside the specified range of valid port values, which is between 0 and * 65535, inclusive. {@code -1} indicates the scheme default port. */ public static int checkWithDefault(final int port) { return Args.checkRange(port, SCHEME_DEFAULT, MAX_VALUE, "Port number(Use -1 to specify the scheme default port)"); }
/** * Obtains the reason phrase for a status code. * * @param status the status code, in the range 100-599 * @param loc ignored * * @return the reason phrase, or {@code null} */ @Override public String getReason(final int status, final Locale loc) { Args.checkRange(status, 100, 599, "Unknown category for status code"); final int category = status / 100; final int subcode = status - 100*category; String reason = null; if (REASON_PHRASES[category].length > subcode) { reason = REASON_PHRASES[category][subcode]; } return reason; }
public static long checkContentLength(final EntityDetails entityDetails) { // -1 is a special value // 0 is allowed as well return checkRange(entityDetails.getContentLength(), -1, Integer.MAX_VALUE, "HTTP entity too large to be buffered in memory)"); }
public static long checkContentLength(final EntityDetails entityDetails) { // -1 is a special value // 0 is allowed as well return checkRange(entityDetails.getContentLength(), -1, Integer.MAX_VALUE, "HTTP entity too large to be buffered in memory)"); }
public void testIntSmallestRangeOK() { Args.checkRange(0, 0, 0, "Number"); }
public void testLongSmallestRangeOK() { Args.checkRange(0L, 0L, 0L, "Number"); }
public void testLongFullRangeOK() { Args.checkRange(0L, Long.MIN_VALUE, Long.MAX_VALUE, "Number"); }
public void testIntFullRangeOK() { Args.checkRange(0, Integer.MIN_VALUE, Integer.MAX_VALUE, "Number"); }
@Test(expected = IllegalArgumentException.class) public void testIntRangeFailHigh() { Args.checkRange(101, -100, 100, "Number"); }
@Test(expected = IllegalArgumentException.class) public void testIntSmallestRangeFailLow() { Args.checkRange(-1, 0, 0, "Number"); }
@Test(expected = IllegalArgumentException.class) public void testLongRangeFailLow() { Args.checkRange(-101L, -100L, 100L, "Number"); }
@Test(expected = IllegalArgumentException.class) public void testIntRangeFailLow() { Args.checkRange(-101, -100, 100, "Number"); }
@Test(expected = IllegalArgumentException.class) public void testLongSmallestRangeFailLow() { Args.checkRange(-1L, 0L, 0L, "Number"); }
@Test(expected = IllegalArgumentException.class) public void testIntSmallestRangeFailHigh() { Args.checkRange(1, 0, 0, "Number"); }
@Test(expected = IllegalArgumentException.class) public void testLongRangeFailHigh() { Args.checkRange(101L, -100L, 100L, "Number"); }
@Test(expected = IllegalArgumentException.class) public void testLongSmallestRangeFailHigh() { Args.checkRange(1L, 0L, 0L, "Number"); }