Package org.simpleframework.http.core
Class ResponseMessage
- java.lang.Object
-
- org.simpleframework.http.message.MessageHeader
-
- org.simpleframework.http.core.ResponseMessage
-
- All Implemented Interfaces:
Message,ResponseHeader,StatusLine
- Direct Known Subclasses:
ResponseEntity
class ResponseMessage extends MessageHeader implements ResponseHeader
TheResponseMessageobject represents the header used for a response. This is used to get and set the headers in a case insensitive manner. It is also used to manage the cookies that are send and received. Also, the status code and description can also be set through this object as well as the protocol version.
-
-
Field Summary
Fields Modifier and Type Field Description private intcodeThis is the status code used to identify the response type.private intmajorThis is the major protocol version used for the response.private intminorThis is the minor protocol version used for the response.private java.lang.StringtextThis is the text description used for the response status.
-
Constructor Summary
Constructors Constructor Description ResponseMessage()Constructor for theResponseMessageobject.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetCode()This represents the status code of the HTTP response.longgetContentLength()This is a convenience method that can be used to determine the length of the message body.ContentTypegetContentType()This is a convenience method that can be used to determine the content type of the message body.java.lang.StringgetDescription()This can be used to retrieve the text of a HTTP status line.java.lang.CharSequencegetHeader()This is used to compose the HTTP response header.intgetMajor()This can be used to get the major number from a HTTP version.intgetMinor()This can be used to get the minor number from a HTTP version.StatusgetStatus()This is used to acquire the status from the response.java.lang.StringgetTransferEncoding()This is a convenience method that can be used to determine the content type of the message body.voidsetCode(int code)This method allows the status for the response to be changed.voidsetDescription(java.lang.String text)This is used to set the text of the HTTP status line.voidsetMajor(int major)This can be used to set the major number from a HTTP version.voidsetMinor(int minor)This can be used to get the minor number from a HTTP version.voidsetStatus(Status status)This is used to set the status code and description for this response.java.lang.StringtoString()This is used to compose the HTTP response header.-
Methods inherited from class org.simpleframework.http.message.MessageHeader
addDate, addInteger, addValue, getAll, getCookie, getCookies, getDate, getInteger, getLong, getNames, getValue, getValue, getValues, getValues, setCookie, setCookie, setDate, setInteger, setLong, setValue
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.simpleframework.http.ResponseHeader
addDate, addInteger, addValue, getCookie, getCookies, getDate, getInteger, getNames, getValue, getValue, getValues, setCookie, setCookie, setDate, setInteger, setLong, setValue
-
-
-
-
Field Detail
-
text
private java.lang.String text
This is the text description used for the response status.
-
major
private int major
This is the major protocol version used for the response.
-
minor
private int minor
This is the minor protocol version used for the response.
-
code
private int code
This is the status code used to identify the response type.
-
-
Method Detail
-
getCode
public int getCode()
This represents the status code of the HTTP response. The response code represents the type of message that is being sent to the client. For a description of the codes see RFC 2616 section 10, Status Code Definitions.- Specified by:
getCodein interfaceStatusLine- Returns:
- the status code that this HTTP response has
-
setCode
public void setCode(int code)
This method allows the status for the response to be changed. This MUST be reflected the the response content given to the client. For a description of the codes see RFC 2616 section 10, Status Code Definitions.- Specified by:
setCodein interfaceStatusLine- Parameters:
code- the new status code for the HTTP response
-
getDescription
public java.lang.String getDescription()
This can be used to retrieve the text of a HTTP status line. This is the text description for the status code. This should match the status code specified by the RFC.- Specified by:
getDescriptionin interfaceStatusLine- Returns:
- the message description of the response
-
setDescription
public void setDescription(java.lang.String text)
This is used to set the text of the HTTP status line. This should match the status code specified by the RFC.- Specified by:
setDescriptionin interfaceStatusLine- Parameters:
text- the descriptive text message of the status
-
getStatus
public Status getStatus()
This is used to acquire the status from the response. TheStatusobject returns represents the code that has been set on the response, it does not necessarily represent the description in the response.- Specified by:
getStatusin interfaceStatusLine- Returns:
- this is the response for this status line
-
setStatus
public void setStatus(Status status)
This is used to set the status code and description for this response. Setting the code and description in this manner provides a much more convenient way to set the response status line details.- Specified by:
setStatusin interfaceStatusLine- Parameters:
status- this is the status to set on the response
-
getMajor
public int getMajor()
This can be used to get the major number from a HTTP version. The major version corresponds to the major type that is the 1 of a HTTP/1.0 version string.- Specified by:
getMajorin interfaceStatusLine- Returns:
- the major version number for the request message
-
setMajor
public void setMajor(int major)
This can be used to set the major number from a HTTP version. The major version corresponds to the major type that is the 1 of a HTTP/1.0 version string.- Specified by:
setMajorin interfaceStatusLine- Parameters:
major- the major version number for the request message
-
getMinor
public int getMinor()
This can be used to get the minor number from a HTTP version. The minor version corresponds to the major type that is the 0 of a HTTP/1.0 version string. This is used to determine if the request message has keep alive semantics.- Specified by:
getMinorin interfaceStatusLine- Returns:
- the minor version number for the request message
-
setMinor
public void setMinor(int minor)
This can be used to get the minor number from a HTTP version. The minor version corresponds to the major type that is the 0 of a HTTP/1.0 version string. This is used to determine if the request message has keep alive semantics.- Specified by:
setMinorin interfaceStatusLine- Parameters:
minor- the minor version number for the request message
-
getContentType
public ContentType getContentType()
This is a convenience method that can be used to determine the content type of the message body. This will determine whether there is aContent-Typeheader, if there is then this will parse that header and represent it as a typed object which will expose the various parts of the HTTP header.- Specified by:
getContentTypein interfaceResponseHeader- Returns:
- this returns the content type value if it exists
-
getContentLength
public long getContentLength()
This is a convenience method that can be used to determine the length of the message body. This will determine if there is aContent-Lengthheader, if it does then the length can be determined, if not then this returns -1.- Specified by:
getContentLengthin interfaceResponseHeader- Returns:
- content length, or -1 if it cannot be determined
-
getTransferEncoding
public java.lang.String getTransferEncoding()
This is a convenience method that can be used to determine the content type of the message body. This will determine whether there is aTransfer-Encodingheader, if there is then this will parse that header and return the first token in the comma separated list of values, which is the primary value.- Specified by:
getTransferEncodingin interfaceResponseHeader- Returns:
- this returns the transfer encoding value if it exists
-
getHeader
public java.lang.CharSequence getHeader()
This is used to compose the HTTP response header. All of the headers added to the response are added, as well as the cookies to form the response message header. To ensure that the text produces is as required the header names are in the same case as they were added to the response message.- Specified by:
getHeaderin interfaceResponseHeader- Returns:
- a string representation of the response message
-
toString
public java.lang.String toString()
This is used to compose the HTTP response header. All of the headers added to the response are added, as well as the cookies to form the response message header. To ensure that the text produces is as required the header names are in the same case as they were added to the response message.- Specified by:
toStringin interfaceResponseHeader- Overrides:
toStringin classjava.lang.Object- Returns:
- a string representation of the response message
-
-