|
NIST-SIP: The Reference Implementation for JAIN-SIP 1.2 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectgov.nist.core.GenericObject
gov.nist.javax.sip.message.MessageObject
gov.nist.javax.sip.message.SIPMessage
public abstract class SIPMessage
This is the main SIP Message structure.
StringMsgParser
,
PipelinedMsgParser
,
Serialized FormConstructor 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 |
---|
public SIPMessage()
Method Detail |
---|
public static boolean isRequestHeader(SIPHeader sipHeader)
sipHeader
- is the header to test.public static boolean isResponseHeader(SIPHeader sipHeader)
sipHeader
- is the header to test.public LinkedList<String> getMessageAsEncodedStrings()
public abstract String encodeMessage()
public abstract String getDialogId(boolean isServerTransaction)
isServerTransaction
- is a flag that indicates whether this is a server transaction.public boolean match(Object other)
match
in class gov.nist.core.GenericObject
other
- is the match template to match against.
public void merge(Object template)
merge
in class gov.nist.core.GenericObject
template
- -- template to merge with.public String encode()
encode
in class MessageObject
public byte[] encodeAsBytes(String transport)
public Object clone()
clone
in interface Message
clone
in class gov.nist.core.GenericObject
public String debugDump()
debugDump
in class MessageObject
public void setHeader(Header sipHeader)
setHeader
in interface Message
sipHeader
- SIPHeader that replaces a header of the same type.public void setHeaders(List<SIPHeader> headers)
headers
- -- a list of headers to set.public void attachHeader(SIPHeader h, boolean replaceflag) throws SIPDuplicateHeaderException
h
- header to attach.replaceflag
- if true then replace a header if it exists.
SIPDuplicateHeaderException
- If replaceFlag is false and only a singleton header is
allowed (fpr example CSeq).public void attachHeader(SIPHeader header, boolean replaceFlag, boolean top) throws SIPDuplicateHeaderException
header
- Header to attach.replaceFlag
- If true then replace the existing header.top
- Location in the header list to insert the header.
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.public void removeHeader(String headerName, boolean top)
headerName
- is the name of the header to remove.top
- -- flag that indicates which end of header list to process.public void removeHeader(String headerName)
removeHeader
in interface Message
headerName
- is the name of the header to remove.public String getTransactionId()
public int hashCode()
hashCode
in interface Message
hashCode
in class Object
public boolean hasContent()
public Iterator<SIPHeader> getHeaders()
public Header getHeader(String headerName)
getHeader
in interface Message
headerName
- the new string name of Header type requested.
public ContentType getContentTypeHeader()
public FromHeader getFrom()
public ErrorInfoList getErrorInfoHeaders()
public ContactList getContactHeaders()
public Contact getContactHeader()
public ViaList getViaHeaders()
public void setVia(List viaList)
viaList
- a list of via headers to add.public void setHeader(SIPHeaderList<Via> sipHeaderList)
sipHeaderList
- a headerList to setpublic Via getTopmostVia()
public CSeqHeader getCSeq()
public Authorization getAuthorization()
public MaxForwardsHeader getMaxForwards()
public void setMaxForwards(MaxForwardsHeader maxForwards)
maxForwards
- is the MaxForwardsHeader to set.public RouteList getRouteHeaders()
public CallIdHeader getCallId()
public void setCallId(CallIdHeader callId)
callId
- call idHeader (what else could it be?)public void setCallId(String callId) throws ParseException
callId
- -- the call identifier to be assigned to the call id header
ParseException
public RecordRouteList getRecordRouteHeaders()
public ToHeader getTo()
public void setTo(ToHeader to)
public void setFrom(FromHeader from)
public ContentLengthHeader getContentLength()
getContentLength
in interface Message
public String getMessageContent() throws UnsupportedEncodingException
UnsupportedEncodingException
- if the platform does not support the charset specified
in the content type header.public byte[] getRawContent()
getRawContent
in interface Message
public void setMessageContent(String type, String subType, String messageContent)
type
- is the message type (eg. application)subType
- is the message sybtype (eg. sdp)messageContent
- is the messge content as a string.public void setContent(Object content, ContentTypeHeader contentTypeHeader) throws ParseException
setContent
in interface Message
content
- -- content to set.contentTypeHeader
- -- content type header corresponding to content.
ParseException
- which signals that an error has been reached
unexpectedly while parsing the body.public Object getContent()
getContent
in interface Message
public void setMessageContent(String type, String subType, byte[] messageContent)
type
- is the messge type.subType
- is the message subType.messageContent
- is the message content as a byte array.public void setMessageContent(String content, boolean computeContentLength, int givenLength) throws ParseException
content
- Message body as a string.
ParseException
public void setMessageContent(byte[] content)
content
- is the content of the message as an array of bytes.public void setMessageContent(byte[] content, boolean computeContentLength, int givenLength) throws ParseException
content
-
ParseException
public void removeContent()
removeContent
in interface Message
public ListIterator<SIPHeader> getHeaders(String headerName)
getHeaders
in interface Message
headerName
- is the name of the header to get.
public String getHeaderAsFormattedString(String name)
name
-
public boolean hasHeader(String headerName)
headerName
- is the header name for which we are testing.
public boolean hasFromTag()
public boolean hasToTag()
public String getFromTag()
public void setFromTag(String tag)
tag
- -- tag to set in the from header.public void setToTag(String tag)
tag
- -- tag to set.public String getToTag()
public abstract String getFirstLine()
public void addHeader(Header sipHeader)
addHeader
in interface Message
sipHeader
- -- sip header to add.public void addUnparsed(String unparsed)
unparsed
- -- unparsed header to add to the list.public void addHeader(String sipHeader)
sipHeader
- -- string version of SIP header to add.public ListIterator<String> getUnrecognizedHeaders()
getUnrecognizedHeaders
in interface Message
public ListIterator<String> getHeaderNames()
getHeaderNames
in interface Message
public boolean equals(Object other)
equals
in interface Message
equals
in class gov.nist.core.GenericObject
other
- -- the other object to compare with.
public ContentDispositionHeader getContentDisposition()
getContentDisposition
in interface Message
public ContentEncodingHeader getContentEncoding()
getContentEncoding
in interface Message
public ContentLanguageHeader getContentLanguage()
getContentLanguage
in interface Message
public ExpiresHeader getExpires()
getExpires
in interface Message
public void setExpires(ExpiresHeader expiresHeader)
setExpires
in interface Message
expiresHeader
- -- the expires header to set.public void setContentDisposition(ContentDispositionHeader contentDispositionHeader)
setContentDisposition
in interface Message
contentDispositionHeader
- -- content disposition header.public void setContentEncoding(ContentEncodingHeader contentEncodingHeader)
Message
setContentEncoding
in interface Message
contentEncodingHeader
- the new ContentEncodingHeader object containing the
content encoding values of this Message.public void setContentLanguage(ContentLanguageHeader contentLanguageHeader)
Message
setContentLanguage
in interface Message
contentLanguageHeader
- the new ContentLanguageHeader object containing the
content language value of this Message.public void setContentLength(ContentLengthHeader contentLength)
setContentLength
in interface Message
contentLength
- -- content length header.public void setSize(int size)
size
- -- size of the headers.public int getSize()
public void addLast(Header header) throws SipException, NullPointerException
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.
addLast
in interface Message
header
- -- the new Header to be added to the end of the existing
list of headers
SipException
- -- if the header is a singleton and an instance of the header
already exists.
NullPointerException
- -- if the argument is null.public void addFirst(Header header) throws SipException, NullPointerException
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.
addFirst
in interface Message
header
- the new Header to be added to the existing Headers List.
SipException
- -- if the header to be added is a singleton and an instance of the header
already exists.
NullPointerException
- -- if the argument is null.public void removeFirst(String headerName) throws NullPointerException
Message
removeFirst
in interface Message
headerName
- the name of the header to be removed.
NullPointerException
- -- if the arg is nullpublic void removeLast(String headerName)
Message
removeLast
in interface Message
headerName
- the name of the header to be removed.public void setCSeq(CSeqHeader cseqHeader)
cseqHeader
- -- CSeq Header.public void setApplicationData(Object applicationData)
setApplicationData
in interface MessageExt
applicationData
- -- application data pointer to set. null clears the application data
pointer.public Object getApplicationData()
getApplicationData
in interface MessageExt
public MultipartMimeContent getMultipartMimeContent() throws ParseException
getMultipartMimeContent
in interface MessageExt
ParseException
- if the content type is multipart mime but the content
is not properly encoded.public abstract void setSIPVersion(String sipVersion) throws ParseException
Message
setSIPVersion
in interface Message
sipVersion
- the new String object containing the version of the SIP
Protocol of this Message.
ParseException
- which signals that an error has been reached
unexpectedly while parsing the version argument.public abstract String getSIPVersion()
Message
getSIPVersion
in interface Message
public abstract String toString()
Message
toString
in interface Message
toString
in class Object
|
NIST-SIP: The Reference Implementation for JAIN-SIP 1.2 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |