Package com.facilita.fc.web
Class HttpStatus
- java.lang.Object
-
- com.facilita.fc.web.HttpStatus
-
public class HttpStatus extends java.lang.ObjectRepresents an HTTP status code.To find the HTTP status code of a
Responseobject, use theResponse.getResult()method.HTTP status codes are defined by RFC 2616.
-
-
Field Summary
Fields Modifier and Type Field Description static HttpStatusNOT_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 intcode()Gets the numeric code for thisHttpStatus.voiddelete()java.lang.Stringdescription()Gets the text that describes the status.static HttpStatusfind(int code)Finds theHttpStatuswith the specifiedcode.static HttpStatusfind(java.lang.String code)Finds theHttpStatuswith the specifiedcode.static longgetCPtr(HttpStatus obj)For internal use only.booleanisAuthenticationRequired()Returnstrueif the status represents a request from the server for the caller to authenticate themselves.booleanisError()Returnstrueif the status has a code of400or abovebooleanisFullfilled()Returnstrueif the request has been generally satisfied.booleanisInformational()Returnstrueif the status has a code in the100s.booleanisInRange(HttpStatus from, HttpStatus to)Returnstrueif thisHttpStatusis ordered between the supplied pair ofHttpStatusobjects.booleanisPossibleToCache()Returnstrueif thisHttpStatuscould cause the state of the cache to change.booleanisRedirection()Returnstrueif the status has a code in the300s.booleanisSuccess()Returnstrueif the status has a code in the200s.booleanisValid()Returnstrueif thisHttpStatusrepresents a known standard response status.java.lang.Stringname()Gets the recommended text that is to be displayed next to the numeric code at the top of the response.java.lang.StringtoString()
-
-
-
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 theHttpStatuswith the specifiedcode.- Parameters:
code- the code to look for- Returns:
- an
HttpStatusobject with the specifiedcode
-
find
public static HttpStatus find(java.lang.String code)
Finds theHttpStatuswith the specifiedcode.- Parameters:
code- the code to look for- Returns:
- an
HttpStatusobject 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()
Returnstrueif thisHttpStatusrepresents a known standard response status.- Returns:
trueif thisHttpStatusrepresents a known standard response status
-
isPossibleToCache
public boolean isPossibleToCache()
Returnstrueif thisHttpStatuscould 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:
trueif thisHttpStatuscould cause the state of the cache to change
-
isAuthenticationRequired
public boolean isAuthenticationRequired()
Returnstrueif the status represents a request from the server for the caller to authenticate themselves.- Returns:
trueif the status represents a request from the server for the caller to authenticate themselves
-
isFullfilled
public boolean isFullfilled()
Returnstrueif the request has been generally satisfied.This means that the call was successful (
200scode) or lead to a redirection (300s).- Returns:
trueif the request has been generally satisfied
-
isInformational
public boolean isInformational()
Returnstrueif the status has a code in the100s.- Returns:
trueif the status has a code in the100s
-
isSuccess
public boolean isSuccess()
Returnstrueif the status has a code in the200s.- Returns:
trueif the status has a code in the200s
-
isRedirection
public boolean isRedirection()
Returnstrueif the status has a code in the300s.- Returns:
trueif the status has a code in the300s
-
isError
public boolean isError()
Returnstrueif the status has a code of400or above- Returns:
trueif the status has a code of400or above
-
isInRange
public boolean isInRange(HttpStatus from, HttpStatus to)
Returnstrueif thisHttpStatusis ordered between the supplied pair ofHttpStatusobjects.The
HttpStatusobjects are ordered by theircode()and the range is inclusive of both of the specifiedHttpStatusobjects. No order is assumed for thefromandtoobjects.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:
trueif thisHttpStatusis ordered between the supplied pair ofHttpStatusobjects
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-