public abstract class SIPMessage extends MessageObject implements Message, MessageExt
StringMsgParser,
PipelinedMsgParser,
Serialized Form| Modifier and Type | Field and Description |
|---|---|
protected Object |
applicationData
The application data pointer.
|
protected CallID |
callIdHeader |
protected ContentLength |
contentLengthHeader |
protected CSeq |
cSeqHeader |
protected String |
forkId |
protected From |
fromHeader
Direct accessors for frequently accessed headers
|
protected ConcurrentLinkedQueue<SIPHeader> |
headers
List of parsed headers (in the order they were added)
|
protected Map<String,SIPHeader> |
headerTable |
protected MaxForwards |
maxForwardsHeader |
protected String |
messageContent |
protected byte[] |
messageContentBytes |
protected Object |
messageContentObject |
protected boolean |
nullRequest |
protected int |
size |
protected To |
toHeader |
protected LinkedList<String> |
unrecognizedHeaders
unparsed headers
|
AND, AT, COLON, COMMA, DOT, DOUBLE_QUOTE, EQUALS, GREATER_THAN, HT, immutableClasses, indentation, LESS_THAN, LPAREN, matchExpression, NEWLINE, PERCENT, POUND, QUESTION, QUOTE, RETURN, RPAREN, SEMICOLON, SLASH, SP, STAR, stringRepresentation| Constructor and Description |
|---|
SIPMessage()
Constructor: Initializes lists and list headers.
|
| Modifier and Type | Method and Description |
|---|---|
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.
|
void |
cleanUp() |
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 StringBuilder |
encodeMessage(StringBuilder retval)
Encode all the headers except the contents.
|
protected StringBuilder |
encodeSIPHeaders(StringBuilder encoding)
Encode only the message and exclude the contents (for debugging);
|
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)
|
CallIdHeader |
getCallIdHeader()
Get the callId header or null if none present.
|
protected String |
getCharset()
Returns the charset to use for encoding/decoding the body of this message
|
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 (body) of the message.
|
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).
|
ContentLengthHeader |
getContentLengthHeader()
Get the contentLength header.
|
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).
|
CSeqHeader |
getCSeqHeader()
Get the CSeq header or null if none present.
|
String |
getDialogId(boolean isServer)
Get A dialog identifier constructed from this messsage.
|
String |
getDialogId(boolean isServer,
String toTag)
Get a dialog id given the remote tag.
|
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.
|
String |
getForkId() |
FromHeader |
getFrom()
Get the from header.
|
FromHeader |
getFromHeader()
Get the From header or null if none present.
|
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.
|
protected Header |
getHeaderLowerCase(String lowerCaseHeaderName) |
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.
|
InetAddress |
getLocalAddress() |
int |
getLocalPort() |
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
|
InetAddress |
getPeerPacketSourceAddress() |
int |
getPeerPacketSourcePort() |
byte[] |
getRawContent()
Get the message content as an array of bytes.
|
RecordRouteList |
getRecordRouteHeaders()
Get the RecordRoute header list (null if one does not exist).
|
InetAddress |
getRemoteAddress() |
int |
getRemotePort() |
RouteList |
getRouteHeaders()
Get the Route List of headers (null if one does not exist).
|
SIPHeader |
getSIPHeaderListLowerCase(String lowerCaseHeaderName) |
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).
|
ToHeader |
getToHeader()
Get the To header or null if none present.
|
Via |
getTopmostVia()
Get the topmost via header.
|
ViaHeader |
getTopmostViaHeader()
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.
|
protected LinkedList<String> |
getUnrecognizedHeadersList() |
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.
|
boolean |
isNullRequest()
Return true if this is a null request (i.e.
|
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 |
setLocalAddress(InetAddress localAddress) |
void |
setLocalPort(int localPort) |
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 strict,
boolean computeContentLength,
int givenLength)
Set the message content for this message.
|
void |
setMessageContent(byte[] content,
boolean computeContentLength,
int givenLength)
Method to set the content - called by the parser
|
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.
|
void |
setNullRequest()
Set a flag to indiate this is a special message ( encoded with CRLFCRLF ).
|
void |
setPeerPacketSourceAddress(InetAddress peerPacketSourceAddress) |
void |
setPeerPacketSourcePort(int peerPacketSourcePort) |
void |
setRemoteAddress(InetAddress remoteAddress) |
void |
setRemotePort(int remotePort) |
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.
|
protected void |
setUnrecognizedHeadersList(LinkedList<String> unrecognizedHeaders) |
void |
setVia(List viaList)
Set A list of via headers.
|
abstract String |
toString()
Gets string representation of Message
|
dbgPrint, dbgPrintdbgPrint, debugDump, encode, getClassFromName, getIndentation, getMatcher, isMySubclass, makeClone, setMatcher, sprint, sprint, sprint, sprint, sprint, sprint, sprint, sprint, sprintprotected boolean nullRequest
protected LinkedList<String> unrecognizedHeaders
protected ConcurrentLinkedQueue<SIPHeader> headers
protected From fromHeader
protected To toHeader
protected CSeq cSeqHeader
protected CallID callIdHeader
protected ContentLength contentLengthHeader
protected MaxForwards maxForwardsHeader
protected int size
protected String messageContent
protected byte[] messageContentBytes
protected Object messageContentObject
protected Object applicationData
protected String forkId
public SIPMessage()
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()
protected StringBuilder encodeSIPHeaders(StringBuilder encoding)
public abstract StringBuilder encodeMessage(StringBuilder retval)
public final String getDialogId(boolean isServer)
isServerTransaction - is a flag that indicates whether this is a server transaction.public final String getDialogId(boolean isServer, String toTag)
public boolean match(Object other)
match in class GenericObjectother - is the match template to match against.public void merge(Object template)
merge in class GenericObjecttemplate - -- template to merge with.public String encode()
encode in class MessageObjectpublic byte[] encodeAsBytes(String transport)
public Object clone()
clone in interface Messageclone in class GenericObjectpublic String debugDump()
debugDump in class MessageObjectpublic void setHeader(Header sipHeader)
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 MessageheaderName - is the name of the header to remove.public String getTransactionId()
public int hashCode()
public boolean hasContent()
public Iterator<SIPHeader> getHeaders()
public ContentType getContentTypeHeader()
getContentTypeHeader in interface MessageExtpublic ContentLengthHeader getContentLengthHeader()
getContentLengthHeader in interface MessageExtpublic 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 headerParseExceptionpublic RecordRouteList getRecordRouteHeaders()
public ToHeader getTo()
public void setTo(ToHeader to)
public void setFrom(FromHeader from)
public ContentLengthHeader getContentLength()
getContentLength in interface Messagepublic 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 Messagepublic 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 Messagecontent - -- 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 Messagepublic 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(byte[] content,
boolean strict,
boolean computeContentLength,
int givenLength)
throws ParseException
content - Message body as a string.ParseExceptionpublic 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 - ParseExceptionpublic void removeContent()
removeContent in interface Messagepublic ListIterator<SIPHeader> getHeaders(String headerName)
getHeaders in interface MessageheaderName - 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()
getFirstLine in interface MessageExtpublic void addHeader(Header sipHeader)
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 Messagepublic ListIterator<String> getHeaderNames()
getHeaderNames in interface Messagepublic boolean equals(Object other)
equals in interface Messageequals in class GenericObjectother - -- the other object to compare with.public ContentDispositionHeader getContentDisposition()
getContentDisposition in interface Messagepublic ContentEncodingHeader getContentEncoding()
getContentEncoding in interface Messagepublic ContentLanguageHeader getContentLanguage()
getContentLanguage in interface Messagepublic ExpiresHeader getExpires()
getExpires in interface Messagepublic void setExpires(ExpiresHeader expiresHeader)
setExpires in interface MessageexpiresHeader - -- the expires header to set.public void setContentDisposition(ContentDispositionHeader contentDispositionHeader)
setContentDisposition in interface MessagecontentDispositionHeader - -- content disposition header.public void setContentEncoding(ContentEncodingHeader contentEncodingHeader)
MessagesetContentEncoding in interface MessagecontentEncodingHeader - the new ContentEncodingHeader object containing the
content encoding values of this Message.public void setContentLanguage(ContentLanguageHeader contentLanguageHeader)
MessagesetContentLanguage in interface MessagecontentLanguageHeader - the new ContentLanguageHeader object containing the
content language value of this Message.public void setContentLength(ContentLengthHeader contentLength)
setContentLength in interface MessagecontentLength - -- 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 Messageheader - -- the new Header to be added to the end of the existing
list of headersSipException - -- 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 Messageheader - 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
MessageremoveFirst in interface MessageheaderName - the name of the header to be removed.NullPointerException - -- if the arg is nullpublic void removeLast(String headerName)
MessageremoveLast in interface MessageheaderName - the name of the header to be removed.public void setCSeq(CSeqHeader cseqHeader)
cseqHeader - -- CSeq Header.public void setApplicationData(Object applicationData)
setApplicationData in interface MessageExtapplicationData - -- application data pointer to set. null clears the application data
pointer.public Object getApplicationData()
getApplicationData in interface MessageExtpublic MultipartMimeContent getMultipartMimeContent() throws ParseException
getMultipartMimeContent in interface MessageExtParseException - if the content type is multipart mime but the content
is not properly encoded.public CallIdHeader getCallIdHeader()
MessageExtgetCallIdHeader in interface MessageExtpublic FromHeader getFromHeader()
MessageExtgetFromHeader in interface MessageExtpublic ToHeader getToHeader()
MessageExtgetToHeader in interface MessageExtpublic ViaHeader getTopmostViaHeader()
MessageExtgetTopmostViaHeader in interface MessageExtpublic CSeqHeader getCSeqHeader()
MessageExtgetCSeqHeader in interface MessageExtprotected final String getCharset()
public boolean isNullRequest()
public void setNullRequest()
public String getForkId()
public abstract void setSIPVersion(String sipVersion) throws ParseException
MessagesetSIPVersion in interface MessagesipVersion - 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()
MessagegetSIPVersion in interface Messagepublic abstract String toString()
Messagepublic void cleanUp()
protected void setUnrecognizedHeadersList(LinkedList<String> unrecognizedHeaders)
unrecognizedHeaders - the unrecognizedHeaders to setprotected LinkedList<String> getUnrecognizedHeadersList()
public void setRemoteAddress(InetAddress remoteAddress)
public InetAddress getRemoteAddress()
public void setRemotePort(int remotePort)
public int getRemotePort()
public void setLocalAddress(InetAddress localAddress)
public InetAddress getLocalAddress()
public void setLocalPort(int localPort)
public int getLocalPort()
public void setPeerPacketSourceAddress(InetAddress peerPacketSourceAddress)
public InetAddress getPeerPacketSourceAddress()
public void setPeerPacketSourcePort(int peerPacketSourcePort)
public int getPeerPacketSourcePort()
Copyright © 2018. All Rights Reserved.