NIST-SIP: The Reference Implementation for JAIN-SIP 1.2

gov.nist.javax.sip.message
Class SIPResponse

java.lang.Object
  extended by gov.nist.core.GenericObject
      extended by gov.nist.javax.sip.message.MessageObject
          extended by gov.nist.javax.sip.message.SIPMessage
              extended by gov.nist.javax.sip.message.SIPResponse
All Implemented Interfaces:
MessageExt, Serializable, Cloneable, Message, Response

public final class SIPResponse
extends SIPMessage
implements Response

SIP Response structure.

Since:
1.1
Version:
1.2 $Revision: 1.27 $ $Date: 2009/07/17 18:57:55 $
Author:
M. Ranganathan
See Also:
Serialized Form

Field Summary
 
Fields inherited from interface javax.sip.message.Response
ACCEPTED, ADDRESS_INCOMPLETE, ALTERNATIVE_SERVICE, AMBIGUOUS, BAD_EVENT, BAD_EXTENSION, BAD_GATEWAY, BAD_REQUEST, BUSY_EVERYWHERE, BUSY_HERE, CALL_IS_BEING_FORWARDED, CALL_OR_TRANSACTION_DOES_NOT_EXIST, CONDITIONAL_REQUEST_FAILED, DECLINE, DOES_NOT_EXIST_ANYWHERE, EXTENSION_REQUIRED, FORBIDDEN, GONE, INTERVAL_TOO_BRIEF, LOOP_DETECTED, MESSAGE_TOO_LARGE, METHOD_NOT_ALLOWED, MOVED_PERMANENTLY, MOVED_TEMPORARILY, MULTIPLE_CHOICES, NOT_ACCEPTABLE, NOT_ACCEPTABLE_HERE, NOT_FOUND, NOT_IMPLEMENTED, OK, PAYMENT_REQUIRED, PROXY_AUTHENTICATION_REQUIRED, QUEUED, REQUEST_ENTITY_TOO_LARGE, REQUEST_PENDING, REQUEST_TERMINATED, REQUEST_TIMEOUT, REQUEST_URI_TOO_LONG, RINGING, SERVER_INTERNAL_ERROR, SERVER_TIMEOUT, SERVICE_UNAVAILABLE, SESSION_NOT_ACCEPTABLE, SESSION_PROGRESS, TEMPORARILY_UNAVAILABLE, TOO_MANY_HOPS, TRYING, UNAUTHORIZED, UNDECIPHERABLE, UNSUPPORTED_MEDIA_TYPE, UNSUPPORTED_URI_SCHEME, USE_PROXY, VERSION_NOT_SUPPORTED
 
Constructor Summary
SIPResponse()
          Constructor.
 
Method Summary
 void checkHeaders()
          Check the response structure.
 Object clone()
          Make a clone (deep copy) of this object.
 SIPRequest createRequest(SipUri requestURI, Via via, CSeq cseq, From from, To to)
          Generate a request from a response.
 String debugDump()
          Print formatting function.
 String encode()
          Encode the SIP Request as a string.
 byte[] encodeAsBytes(String transport)
          Encode this into a byte array.
 String encodeMessage()
          Encode the message except for the body.
 boolean equals(Object other)
          Compare for equality.
 String getDialogId(boolean isServer)
          Get a dialog identifier.
 String getDialogId(boolean isServer, String toTag)
           
 String getFirstLine()
          Get the encoded first line.
 LinkedList getMessageAsEncodedStrings()
          Get this message as a list of encoded strings.
 String getReasonPhrase()
          Get the reason phrase.
static String getReasonPhrase(int rc)
           
 String getSIPVersion()
          Gets the protocol version of SIP being used by this Message.
 int getStatusCode()
          Get the staus code (conveniance function).
 StatusLine getStatusLine()
          Get the status line of the response.
 boolean isFinalResponse()
          Is this a final response?
