Class StatusCode

java.lang.Object
net.thauvin.erik.httpstatus.StatusCode
All Implemented Interfaces:
Serializable

public class StatusCode extends Object implements Serializable
The StatusCode bean implements methods to check the class of an HTTP status code.
Since:
1.1.0
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new StatusCode object.
    StatusCode(int code)
    Creates a new StatusCode object.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Returns the status code.
    Returns the reason for the status code.
    static String
    getReason(int code)
    Returns the reason for the status code.
    boolean
    Checks if the status code is a client error.
    static boolean
    isClientError(int code)
    Checks if the status code is a client error.
    boolean
    Checks if the status code is a client or server error.
    static boolean
    isError(int code)
    Checks if the status code is a client or server error.
    boolean
    Checks if the status code is informational.
    static boolean
    isInfo(int code)
    Checks if the status code is informational.
    boolean
    Checks if the status code is informational.
    static boolean
    isInformational(int code)
    Checks if the status code is informational.
    boolean
    Checks if the status code is a redirect.
    static boolean
    isRedirect(int code)
    Checks if the status code is a redirect.
    boolean
    Checks if the status code is a server error.
    static boolean
    isServerError(int code)
    Checks if the status code is a server error.
    boolean
    Checks if the status code is a (OK) success.
    static boolean
    isSuccess(int code)
    Checks if the status code is a (OK) success.
    boolean
    Checks if the status code is a (OK) success.
    static boolean
    isSuccessful(int code)
    Checks if the status code is a (OK) success.
    boolean
    Checks if the status code is valid.
    static boolean
    isValid(int code)
    Checks if the status code is valid.
    void
    setCode(int code)
    Sets the status code.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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

      public static String getReason(int code)
      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:
      true if the status code is a client error, false otherwise
      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:
      true if the status code is an error, false otherwise
      Since:
      2.0.0
    • isInfo

      public static boolean isInfo(int code)
      Checks if the status code is informational.
      Parameters:
      code - the status code
      Returns:
      true if the status code is informational, false otherwise
      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:
      true if 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:
      true if the status code is a redirect, false otherwise
      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:
      true if the status code is a server error, false otherwise
      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:
      true if the status code is a success, false otherwise
      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:
      true if the status code is a success, false otherwise
      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:
      true if the status code is valid, false otherwise
    • getCode

      public int getCode()
      Returns the status code.
    • getReason

      public String 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:
      true if the status code is a client error, false otherwise
    • isError

      public boolean isError()
      Checks if the status code is a client or server error.
      Returns:
      true if the status code is an error, false otherwise
    • isInfo

      public boolean isInfo()
      Checks if the status code is informational.
      Returns:
      true if the status code is informational, false otherwise
    • isInformational

      public boolean isInformational()
      Checks if the status code is informational.
      Returns:
      true if the status code is informational, false otherwise
      Since:
      2.0.0
    • isRedirect

      public boolean isRedirect()
      Checks if the status code is a redirect.
      Returns:
      true if the status code is a redirect, false otherwise
    • isServerError

      public boolean isServerError()
      Checks if the status code is a server error.
      Returns:
      true if the status code is a server error, false otherwise
    • isSuccess

      public boolean isSuccess()
      Checks if the status code is a (OK) success.
      Returns:
      true if the status code is a success, false otherwise
    • isSuccessful

      public boolean isSuccessful()
      Checks if the status code is a (OK) success.
      Returns:
      true if the status code is a success, false otherwise
      Since:
      2.0.0
    • isValid

      public boolean isValid()
      Checks if the status code is valid.
      Returns:
      true if the status code is valid, false otherwise
    • setCode

      public void setCode(int code)
      Sets the status code.
      Parameters:
      code - The HTTP status code