Class HttpStatus


  • public class HttpStatus
    extends java.lang.Object
    Represents an HTTP status code.

    To find the HTTP status code of a Response object, use the Response.getResult() method.

    HTTP status codes are defined by RFC 2616.

    • Constructor Summary

      Constructors 
      Constructor Description
      HttpStatus​(long cPtr, boolean cMemoryOwn)
      For internal use only.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int code()
      Gets the numeric code for this HttpStatus.
      void delete()  
      java.lang.String description()
      Gets the text that describes the status.
      static HttpStatus find​(int code)
      Finds the HttpStatus with the specified code.
      static HttpStatus find​(java.lang.String code)
      Finds the HttpStatus with the specified code.
      static long getCPtr​(HttpStatus obj)
      For internal use only.
      boolean isAuthenticationRequired()
      Returns true if the status represents a request from the server for the caller to authenticate themselves.
      boolean isError()
      Returns true if the status has a code of 400 or above
      boolean isFullfilled()
      Returns true if the request has been generally satisfied.
      boolean isInformational()
      Returns true if the status has a code in the 100s.
      boolean isInRange​(HttpStatus from, HttpStatus to)
      Returns true if this HttpStatus is ordered between the supplied pair of HttpStatus objects.
      boolean isPossibleToCache()
      Returns true if this HttpStatus could cause the state of the cache to change.
      boolean isRedirection()
      Returns true if the status has a code in the 300s.
      boolean isSuccess()
      Returns true if the status has a code in the 200s.
      boolean isValid()
      Returns true if this HttpStatus represents a known standard response status.
      java.lang.String name()
      Gets the recommended text that is to be displayed next to the numeric code at the top of the response.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

    • Constructor Detail

      • HttpStatus

        public HttpStatus​(long cPtr,
                          boolean cMemoryOwn)
        For internal use only. Of no interest to the user.
        Parameters:
        cPtr - pointer to the CPP wrapped object
        cMemoryOwn - indicates if this object is responsible for memory management of the CPP object
    • Method Detail

      • getCPtr

        public static long getCPtr​(HttpStatus obj)
        For internal use only. Of no interest to the user.
        Parameters:
        obj - a reference to an object of this class
        Returns:
        a long containing the address of the CPP wrapped object
      • delete

        public void delete()
      • find

        public static HttpStatus find​(int code)
        Finds the HttpStatus with the specified code.
        Parameters:
        code - the code to look for
        Returns:
        an HttpStatus object with the specified code
      • find

        public static HttpStatus find​(java.lang.String code)
        Finds the HttpStatus with the specified code.
        Parameters:
        code - the code to look for
        Returns:
        an HttpStatus object with the specified code
      • code

        public int code()
        Gets the numeric code for this HttpStatus.
        Returns:
        the numeric code for this HttpStatus
      • name

        public java.lang.String name()
        Gets the recommended text that is to be displayed next to the numeric code at the top of the response.
        Returns:
        the recommended text that is to be displayed next to the numeric code at the top of the response
      • description

        public java.lang.String description()
        Gets the text that describes the status.
        Returns:
        the text that describes the status
      • isValid

        public boolean isValid()
        Returns true if this HttpStatus represents a known standard response status.
        Returns:
        true if this HttpStatus represents a known standard response status
      • isPossibleToCache

        public boolean isPossibleToCache()
        Returns true if this HttpStatus could cause the state of the cache to change.

        Note that could mean removing data from the cache as well as putting data into the cache.

        Returns:
        true if this HttpStatus could cause the state of the cache to change
      • isAuthenticationRequired

        public boolean isAuthenticationRequired()
        Returns true if the status represents a request from the server for the caller to authenticate themselves.
        Returns:
        true if the status represents a request from the server for the caller to authenticate themselves
      • isFullfilled

        public boolean isFullfilled()
        Returns true if the request has been generally satisfied.

        This means that the call was successful (200s code) or lead to a redirection (300s).

        Returns:
        true if the request has been generally satisfied
      • isInformational

        public boolean isInformational()
        Returns true if the status has a code in the 100s.
        Returns:
        true if the status has a code in the 100s
      • isSuccess

        public boolean isSuccess()
        Returns true if the status has a code in the 200s.
        Returns:
        true if the status has a code in the 200s
      • isRedirection

        public boolean isRedirection()
        Returns true if the status has a code in the 300s.
        Returns:
        true if the status has a code in the 300s
      • isError

        public boolean isError()
        Returns true if the status has a code of 400 or above
        Returns:
        true if the status has a code of 400 or above
      • isInRange

        public boolean isInRange​(HttpStatus from,
                                 HttpStatus to)
        Returns true if this HttpStatus is ordered between the supplied pair of HttpStatus objects.

        The HttpStatus objects are ordered by their code() and the range is inclusive of both of the specified HttpStatus objects. No order is assumed for the from and to objects.

        e.g.

        
         if (response.getResult().isInRange(HttpStatus.BAD_REQUEST, HttpStatus.UNSUPPORTED_MEDIA))
         {
             error("A client error occurred");
         }
         
        Parameters:
        from - the start of the range
        to - the end of the range
        Returns:
        true if this HttpStatus is ordered between the supplied pair of HttpStatus objects
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object