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

gov.nist.javax.sip.message
Class SIPMessage

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
All Implemented Interfaces:
MessageExt, Serializable, Cloneable, Message
Direct Known Subclasses:
SIPRequest, SIPResponse

public abstract class SIPMessage
extends MessageObject
implements Message, MessageExt

This is the main SIP Message structure.

Since:
1.1
Version:
1.2 $Revision: 1.47 $ $Date: 2009/08/20 19:01:21 $
Author:
M. Ranganathan
See Also:
StringMsgParser, PipelinedMsgParser, Serialized Form

Constructor Summary
SIPMessage()
          Constructor: Initializes lists and list headers.
 
Method Summary
 void addFirst(Header header)
          Adds the new Header to the head of the existing list of Headers contained in this Message.
 void addHeader(Header sipHeader)
          Add a SIP header.
 void addHeader(String sipHeader)
          Add a SIP header.
 void addLast(Header header)
          Adds the new Header to the end of existing list of Headers contained in this Message.
 void addUnparsed(String unparsed)
          Add a header to the unparsed list of headers.
 void attachHeader(SIPHeader h, boolean replaceflag)
          Attach a header to the end of the existing headers in this SIPMessage structure.
 void attachHeader(SIPHeader header, boolean replaceFlag, boolean top)
          Attach the header to the SIP Message structure at a specified position in its list of headers.
 Object clone()
          clone this message (create a new deep physical copy).
 String debugDump()
          Get the string representation of this header (for pretty printing the generated structure).
 String encode()
          Encode this message as a string.
 byte[] encodeAsBytes(String transport)
          Encode the message as a byte array.
abstract  String encodeMessage()
          Encode all the headers except the contents.
 boolean equals(Object other)
          Compare for equality.
 Object getApplicationData()
          Get the application data associated with this message.
 Authorization getAuthorization()
          Get the Authorization header (null if one does not exist).
 CallIdHeader getCallId()
          Get the CallID header (null if one does not exist)
 Contact getContactHeader()
          Get the contact header ( the first contact header) which is all we need for the most part.
 ContactList getContactHeaders()
          Get the Contact list of headers (null if one does not exist).
 Object getContent()
          Get the content of the header.
 ContentDispositionHeader getContentDisposition()
          get content disposition header or null if no such header exists.
 ContentEncodingHeader getContentEncoding()
          get the content encoding header.
 ContentLanguageHeader getContentLanguage()
          Get the contentLanguage header.
 ContentLengthHeader getContentLength()
          Get the ContentLength header (null if one does not exist).
 ContentType getContentTypeHeader()
          Get the contentType header (null if one does not exist).
 CSeqHeader getCSeq()
          Get the CSeq list of header (null if one does not exist).
abstract  String getDialogId(boolean isServerTransaction)
          Get A dialog identifier constructed from this messsage.
 ErrorInfoList getErrorInfoHeaders()
          Get the ErrorInfo list of headers (null if one does not exist).
 ExpiresHeader getExpires()
          Get the exipres header.
abstract  String getFirstLine()
          Return the encoded first line.
 FromHeader getFrom()
          Get the from header.
 String getFromTag()
          Return the from tag.
 Header getHeader(String headerName)
          Get the first header of the given name.
 String getHeaderAsFormattedString(String name)
          Get a header of the given name as a string.
 ListIterator<String> getHeaderNames()
          Get the header names.
 Iterator<SIPHeader> getHeaders()
          Return an iterator for the list of headers in this message.
 ListIterator<SIPHeader> getHeaders(String headerName)
          Get a SIP header or Header list given its name.
 MaxForwardsHeader getMaxForwards()
          Get the MaxForwards header (null if one does not exist).
 LinkedList<String> getMessageAsEncodedStrings()
          Get the headers as a linked list of encoded Strings
 String getMessageContent()
          Get the message body as a string.
 MultipartMimeContent getMultipartMimeContent()
          Get the multipart MIME content
 byte[] getRawContent()
          Get the message content as an array of bytes.
 RecordRouteList getRecordRouteHeaders()
          Get the RecordRoute header list (null if one does not exist).
 RouteList getRouteHeaders()
          Get the Route List of headers (null if one does not exist).
