Package org.dellroad.msrp.msg
Class MsrpResponse
- java.lang.Object
-
- org.dellroad.msrp.msg.MsrpMessage
-
- org.dellroad.msrp.msg.MsrpResponse
-
public class MsrpResponse extends MsrpMessage
MSRP response.
-
-
Constructor Summary
Constructors Constructor Description MsrpResponse(String transactionId, int code, String comment)Construct an instance with the given transaction ID, code, and comment.MsrpResponse(String transactionId, int code, String comment, MsrpHeaders headers)Construct an instance with the given transaction ID, code, comment, and headers.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object obj)intgetCode()StringgetComment()protected StringgetFirstLine()Get the first message line.bytegetFlagByte()Get the end line flag byte.StringgetResultString()Get the result string (starting with the response code) from the first line of this response.inthashCode()StatustoStatus()Get this response's response code and comment as aStatusobject.protected voidwritePayload(OutputStream output)Write the message body, if any.-
Methods inherited from class org.dellroad.msrp.msg.MsrpMessage
encode, getHeaders, getTransactionId, randomId, toString
-
-
-
-
Constructor Detail
-
MsrpResponse
public MsrpResponse(String transactionId, int code, String comment)
Construct an instance with the given transaction ID, code, and comment.- Parameters:
transactionId- transaction ID, or null to have a randomly generated one assignedcode- response codecomment- response code comment, if any, otherwise null- Throws:
IllegalArgumentException- ifcodeis not in the range 000 .. 999IllegalArgumentException- iftransactionIdis invalid
-
MsrpResponse
public MsrpResponse(String transactionId, int code, String comment, MsrpHeaders headers)
Construct an instance with the given transaction ID, code, comment, and headers.- Parameters:
transactionId- transaction ID, or null to have a randomly generated one assignedcode- response codecomment- response code comment, if any, otherwise nullheaders- MSRP headers, or null to have an empty instance created- Throws:
IllegalArgumentException- ifcodeis not in the range 000 .. 999IllegalArgumentException- iftransactionIdis invalid
-
-
Method Detail
-
getCode
public int getCode()
-
getComment
public String getComment()
-
getResultString
public String getResultString()
Get the result string (starting with the response code) from the first line of this response.- Returns:
- result string
-
toStatus
public Status toStatus()
Get this response's response code and comment as aStatusobject.- Returns:
- associated
Status
-
equals
public boolean equals(Object obj)
- Overrides:
equalsin classMsrpMessage
-
hashCode
public int hashCode()
- Overrides:
hashCodein classMsrpMessage
-
getFlagByte
public byte getFlagByte()
Description copied from class:MsrpMessageGet the end line flag byte.- Specified by:
getFlagBytein classMsrpMessage- Returns:
- flag byte
-
getFirstLine
protected String getFirstLine()
Description copied from class:MsrpMessageGet the first message line.- Specified by:
getFirstLinein classMsrpMessage- Returns:
- first line
-
writePayload
protected void writePayload(OutputStream output) throws IOException
Description copied from class:MsrpMessageWrite the message body, if any.If this message has a body, this method should output CRLF, followed by the binary body content, followed by a final CRLF. If this message has no body, this method should not output anything.
- Specified by:
writePayloadin classMsrpMessage- Parameters:
output- destination for message- Throws:
IOException- if an I/O error occurs
-
-