Package net.thauvin.erik.httpstatus
Class StatusCode
java.lang.Object
net.thauvin.erik.httpstatus.StatusCode
- All Implemented Interfaces:
Serializable
The
StatusCode bean implements methods to check the class of an HTTP status code.- Since:
- 1.1.0
- Author:
- Erik C. Thauvin
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new StatusCode object.StatusCode(int code) Creates a new StatusCode object. -
Method Summary
Modifier and TypeMethodDescriptionintgetCode()Returns the status code.Returns the reason for the status code.static StringgetReason(int code) Returns the reason for the status code.booleanChecks if the status code is a client error.static booleanisClientError(int code) Checks if the status code is a client error.booleanisError()Checks if the status code is a client or server error.static booleanisError(int code) Checks if the status code is a client or server error.booleanisInfo()Checks if the status code is informational.static booleanisInfo(int code) Checks if the status code is informational.booleanChecks if the status code is informational.static booleanisInformational(int code) Checks if the status code is informational.booleanChecks if the status code is a redirect.static booleanisRedirect(int code) Checks if the status code is a redirect.booleanChecks if the status code is a server error.static booleanisServerError(int code) Checks if the status code is a server error.booleanChecks if the status code is a (OK) success.static booleanisSuccess(int code) Checks if the status code is a (OK) success.booleanChecks if the status code is a (OK) success.static booleanisSuccessful(int code) Checks if the status code is a (OK) success.booleanisValid()Checks if the status code is valid.static booleanisValid(int code) Checks if the status code is valid.voidsetCode(int code) Sets the status code.
-
Constructor Details
-
StatusCode
public StatusCode()Creates a new StatusCode object. -
StatusCode
public StatusCode(int code) Creates a new StatusCode object.- Parameters:
code- the status code- Since:
- 2.0.0
-
-
Method Details
-
getReason
Returns the reason for the status code.- Parameters:
code- the status code- Returns:
- The reason, or
null - Since:
- 2.0.0
- See Also:
-
isClientError
public static boolean isClientError(int code) Checks if the status code is a client error. (e.g.:Internal Server Error)- Parameters:
code- the status code- Returns:
trueif the status code is a client error,falseotherwise- Since:
- 2.0.0
-
isError
public static boolean isError(int code) Checks if the status code is a client or server error.- Parameters:
code- the status code- Returns:
trueif the status code is an error,falseotherwise- Since:
- 2.0.0
-
isInfo
public static boolean isInfo(int code) Checks if the status code is informational.- Parameters:
code- the status code- Returns:
trueif the status code is informational,falseotherwise- Since:
- 2.0.0
- See Also:
-
isInformational
public static boolean isInformational(int code) Checks if the status code is informational.- Parameters:
code- the status code- Returns:
trueif the status code is informational,false- Since:
- 2.0.0
- See Also:
-
isRedirect
public static boolean isRedirect(int code) Checks if the status code is a redirect.- Parameters:
code- the status code- Returns:
trueif the status code is a redirect,falseotherwise- Since:
- 2.0.0
-
isServerError
public static boolean isServerError(int code) Checks if the status code is a server error.- Parameters:
code- the status code- Returns:
trueif the status code is a server error,falseotherwise- Since:
- 2.0.0
-
isSuccess
public static boolean isSuccess(int code) Checks if the status code is a (OK) success.- Parameters:
code- the status code- Returns:
trueif the status code is a success,falseotherwise- Since:
- 2.0.0
- See Also:
-
isSuccessful
public static boolean isSuccessful(int code) Checks if the status code is a (OK) success.- Parameters:
code- the status code- Returns:
trueif the status code is a success,falseotherwise- Since:
- 2.0.0
- See Also:
-
isValid
public static boolean isValid(int code) Checks if the status code is valid.- Parameters:
code- the status code- Returns:
trueif the status code is valid,falseotherwise
-
getCode
public int getCode()Returns the status code. -
getReason
Returns the reason for the status code.- Returns:
- The reason, or
null - See Also:
-
isClientError
public boolean isClientError()Checks if the status code is a client error. (e.g.:Internal Server Error)- Returns:
trueif the status code is a client error,falseotherwise
-
isError
public boolean isError()Checks if the status code is a client or server error.- Returns:
trueif the status code is an error,falseotherwise
-
isInfo
public boolean isInfo()Checks if the status code is informational.- Returns:
trueif the status code is informational,falseotherwise
-
isInformational
public boolean isInformational()Checks if the status code is informational.- Returns:
trueif the status code is informational,falseotherwise- Since:
- 2.0.0
-
isRedirect
public boolean isRedirect()Checks if the status code is a redirect.- Returns:
trueif the status code is a redirect,falseotherwise
-
isServerError
public boolean isServerError()Checks if the status code is a server error.- Returns:
trueif the status code is a server error,falseotherwise
-
isSuccess
public boolean isSuccess()Checks if the status code is a (OK) success.- Returns:
trueif the status code is a success,falseotherwise
-
isSuccessful
public boolean isSuccessful()Checks if the status code is a (OK) success.- Returns:
trueif the status code is a success,falseotherwise- Since:
- 2.0.0
-
isValid
public boolean isValid()Checks if the status code is valid.- Returns:
trueif the status code is valid,falseotherwise
-
setCode
public void setCode(int code) Sets the status code.- Parameters:
code- The HTTP status code
-