Package com.avoka.tm.http
Class HttpResponse
- java.lang.Object
-
- com.avoka.tm.http.HttpResponse
-
public class HttpResponse extends java.lang.Object
Provides a HttpResponse value object class.
- Since:
- 5.0.0
-
-
Constructor Summary
Constructors Constructor Description HttpResponse()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]
getContent()
java.lang.String
getContentEncoding()
long
getContentLength()
java.lang.String
getContentType()
org.w3c.dom.Document
getDocumentContent()
Return the content as a XML Document object, or null if not defined.java.util.Map<java.lang.String,java.lang.String>
getHeaders()
Return the map of HTTP response headers.Path
getPathContent()
Return the content as a Path object, or null if not defined.int
getStatus()
java.lang.String
getStatusLine()
java.lang.String
getTextContent()
Return the content as a UTF-8 encoded string, or null if not defined.boolean
isClientError()
Return true if HTTP response is an client error status code (400-499).boolean
isInformational()
Return true if HTTP response is an informational status code (100-199).boolean
isRedirection()
Return true if HTTP response is an redirection status code (300-399).boolean
isServerError()
Return true if HTTP response is an server error status code (500-599).boolean
isStatusNotFound()
Return true if the HTTP response status code is NOT FOUND (404).boolean
isStatusOK()
Return true if the HTTP response status code is OK (200).boolean
isSuccess()
Return true if HTTP response is an success status code (200-299).HttpResponse
setContent(byte[] content)
HttpResponse
setContentEncoding(java.lang.String contentEncoding)
HttpResponse
setContentLength(long contentLength)
HttpResponse
setContentType(java.lang.String contentType)
HttpResponse
setHeaders(java.util.Map<java.lang.String,java.lang.String> headers)
Set the map of HTTP response headers.HttpResponse
setStatus(int status)
HttpResponse
setStatusLine(java.lang.String statusLine)
HttpResponse
setTextContent(java.lang.String content)
Sets the text content in the response.java.lang.String
toString()
Return the string representation of this class.
-
-
-
Method Detail
-
getPathContent
public Path getPathContent()
Return the content as a Path object, or null if not defined.- Returns:
- the content as Path object
-
getDocumentContent
public org.w3c.dom.Document getDocumentContent()
Return the content as a XML Document object, or null if not defined.- Returns:
- the content as a XML Document object, or null if not defined.
-
getHeaders
public java.util.Map<java.lang.String,java.lang.String> getHeaders()
Return the map of HTTP response headers.- Returns:
- the map of HTTP response headers
-
setHeaders
public HttpResponse setHeaders(java.util.Map<java.lang.String,java.lang.String> headers)
Set the map of HTTP response headers.- Parameters:
headers
- the map of HTTP response headers- Returns:
- the HttpResponse value object
-
isStatusOK
public boolean isStatusOK()
Return true if the HTTP response status code is OK (200).- Returns:
- true if the HTTP response status code is OK (200).
-
isStatusNotFound
public boolean isStatusNotFound()
Return true if the HTTP response status code is NOT FOUND (404).- Returns:
- true if the HTTP response status code is NOT FOUND (404).
-
isInformational
public boolean isInformational()
Return true if HTTP response is an informational status code (100-199).- Returns:
- true if HTTP response is an informational status code (100-199).
-
isSuccess
public boolean isSuccess()
Return true if HTTP response is an success status code (200-299).- Returns:
- true if HTTP response is an success status code (200-299).
-
isRedirection
public boolean isRedirection()
Return true if HTTP response is an redirection status code (300-399).- Returns:
- true if HTTP response is an redirection status code (300-399).
-
isClientError
public boolean isClientError()
Return true if HTTP response is an client error status code (400-499).- Returns:
- true if HTTP response is an client error status code (400-499).
-
isServerError
public boolean isServerError()
Return true if HTTP response is an server error status code (500-599).- Returns:
- true if HTTP response is an server error status code (500-599).
-
getStatus
public int getStatus()
- Returns:
- the HTTP response status code
-
setStatus
public HttpResponse setStatus(int status)
- Parameters:
status
- the status to set- Returns:
- the HttpResponse value object
-
getStatusLine
public java.lang.String getStatusLine()
- Returns:
- the statusLine
-
setStatusLine
public HttpResponse setStatusLine(java.lang.String statusLine)
- Parameters:
statusLine
- the statusLine to set- Returns:
- the HttpResponse value object
-
getContent
public byte[] getContent()
- Returns:
- the content
-
setContent
public HttpResponse setContent(byte[] content)
- Parameters:
content
- the content to set- Returns:
- the HttpResponse value object
-
getContentLength
public long getContentLength()
- Returns:
- the contentLength
-
setContentLength
public HttpResponse setContentLength(long contentLength)
- Parameters:
contentLength
- the contentLength to set- Returns:
- the HttpResponse value object
-
getContentType
public java.lang.String getContentType()
- Returns:
- the contentType
-
setContentType
public HttpResponse setContentType(java.lang.String contentType)
- Parameters:
contentType
- the contentType to set- Returns:
- the HttpResponse value object
-
getContentEncoding
public java.lang.String getContentEncoding()
- Returns:
- the contentEncoding
-
setContentEncoding
public HttpResponse setContentEncoding(java.lang.String contentEncoding)
- Parameters:
contentEncoding
- the contentEncoding to set- Returns:
- the HttpResponse value object
-
getTextContent
public java.lang.String getTextContent()
Return the content as a UTF-8 encoded string, or null if not defined.- Returns:
- the content as a UTF-8 encoded string, or null if not defined.
-
setTextContent
public HttpResponse setTextContent(java.lang.String content)
Sets the text content in the response.- Parameters:
content
- the plain text content to set- Returns:
- the HttpResponse value object
- Since:
- 5.1.7
-
toString
public java.lang.String toString()
Return the string representation of this class.- Overrides:
toString
in classjava.lang.Object
- Returns:
- the string representation of this class
-
-