static boolean isFinalResponse(int rc)
          Return true if the response is a final response.
 boolean match(Object matchObj)
          Match with a template.
 void setReasonPhrase(String reasonPhrase)
          Set the reason phrase.
 void setSIPVersion(String sipVersion)
          Sets the protocol version of SIP being used by this Message.
 void setStatusCode(int statusCode)
          set the status code.
 void setStatusLine(StatusLine sl)
          Set the status line field.
 String toString()
          Gets string representation of Message
 
Methods inherited from class gov.nist.javax.sip.message.SIPMessage
addFirst, addHeader, addHeader, addLast, addUnparsed, attachHeader, attachHeader, getApplicationData, getAuthorization, getCallId, getContactHeader, getContactHeaders, getContent, getContentDisposition, getContentEncoding, getContentLanguage, getContentLength, getContentTypeHeader, getCSeq, getErrorInfoHeaders, getExpires, getFrom, getFromTag, getHeader, getHeaderAsFormattedString, getHeaderNames, getHeaders, getHeaders, getMaxForwards, getMessageContent, getMultipartMimeContent, getRawContent, getRecordRouteHeaders, getRouteHeaders, getSize, getTo, getTopmostVia, getToTag, getTransactionId, getUnrecognizedHeaders, getViaHeaders, hasContent, hasFromTag, hashCode, hasHeader, hasToTag, isRequestHeader, isResponseHeader, merge, removeContent, removeFirst, removeHeader, removeHeader, removeLast, setApplicationData, setCallId, setCallId, setContent, setContentDisposition, setContentEncoding, setContentLanguage, setContentLength, setCSeq, setExpires, setFrom, setFromTag, setHeader, setHeader, setHeaders, setMaxForwards, setMessageContent, setMessageContent, setMessageContent, setMessageContent, setMessageContent, setSize, setTo, setToTag, setVia
 
Methods inherited from class gov.nist.javax.sip.message.MessageObject
dbgPrint, dbgPrint
 
Methods inherited from class gov.nist.core.GenericObject
debugDump, encode, getClassFromName, getMatcher, isMySubclass, makeClone, setMatcher
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface javax.sip.message.Message
addFirst, addHeader, addLast, getContent, getContentDisposition, getContentEncoding, getContentLanguage, getContentLength, getExpires, getHeader, getHeaderNames, getHeaders, getRawContent, getUnrecognizedHeaders, hashCode, removeContent, removeFirst, removeHeader, removeLast, setContent, setContentDisposition, setContentEncoding, setContentLanguage, setContentLength, setExpires, setHeader
 

Constructor Detail

SIPResponse

public SIPResponse()
Constructor.

Method Detail

getReasonPhrase

public static String getReasonPhrase(int rc)

setStatusCode

public void setStatusCode(int statusCode)
                   throws ParseException
set the status code.

Specified by:
setStatusCode in interface Response
Parameters:
statusCode - is the status code to set.
Throws:
IlegalArgumentException - if invalid status code.
ParseException - which signals that an error has been reached unexpectedly while parsing the statusCode value.

getStatusLine

public StatusLine getStatusLine()
Get the status line of the response.

Returns:
StatusLine

getStatusCode

public int getStatusCode()
Get the staus code (conveniance function).

Specified by:
getStatusCode in interface Response
Returns:
the status code of the status line.

setReasonPhrase

public void setReasonPhrase(String reasonPhrase)
Set the reason phrase.

Specified by:
setReasonPhrase in interface Response
Parameters:
reasonPhrase - the reason phrase.
Throws:
IllegalArgumentException - if null string

getReasonPhrase

public String getReasonPhrase()
Get the reason phrase.

Specified by:
getReasonPhrase in interface Response
Returns:
the reason phrase.

isFinalResponse

public static boolean isFinalResponse(int rc)
Return true if the response is a final response.

Parameters:
rc - is the return code.
Returns:
true if the parameter is between the range 200 and 700.

isFinalResponse

public boolean isFinalResponse()
Is this a final response?

Returns:
true if this is a final response.

setStatusLine

