Package com.facilita.fc.web
Class HttpStatus
- java.lang.Object
-
- com.facilita.fc.web.HttpStatus
-
public class HttpStatus extends java.lang.Object
Represents an HTTP status code.To find the HTTP status code of a
Response
object, use theResponse.getResult()
method.HTTP status codes are defined by RFC 2616.
-
-
Field Summary
Fields Modifier and Type Field Description static HttpStatus
NOT_SET
-
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 thisHttpStatus
.void
delete()
java.lang.String
description()
Gets the text that describes the status.static HttpStatus
find(int code)
Finds theHttpStatus
with the specifiedcode
.static HttpStatus
find(java.lang.String code)
Finds theHttpStatus
with the specifiedcode
.static long
getCPtr(HttpStatus obj)
For internal use only.boolean
isAuthenticationRequired()
Returnstrue
if the status represents a request from the server for the caller to authenticate themselves.boolean
isError()
Returnstrue
if the status has a code of400
or aboveboolean
isFullfilled()
Returnstrue
if the request has been generally satisfied.boolean
isInformational()
Returnstrue
if the status has a code in the100s
.boolean
isInRange(HttpStatus from, HttpStatus to)
Returnstrue
if thisHttpStatus
is ordered between the supplied pair ofHttpStatus
objects.boolean
isPossibleToCache()
Returnstrue
if thisHttpStatus
could cause the state of the cache to change.boolean
isRedirection()
Returnstrue
if the status has a code in the300s
.boolean
isSuccess()
Returnstrue
if the status has a code in the200s
.boolean
isValid()
Returnstrue
if thisHttpStatus
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()
-
-
-
Field Detail
-
NOT_SET
public static final HttpStatus NOT_SET
-
-
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 theHttpStatus
with the specifiedcode
.- Parameters:
code
- the code to look for- Returns:
- an
HttpStatus
object with the specifiedcode
-
find
public static HttpStatus find(java.lang.String code)
Finds theHttpStatus
with the specifiedcode
.- Parameters:
code
- the code to look for- Returns:
- an
HttpStatus
object with the specifiedcode
-
code
public int code()
Gets the numeric code for thisHttpStatus
.- 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()
Returnstrue
if thisHttpStatus
represents a known standard response status.- Returns:
true
if thisHttpStatus
represents a known standard response status
-
isPossibleToCache
public boolean isPossibleToCache()
Returnstrue
if thisHttpStatus
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 thisHttpStatus
could cause the state of the cache to change
-
isAuthenticationRequired
public boolean isAuthenticationRequired()
Returnstrue
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()
Returnstrue
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()
Returnstrue
if the status has a code in the100s
.- Returns:
true
if the status has a code in the100s
-
isSuccess
public boolean isSuccess()
Returnstrue
if the status has a code in the200s
.- Returns:
true
if the status has a code in the200s
-
isRedirection
public boolean isRedirection()
Returnstrue
if the status has a code in the300s
.- Returns:
true
if the status has a code in the300s
-
isError
public boolean isError()
Returnstrue
if the status has a code of400
or above- Returns:
true
if the status has a code of400
or above
-
isInRange
public boolean isInRange(HttpStatus from, HttpStatus to)
Returnstrue
if thisHttpStatus
is ordered between the supplied pair ofHttpStatus
objects.The
HttpStatus
objects are ordered by theircode()
and the range is inclusive of both of the specifiedHttpStatus
objects. No order is assumed for thefrom
andto
objects.e.g.
if (response.getResult().isInRange(HttpStatus.BAD_REQUEST, HttpStatus.UNSUPPORTED_MEDIA)) { error("A client error occurred"); }
- Parameters:
from
- the start of the rangeto
- the end of the range- Returns:
true
if thisHttpStatus
is ordered between the supplied pair ofHttpStatus
objects
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-