abstract  String getSIPVersion()
          Gets the protocol version of SIP being used by this Message.
 int getSize()
           
 ToHeader getTo()
          Get the To header (null if one does not exist).
 Via getTopmostVia()
          Get the topmost via header.
 String getToTag()
          Return the to tag.
 String getTransactionId()
          Generate (compute) a transaction ID for this SIP message.
 ListIterator<String> getUnrecognizedHeaders()
          Get a list containing the unrecognized headers.
 ViaList getViaHeaders()
          Get the Via list of headers (null if one does not exist).
 boolean hasContent()
          Return true if this message has a body.
 boolean hasFromTag()
          Return true if the message has a From header tag.
 int hashCode()
          Override the hashcode method ( see issue # 55 ) Note that if you try to use this method before you assemble a valid request, you will get a constant ( -1 ).
 boolean hasHeader(String headerName)
          Return true if the SIPMessage has a header of the given name.
 boolean hasToTag()
          Return true if the message has a To header tag.
static boolean isRequestHeader(SIPHeader sipHeader)
          Return true if the header belongs only in a Request.
static boolean isResponseHeader(SIPHeader sipHeader)
          Return true if the header belongs only in a response.
 boolean match(Object other)
          Template match for SIP messages.
 void merge(Object template)
          Merge a request with a template
 void removeContent()
          Remove the message content if it exists.
 void removeFirst(String headerName)
          Removes the first header from a list of headers.
 void removeHeader(String headerName)
          Remove all headers given its name.
 void removeHeader(String headerName, boolean top)
          Remove a header given its name.
 void removeLast(String headerName)
          Removes the last header from a list of headers.
 void setApplicationData(Object applicationData)
          Set the application data pointer.
 void setCallId(CallIdHeader callId)
          Set the call id header.
 void setCallId(String callId)
          Get the CallID header (null if one does not exist)
 void setContent(Object content, ContentTypeHeader contentTypeHeader)
          Set the message content after converting the given object to a String.
 void setContentDisposition(ContentDispositionHeader contentDispositionHeader)
          Set the content disposition header.
 void setContentEncoding(ContentEncodingHeader contentEncodingHeader)
          Sets the ContentEncodingHeader of this Message.
 void setContentLanguage(ContentLanguageHeader contentLanguageHeader)
          Sets the ContentLanguageHeader of this Message.
 void setContentLength(ContentLengthHeader contentLength)
          Set the content length header.
 void setCSeq(CSeqHeader cseqHeader)
          Set the CSeq header.
 void setExpires(ExpiresHeader expiresHeader)
          Set the expiresHeader
 void setFrom(FromHeader from)
           
 void setFromTag(String tag)
          Set the From Tag.
 void setHeader(Header sipHeader)
          Attach a header (replacing the original header).
 void setHeader(SIPHeaderList<Via> sipHeaderList)
          Set the header given a list of headers.
 void setHeaders(List<SIPHeader> headers)
          Set a header from a linked list of headers.
 void setMaxForwards(MaxForwardsHeader maxForwards)
          Set the max forwards header.
 void setMessageContent(byte[] content)
          Set the message content as an array of bytes.
 void setMessageContent(byte[] content, boolean computeContentLength, int givenLength)
          Method to set the content - called by the parser
 void setMessageContent(String content, boolean computeContentLength, int givenLength)
          Set the message content for this message.
 void setMessageContent(String type, String subType, byte[] messageContent)
          Set the message content for a given type and subtype.
 void setMessageContent(String type, String subType, String messageContent)
          Set the message content given type and subtype.
abstract  void setSIPVersion(String sipVersion)
          Sets the protocol version of SIP being used by this Message.
 void setSize(int size)
          Set the size of all the headers.
 void setTo(ToHeader to)
           
 void setToTag(String tag)
          Set the to tag.
 void setVia(List viaList)
          Set A list of via headers.
abstract  String toString()
          Gets string representation of Message
 
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
 

Constructor Detail

SIPMessage

public SIPMessage()
Constructor: Initializes lists and list headers. All the headers for which there can be multiple occurances in a message are derived from the SIPHeaderListClass. All singleton headers are derived from SIPHeader class.

Method Detail

isRequestHeader

public static boolean isRequestHeader(SIPHeader sipHeader)
Return true if the header belongs only in a Request.

Parameters:
sipHeader - is the header to test.

isResponseHeader

public static boolean isResponseHeader(SIPHeader sipHeader)
Return true if the header belongs only in a response.

Parameters:
sipHeader - is the header to test.

getMessageAsEncodedStrings

public LinkedList<String> getMessageAsEncodedStrings()
Get the headers as a linked list of encoded Strings

Returns:
a linked list with each element of the list containing a string encoded header in canonical form.

encodeMessage

public abstract String encodeMessage()
Encode all the headers except the contents. For debug logging.


getDialogId

public abstract String getDialogId(boolean isServerTransaction)
Get A dialog identifier constructed from this messsage. This is an id that can be used to identify dialogs.

Parameters:
isServerTransaction - is a flag that indicates whether this is a server transaction.

match

public boolean match(Object other)
Template match for SIP messages. The matchObj is a SIPMessage template to match against. This method allows you to do pattern matching with incoming SIP messages. Null matches wild card.

Overrides:
match in class gov.nist.core.GenericObject
Parameters:
other - is the match template to match against.
Returns:
true if a match occured and false otherwise.

merge

public void merge(Object template)
Merge a request with a template

Overrides:
merge in class gov.nist.core.GenericObject
Parameters:
template - -- template to merge with.

encode

public String encode()
Encode this message as a string. This is more efficient when the payload is a string (rather than a binary array of bytes). If the payload cannot be encoded as a UTF-8 string then it is simply ignored (will not appear in the encoded message).

Specified by:
encode in class MessageObject
Returns:
The Canonical String representation of the message (including the canonical string representation of the SDP payload if it exists).

encodeAsBytes

public byte[] encodeAsBytes(String transport)
Encode the message as a byte array. Use this when the message payload is a binary byte array.

Returns:
The Canonical byte array representation of the message (including the canonical byte array representation of the SDP payload if it exists all in one contiguous byte array).

clone

public Object clone()
clone this message (create a new deep physical copy). All headers in the message are cloned. You can modify the cloned copy without affecting the original. The content is handled as follows: If the content is a String, or a byte array, a new copy of the content is allocated and copied over. If the content is an Object that supports the clone method, then the clone method is invoked and the cloned content is the new content. Otherwise, the content of the new message is set equal to the old one.

Specified by:
clone in interface Message
Overrides:
clone in class gov.nist.core.GenericObject
Returns:
A cloned copy of this object.

debugDump

public String debugDump()
Get the string representation of this header (for pretty printing the generated structure).

Overrides:
debugDump in class MessageObject
Returns:
Formatted string representation of the object. Note that this is NOT the same as encode(). This is used mainly for debugging purposes.

setHeader

public void setHeader(Header sipHeader)
Attach a header (replacing the original header).

Specified by:
setHeader in interface Message
Parameters:
sipHeader - SIPHeader that replaces a header of the same type.

setHeaders

public void setHeaders(List<SIPHeader> headers)
Set a header from a linked list of headers.

Parameters:
headers - -- a list of headers to set.

attachHeader

public void attachHeader(SIPHeader h,
                         boolean replaceflag)
                  throws SIPDuplicateHeaderException
Attach a header to the end of the existing headers in this SIPMessage structure. This is equivalent to the attachHeader(SIPHeader,replaceflag,false); which is the normal way in which headers are attached. This was added in support of JAIN-SIP.

Parameters:
h - header to attach.
replaceflag - if true then replace a header if it exists.
Throws:
SIPDuplicateHeaderException - If replaceFlag is false and only a singleton header is allowed (fpr example CSeq).

attachHeader

public void attachHeader(SIPHeader header,
                         boolean replaceFlag,
                         boolean top)
                  throws SIPDuplicateHeaderException
Attach the header to the SIP Message structure at a specified position in its list of headers.

Parameters:
header - Header to attach.
replaceFlag - If true then replace the existing header.
top - Location in the header list to insert the header.
Throws:
SIPDuplicateHeaderException - if the header is of a type that cannot tolerate duplicates and one of this type already exists (e.g. CSeq header).
IndexOutOfBoundsException - If the index specified is greater than the number of headers that are in this message.

removeHeader

public void removeHeader(String headerName,
                         boolean top)
Remove a header given its name. If multiple headers of a given name are present then the top flag determines which end to remove headers from.

Parameters:
headerName - is the name of the header to remove.
top - -- flag that indicates which end of header list to process.

removeHeader

public void removeHeader(String headerName)
Remove all headers given its name.

Specified by:
removeHeader in interface Message
Parameters:
headerName - is the name of the header to remove.

getTransactionId

public String getTransactionId()
Generate (compute) a transaction ID for this SIP message.

Returns:
A string containing the concatenation of various portions of the From,To,Via and RequestURI portions of this message as specified in RFC 2543: All responses to a request contain the same values in the Call-ID, CSeq, To, and From fields (with the possible addition of a tag in the To field (section 10.43)). This allows responses to be matched with requests. Incorporates a bug fix for a bug sent in by Gordon Ledgard of IPera for generating transactionIDs when no port is present in the via header. Incorporates a bug fix for a bug report sent in by Chris Mills of Nortel Networks (converts to lower case when returning the transaction identifier).

hashCode

public int hashCode()
Override the hashcode method ( see issue # 55 ) Note that if you try to use this method before you assemble a valid request, you will get a constant ( -1 ). Beware of placing any half formed requests in a table.

Specified by:
hashCode in interface Message
Overrides:
hashCode in class Object
Returns:
integer representation of the Message hashcode

hasContent

public boolean hasContent()
Return true if this message has a body.


getHeaders

public Iterator<SIPHeader> getHeaders()
Return an iterator for the list of headers in this message.

Returns:
an Iterator for the headers of this message.

getHeader

public Header getHeader(String headerName)
Get the first header of the given name.

Specified by:
getHeader in interface Message
Parameters:
headerName - the new string name of Header type requested.
Returns:
header -- the first header of the given name.

getContentTypeHeader

public ContentType getContentTypeHeader()
Get the contentType header (null if one does not exist).

Returns:
contentType header

getFrom

public FromHeader getFrom()
Get the from header.

Returns:
-- the from header.

getErrorInfoHeaders

public ErrorInfoList getErrorInfoHeaders()
Get the ErrorInfo list of headers (null if one does not exist).

Returns:
List containing ErrorInfo headers.

getContactHeaders

public ContactList getContactHeaders()
Get the Contact list of headers (null if one does not exist).

Returns:
List containing Contact headers.

getContactHeader

public Contact getContactHeader()
Get the contact header ( the first contact header) which is all we need for the most part.


getViaHeaders

public ViaList getViaHeaders()
Get the Via list of headers (null if one does not exist).

Returns:
List containing Via headers.

setVia

public void setVia(List viaList)
Set A list of via headers.

Parameters:
viaList - a list of via headers to add.

setHeader

public void setHeader(SIPHeaderList<Via> sipHeaderList)
Set the header given a list of headers.

Parameters:
sipHeaderList - a headerList to set

getTopmostVia

public Via getTopmostVia()
Get the topmost via header.

Returns:
the top most via header if one exists or null if none exists.

getCSeq

public CSeqHeader getCSeq()
Get the CSeq list of header (null if one does not exist).

Returns:
CSeq header

getAuthorization

public Authorization getAuthorization()
Get the Authorization header (null if one does not exist).

Returns:
Authorization header.

getMaxForwards

public MaxForwardsHeader getMaxForwards()
Get the MaxForwards header (null if one does not exist).

Returns:
Max-Forwards header

setMaxForwards

public void setMaxForwards(MaxForwardsHeader maxForwards)
Set the max forwards header.

Parameters:
maxForwards - is the MaxForwardsHeader to set.

getRouteHeaders

public RouteList getRouteHeaders()
Get the Route List of headers (null if one does not exist).

Returns:
List containing Route headers

getCallId

public CallIdHeader getCallId()
Get the CallID header (null if one does not exist)

Returns:
Call-ID header .

setCallId

public void setCallId(CallIdHeader callId)
Set the call id header.

Parameters:
callId - call idHeader (what else could it be?)

setCallId

public void setCallId(String callId)
               throws ParseException
Get the CallID header (null if one does not exist)

Parameters:
callId - -- the call identifier to be assigned to the call id header
Throws:
ParseException

getRecordRouteHeaders

public RecordRouteList getRecordRouteHeaders()
Get the RecordRoute header list (null if one does not exist).

Returns:
Record-Route header

getTo

public ToHeader getTo()
Get the To header (null if one does not exist).

Returns:
To header

setTo

public void setTo(ToHeader to)

setFrom

public void setFrom(FromHeader from)

getContentLength

public ContentLengthHeader getContentLength()
Get the ContentLength header (null if one does not exist).

Specified by:
getContentLength in interface Message
Returns:
content-length header.

getMessageContent

public String getMessageContent()
                         throws UnsupportedEncodingException
Get the message body as a string. If the message contains a content type header with a specified charset, and if the payload has been read as a byte array, then it is returned encoded into this charset.

Returns:
Message body (as a string)
Throws:
UnsupportedEncodingException - if the platform does not support the charset specified in the content type header.

getRawContent

public byte[] getRawContent()
Get the message content as an array of bytes. If the payload has been read as a String then it is decoded using the charset specified in the content type header if it exists. Otherwise, it is encoded using the default encoding which is UTF-8.

Specified by:
getRawContent in interface Message
Returns:
an array of bytes that is the message payload.

setMessageContent

public void setMessageContent(String type,
                              String subType,
                              String messageContent)
Set the message content given type and subtype.

Parameters:
type - is the message type (eg. application)
subType - is the message sybtype (eg. sdp)
messageContent - is the messge content as a string.

setContent

public void setContent(Object content,
                       ContentTypeHeader contentTypeHeader)
                throws ParseException
Set the message content after converting the given object to a String.

Specified by:
setContent in interface Message
Parameters:
content - -- content to set.
contentTypeHeader - -- content type header corresponding to content.
Throws:
ParseException - which signals that an error has been reached unexpectedly while parsing the body.

getContent

public Object getContent()
Get the content of the header.

Specified by:
getContent in interface Message
Returns:
the content of the sip message.

setMessageContent

public void setMessageContent(String type,
                              String subType,
                              byte[] messageContent)
Set the message content for a given type and subtype.

Parameters:
type - is the messge type.
subType - is the message subType.
messageContent - is the message content as a byte array.

setMessageContent

public void setMessageContent(String content,
                              boolean computeContentLength,
                              int givenLength)
                       throws ParseException
Set the message content for this message.

Parameters:
content - Message body as a string.
Throws:
ParseException

setMessageContent

public void setMessageContent(byte[] content)
Set the message content as an array of bytes.

Parameters:
content - is the content of the message as an array of bytes.

setMessageContent

public void setMessageContent(byte[] content,
                              boolean computeContentLength,
                              int givenLength)
                       throws ParseException
Method to set the content - called by the parser

Parameters:
content -
Throws:
ParseException

removeContent

public void removeContent()
Remove the message content if it exists.

Specified by:
removeContent in interface Message

getHeaders

public ListIterator<SIPHeader> getHeaders(String headerName)
Get a SIP header or Header list given its name.

Specified by:
getHeaders in interface Message
Parameters:
headerName - is the name of the header to get.
Returns:
a header or header list that contians the retrieved header.

getHeaderAsFormattedString

public String getHeaderAsFormattedString(String name)
Get a header of the given name as a string. This concatenates the headers of a given type as a comma separted list. This is useful for formatting and printing headers.

Parameters:
name -
Returns:
the header as a formatted string

hasHeader

public boolean hasHeader(String headerName)
Return true if the SIPMessage has a header of the given name.

Parameters:
headerName - is the header name for which we are testing.
Returns:
true if the header is present in the message

hasFromTag

public boolean hasFromTag()
Return true if the message has a From header tag.

Returns:
true if the message has a from header and that header has a tag.

hasToTag

public boolean hasToTag()
Return true if the message has a To header tag.

Returns:
true if the message has a to header and that header has a tag.

getFromTag

public String getFromTag()
Return the from tag.

Returns:
the tag from the from header.

setFromTag

public void setFromTag(String tag)
Set the From Tag.

Parameters:
tag - -- tag to set in the from header.

setToTag

public void setToTag(String tag)
Set the to tag.

Parameters:
tag - -- tag to set.

getToTag

public String getToTag()
Return the to tag.


getFirstLine

public abstract String getFirstLine()
Return the encoded first line.


addHeader

public void addHeader(Header sipHeader)
Add a SIP header.

Specified by:
addHeader in interface Message
Parameters:
sipHeader - -- sip header to add.

addUnparsed

public void addUnparsed(String unparsed)
Add a header to the unparsed list of headers.

Parameters:
unparsed - -- unparsed header to add to the list.

addHeader

public void addHeader(String sipHeader)
Add a SIP header.

Parameters:
sipHeader - -- string version of SIP header to add.

getUnrecognizedHeaders

public ListIterator<String> getUnrecognizedHeaders()
Get a list containing the unrecognized headers.

Specified by:
getUnrecognizedHeaders in interface Message
Returns:
a linked list containing unrecongnized headers.

getHeaderNames

public ListIterator<String> getHeaderNames()
Get the header names.

Specified by:
getHeaderNames in interface Message
Returns:
a list iterator to a list of header names. These are ordered in the same order as are present in the message.

equals

public boolean equals(Object other)
Compare for equality.

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

getContentDisposition

public ContentDispositionHeader getContentDisposition()
get content disposition header or null if no such header exists.

Specified by:
getContentDisposition in interface Message
Returns:
the contentDisposition header

getContentEncoding

public ContentEncodingHeader getContentEncoding()
get the content encoding header.

Specified by:
getContentEncoding in interface Message
Returns:
the contentEncoding header.

getContentLanguage

public ContentLanguageHeader getContentLanguage()
Get the contentLanguage header.

Specified by:
getContentLanguage in interface Message
Returns:
the content language header.

getExpires

public ExpiresHeader getExpires()
Get the exipres header.

Specified by:
getExpires in interface Message
Returns:
the expires header or null if one does not exist.

setExpires

public void setExpires(ExpiresHeader expiresHeader)
Set the expiresHeader

Specified by:
setExpires in interface Message
Parameters:
expiresHeader - -- the expires header to set.

setContentDisposition

public void setContentDisposition(ContentDispositionHeader contentDispositionHeader)
Set the content disposition header.

Specified by:
setContentDisposition in interface Message
Parameters:
contentDispositionHeader - -- content disposition header.

setContentEncoding

public void setContentEncoding(ContentEncodingHeader contentEncodingHeader)
Description copied from interface: Message
Sets the ContentEncodingHeader of this Message. This overrides the ContentEncodingHeader set using the setHeaders method. If no ContentEncodingHeader exists in this message this ContentEncodingHeader is added to the end of the Header List.

Specified by:
setContentEncoding in interface Message
Parameters:
contentEncodingHeader - the new ContentEncodingHeader object containing the content encoding values of this Message.

setContentLanguage

public void setContentLanguage(ContentLanguageHeader contentLanguageHeader)
Description copied from interface: Message
Sets the ContentLanguageHeader of this Message. This overrides the ContentLanguageHeader set using the setHeaders method. If no ContentLanguageHeader exists in this message this ContentLanguageHeader is added to the end of the Header List.

Specified by:
setContentLanguage in interface Message
Parameters:
contentLanguageHeader - the new ContentLanguageHeader object containing the content language value of this Message.

setContentLength

public void setContentLength(ContentLengthHeader contentLength)
Set the content length header.

Specified by:
setContentLength in interface Message
Parameters:
contentLength - -- content length header.

setSize

public void setSize(int size)
Set the size of all the headers. This is for book keeping. Called by the parser.

Parameters:
size - -- size of the headers.

getSize

public int getSize()

addLast

public void addLast(Header header)
             throws SipException,
                    NullPointerException
Description copied from interface: Message
Adds the new Header to the end of existing list of Headers contained in this Message. The Header is added to the end of the List and will appear in that order in the SIP Message.

Required Headers that are singletons should not be added to the message as they already exist in the message and therefore should be changed using the Message.setHeader(Header) method. This does the same thing as addHeader in all cases including the Via header. Add a header explicitly to the end of a list of headers.

Specified by:
addLast in interface Message
Parameters:
header - -- the new Header to be added to the end of the existing list of headers
Throws:
SipException - -- if the header is a singleton and an instance of the header already exists.
NullPointerException - -- if the argument is null.

addFirst

public void addFirst(Header header)
              throws SipException,
                     NullPointerException
Description copied from interface: Message
Adds the new Header to the head of the existing list of Headers contained in this Message. The Header is added to the head of the List and will appear in that order in the SIP Message.

Required Headers that are singletons should not be added to the message as they already exist in the message and therefore should be changed using the Message.setHeader(Header) method.

Specified by:
addFirst in interface Message
Parameters:
header - the new Header to be added to the existing Headers List.
Throws:
SipException - -- if the header to be added is a singleton and an instance of the header already exists.
NullPointerException - -- if the argument is null.

removeFirst

public void removeFirst(String headerName)
                 throws NullPointerException
Description copied from interface: Message
Removes the first header from a list of headers. If there's only one header of this kind, then it is removed from the message.

Specified by:
removeFirst in interface Message
Parameters:
headerName - the name of the header to be removed.
Throws:
NullPointerException - -- if the arg is null

removeLast

public void removeLast(String headerName)
Description copied from interface: Message
Removes the last header from a list of headers. If there's only one header of this kind, then it is removed from the message.

Specified by:
removeLast in interface Message
Parameters:
headerName - the name of the header to be removed.

setCSeq

public void setCSeq(CSeqHeader cseqHeader)
Set the CSeq header.

Parameters:
cseqHeader - -- CSeq Header.

setApplicationData

public void setApplicationData(Object applicationData)
Set the application data pointer. This method is not used the stack. It is provided as a convenient way of storing book-keeping data for applications. Note that null clears the application data pointer (releases it).

Specified by:
setApplicationData in interface MessageExt
Parameters:
applicationData - -- application data pointer to set. null clears the application data pointer.

getApplicationData

public Object getApplicationData()
Get the application data associated with this message.

Specified by:
getApplicationData in interface MessageExt
Returns:
stored application data.

getMultipartMimeContent

public MultipartMimeContent getMultipartMimeContent()
                                             throws ParseException
Get the multipart MIME content

Specified by:
getMultipartMimeContent in interface MessageExt
Throws:
ParseException - if the content type is multipart mime but the content is not properly encoded.

setSIPVersion

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

Specified by:
setSIPVersion in interface Message
Parameters:
sipVersion - the new String object containing the version of the SIP Protocol of this Message.
Throws:
ParseException - which signals that an error has been reached unexpectedly while parsing the version argument.

getSIPVersion

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

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

toString

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

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

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.