public void setStatusLine(StatusLine sl)
Set the status line field.

Parameters:
sl - Status line to set.

debugDump

public String debugDump()
Print formatting function. Indent and parenthesize for pretty printing. Note -- use the encode method for formatting the message. Hack here to XMLize.

Overrides:
debugDump in class SIPMessage
Returns:
a string for pretty printing.

checkHeaders

public void checkHeaders()
                  throws ParseException
Check the response structure. Must have from, to CSEQ and VIA headers.

Throws:
ParseException

encode

public String encode()
Encode the SIP Request as a string.

Overrides:
encode in class SIPMessage
Returns:
The string encoded canonical form of the message.

encodeMessage

public String encodeMessage()
Encode the message except for the body.

Specified by:
encodeMessage in class SIPMessage
Returns:
The string except for the body.

getMessageAsEncodedStrings

public LinkedList getMessageAsEncodedStrings()
Get this message as a list of encoded strings.

Overrides:
getMessageAsEncodedStrings in class SIPMessage
Returns:
LinkedList containing encoded strings for each header in the message.

clone

public Object clone()
Make a clone (deep copy) of this object.

Specified by:
clone in interface Message
Overrides:
clone in class SIPMessage
Returns:
a deep copy of this object.

equals

public boolean equals(Object other)
Compare for equality.

Specified by:
equals in interface Message
Overrides:
equals in class SIPMessage
Parameters:
other - other object to compare with.
Returns:
true if the objects are euqal and false otherwise

match

public boolean match(Object matchObj)
Match with a template.

Overrides:
match in class SIPMessage
Parameters:
matchObj - template object to match ourselves with (null in any position in the template object matches wildcard)
Returns:
true if a match occured and false otherwise.

encodeAsBytes

public byte[] encodeAsBytes(String transport)
Encode this into a byte array. This is used when the body has been set as a binary array and you want to encode the body as a byte array for transmission.

Overrides:
encodeAsBytes in class SIPMessage
Returns:
a byte array containing the SIPRequest encoded as a byte array.

getDialogId

public String getDialogId(boolean isServer)
Get a dialog identifier. Generates a string that can be used as a dialog identifier.

Specified by:
getDialogId in class SIPMessage
Parameters:
isServer - is set to true if this is the UAS and set to false if this is the UAC

getDialogId

public String getDialogId(boolean isServer,
                          String toTag)

getFirstLine

public String getFirstLine()
Get the encoded first line.

Specified by:
getFirstLine in class SIPMessage
Returns:
the status line encoded.

setSIPVersion

public void setSIPVersion(String sipVersion)
Description copied from interface: Message
Sets the protocol version of SIP being used by this Message.

Specified by:
setSIPVersion in interface Message
Specified by:
setSIPVersion in class SIPMessage
Parameters:
sipVersion - the new String object containing the version of the SIP Protocol of this Message.

getSIPVersion

public String getSIPVersion()
Description copied from interface: Message
Gets the protocol version of SIP being used by this Message.

Specified by:
getSIPVersion in interface Message
Specified by:
getSIPVersion in class SIPMessage
Returns:
the protocol version of the SIP protocol of this message.

toString

public String toString()
Description copied from interface: Message
Gets string representation of Message

Specified by:
toString in interface Message
Specified by:
toString in class SIPMessage
Returns:
string representation of Message

createRequest

public SIPRequest createRequest(SipUri requestURI,
                                Via via,
                                CSeq cseq,
                                From from,
                                To to)
Generate a request from a response.

Parameters:
requestURI - -- the request URI to assign to the request.
via - -- the Via header to assign to the request
cseq - -- the CSeq header to assign to the request
from - -- the From header to assign to the request
to - -- the To header to assign to the request
Returns:
-- the newly generated sip request.

NIST-SIP: The Reference Implementation for JAIN-SIP 1.2

A product of the NIST/ITL Advanced Networking Technologies Division.
See conditions of use.
Submit a bug report or feature request.