Methods Summary |
---|
public void | addHeader(Header sipHeader)Adds a SIP header.
Header sh = (Header) sipHeader;
// Add the header value topmost of this type of headers
// as required by JSR180.
attachHeader(sh, false, true);
/*
if (sipHeader instanceof ViaHeader) {
attachHeader(sh, false, true);
} else {
attachHeader(sh, false, false);
}
*/
|
public void | addHeader(java.lang.String sipHeader)Adds a SIP header.
String hdrString = sipHeader.trim() + "\n";
try {
HeaderParser parser = ParserFactory.createParser(sipHeader);
Header sh = parser.parse();
attachHeader(sh, false);
} catch (ParseException ex) {
unrecognizedHeaders.addElement(hdrString);
}
|
public void | addUnparsed(java.lang.String unparsed)Adds a header to the unparsed list of headers.
unrecognizedHeaders.addElement(unparsed);
|
private void | attachHeader(Header h)Attaches a header and dies if you get a duplicate header exception.
if (h == null)
throw new IllegalArgumentException("null header!");
if (h instanceof HeaderList) {
HeaderList hl = (HeaderList) h;
if (hl.isEmpty()) {
// System.out.println("Attaching an empty header: " +
// h.getClass().getName());
return;
}
}
attachHeader(h, false, false);
|
public void | attachHeader(Header h, boolean replaceflag)Attaches a header to the end of the existing headers in
this Message structure.
This is equivalent to the attachHeader(Header,replaceflag,false);
which is the normal way in which headers are attached.
This was added in support of JAIN-SIP.
attachHeader(h, replaceflag, false);
|
public void | attachHeader(Header header, boolean replaceFlag, boolean top)Attaches the header to the SIP Message structure at a specified
position in its list of headers.
if (header == null) {
throw new NullPointerException("null header");
}
// System.out.println(">>> attachHeader( " +
// header + ", " + replaceFlag + ");");
Header h;
String expandedHeaderName = NameMap.expandHeaderName(
header.getHeaderName()).toLowerCase();
if (ListMap.hasList(header) &&
! sipHeaderListClass.isAssignableFrom(header.getClass())) {
HeaderList hdrList = ListMap.getList(header);
// Actually, hdrList.size() is always 0.
if (replaceFlag && (hdrList.size() > 0)) {
// remove first element
hdrList.removeElement(hdrList.elementAt(0));
}
hdrList.add(header);
h = hdrList;
} else {
h = header;
}
if (!replaceFlag && nameTable.containsKey(expandedHeaderName) &&
!(h instanceof HeaderList)) {
// Throw an exception here because according to JSR180:
// "The implementations MAY restrict the access to some
// headers according to RFC 3261."
//
// It may happen if this function is called to add a header that
// already exist and the only one header of this type may present
// (Call-Id, From, To).
//
throw new SipException("Header '" + header.getHeaderName() +
"' already exist. Only one header of this type is allowed.",
SipException.INVALID_OPERATION);
}
// Delete the first header with name = headerName
// from our list structure.
// If case of HeaderList the whole list is removed
// to avoid duplication (it is added bellow).
if (replaceFlag || (h instanceof HeaderList)) {
Enumeration li = headers.elements();
int index;
for (index = 0; li.hasMoreElements(); index++) {
Header next = (Header) li.nextElement();
String currName = NameMap.expandHeaderName(
next.getHeaderName());
if (expandedHeaderName.equalsIgnoreCase(currName)) {
headers.removeElementAt(index);
break;
}
}
}
Header hRef = h;
if (h instanceof HeaderList) {
HeaderList hdrlist = (HeaderList) nameTable.get(expandedHeaderName);
if (hdrlist != null) {
if (replaceFlag) {
hdrlist.removeFirst();
}
hdrlist.concatenate((HeaderList)h, top);
// This is required due to the way that 'concatenate'
// is implemented: if 'top' is false, it modifies
// the objects itself; otherwise, the list passed
// as the first parameter is modified.
if (!top) {
hRef = hdrlist;
}
}
}
nameTable.put(expandedHeaderName, hRef);
headers.addElement(hRef);
// Direct accessor fields for frequently accessed headers.
if (h instanceof FromHeader) {
this.fromHeader = (FromHeader)h;
} else if (h instanceof ContentLengthHeader) {
this.contentLengthHeader = (ContentLengthHeader) h;
} else if (h instanceof ToHeader) {
this.toHeader = (ToHeader)h;
} else if (h instanceof CSeqHeader) {
this.cSeqHeader = (CSeqHeader) h;
} else if (h instanceof CallIdHeader) {
this.callIdHeader = (CallIdHeader) h;
}
|
public java.lang.Object | clone()Clones 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.
Message retval = null;
try {
retval = (Message) this.getClass().newInstance();
} catch (IllegalAccessException ex) {
InternalErrorHandler.handleException(ex);
} catch (InstantiationException ex) {
InternalErrorHandler.handleException(ex);
}
Enumeration li = headers.elements();
while (li.hasMoreElements()) {
Header sipHeader = (Header) ((Header) li.nextElement()).clone();
try {
retval.attachHeader(sipHeader);
} catch (SipException ex) {
if (Logging.REPORT_LEVEL <= Logging.ERROR) {
Logging.report(Logging.ERROR, LogChannels.LC_JSR180,
"Message.clone(): can't attach header '" +
sipHeader.getName() + "'.");
ex.printStackTrace();
}
}
}
if (retval instanceof Request) {
Request thisRequest = (Request) this;
RequestLine rl = (RequestLine)
(thisRequest.getRequestLine()).clone();
((Request) retval).setRequestLine(rl);
} else {
Response thisResponse = (Response) this;
StatusLine sl = (StatusLine)
(thisResponse.getStatusLine()).clone();
((Response) retval).setStatusLine(sl);
}
if (getContent() != null) {
try {
retval.setContent(getContent(), getContentTypeHeader());
} catch (SipException ex) { // Ignore
if (Logging.REPORT_LEVEL <= Logging.ERROR) {
Logging.report(Logging.ERROR, LogChannels.LC_JSR180,
"Message.clone(): can't set the content!");
ex.printStackTrace();
}
}
}
return retval;
|
public java.lang.String | encode()Encodes 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).
StringBuffer encoding = new StringBuffer();
// Synchronization added because of concurrent modification exception
// noticed by Lamine Brahimi.
synchronized (this.headers) {
Enumeration it = this.headers.elements();
while (it.hasMoreElements()) {
Header siphdr = (Header) it.nextElement();
if (! (siphdr instanceof ContentLengthHeader)) {
encoding.append(siphdr.encode());
}
}
}
// Add the content-length header
if (contentLengthHeader != null) {
encoding.append(contentLengthHeader.encode()).append
(Separators.NEWLINE);
}
if (this.messageContentObject != null) {
String mbody = this.getContent().toString();
encoding.append(mbody);
} else if (this.messageContent != null ||
this.messageContentBytes != null) {
String content = null;
try {
if (messageContent != null) {
content = messageContent;
} else {
content = new String(messageContentBytes,
DEFAULT_ENCODING);
}
} catch (UnsupportedEncodingException ex) {
content = "";
}
encoding.append(content);
}
return encoding.toString();
|
public byte[] | encodeAsBytes()Encodes the message as a byte array.
Use this when the message payload is a binary byte array.
StringBuffer encoding = new StringBuffer();
Enumeration it = this.headers.elements();
while (it.hasMoreElements()) {
Header siphdr = (Header) it.nextElement();
if (! (siphdr instanceof ContentLengthHeader))
encoding.append(siphdr.encode());
}
byte[] retval = null;
byte[] content = this.getRawContent();
if (content != null) {
encoding.append(Header.CONTENT_LENGTH +
Separators.COLON +
Separators.SP + content.length
+ Separators.NEWLINE);
encoding.append(Separators.NEWLINE);
// Append the content
byte[] msgarray = null;
try {
msgarray = encoding.toString().getBytes("UTF-8");
} catch (UnsupportedEncodingException ex) {
InternalErrorHandler.handleException(ex);
}
retval = new byte[msgarray.length + content.length];
System.arraycopy(msgarray, 0, retval, 0, msgarray.length);
System.arraycopy(content, 0, retval, msgarray.
length, content.length);
} else {
// Message content does not exist.
encoding.append(Header.CONTENT_LENGTH +
Separators.COLON + Separators.SP + '0"
+ Separators.NEWLINE);
encoding.append(Separators.NEWLINE);
try {
retval = encoding.toString().getBytes("UTF-8");
} catch (UnsupportedEncodingException ex) {
InternalErrorHandler.handleException(ex);
}
}
return retval;
|
public boolean | equals(java.lang.Object other)Compares for equality.
if (!other.getClass().equals(this.getClass()))
return false;
Message otherMessage = (Message) other;
Enumeration values = this.nameTable.elements();
Hashtable otherNameTable = otherMessage.nameTable;
if (otherNameTable.size() != nameTable.size())
return false;
while (values.hasMoreElements()) {
Header mine = (Header) values.nextElement();
// maybe short form
String mineName =
NameMap.expandHeaderName(mine.getHeaderName()).trim()
.toLowerCase();
Header hisHeader = (Header) otherNameTable.get(mineName);
String his = null;
if (hisHeader != null) {
his = hisHeader.toString().trim();
}
if (his == null) {
return false;
} else if (! his.equals(mine.toString().trim())) {
return false;
}
}
return true;
|
public CSeqHeader | getCSeqHeader()Gets the CSeqHeader list of header (null if one does not exist).
return cSeqHeader;
|
public int | getCSeqHeaderNumber()Gets the sequence number.
return cSeqHeader.getSequenceNumber();
|
public CallIdHeader | getCallId()Gets the CallIdHeader header (null if one does not exist).
return callIdHeader;
|
public java.lang.String | getCallIdentifier()Gets the call ID string.
A conveniance function that returns the stuff following
the header name for the call id header.
return callIdHeader.getCallId();
|
public ContactList | getContactHeaders()Gets the Contact list of headers (null if one does not exist).
return (ContactList) getHeaderList(Header.CONTACT);
|
public java.lang.Object | getContent()Gets the content of the header.
if (this.messageContentObject != null)
return messageContentObject;
else if (this.messageContentBytes != null)
return this.messageContentBytes;
else if (this.messageContent != null)
return this.messageContent;
else return null;
|
public ContentLengthHeader | getContentLengthHeader()Gets the ContentLengthHeader header (null if one does not exist).
return contentLengthHeader;
|
public ContentTypeHeader | getContentTypeHeader()Gets the contentType header (null if one does not exist).
return (ContentTypeHeader) getHeader(Header.CONTENT_TYPE);
|
public java.lang.String | getDialogId(boolean isServer)Gets a dialog identifier.
Generates a string that can be used as a dialog identifier.
CallIdHeader cid = (CallIdHeader) this.getCallId();
StringBuffer retval = new StringBuffer(cid.getCallId());
FromHeader from = (FromHeader) this.getFromHeader();
ToHeader to = (ToHeader) this.getTo();
if (! isServer) {
if (to.getTag() != null) {
retval.append(to.getTag());
}
if (from.getTag() != null) {
retval.append(from.getTag());
}
} else {
if (from.getTag() != null) {
retval.append(from.getTag());
}
if (to.getTag() != null) {
retval.append(to.getTag());
}
}
return retval.toString().toLowerCase();
|
public java.lang.String | getDialogId(boolean isServer, java.lang.String toTag)Gets a dialog id given the remote tag.
FromHeader from = (FromHeader) this.getFromHeader();
ToHeader to = (ToHeader) this.getTo();
CallIdHeader cid = (CallIdHeader) this.getCallId();
StringBuffer retval = new StringBuffer(cid.getCallId());
if (! isServer) {
if (toTag != null) {
retval.append(toTag);
}
if (from.getTag() != null) {
retval.append(from.getTag());
}
} else {
if (from.getTag() != null) {
retval.append(from.getTag());
}
if (toTag != null) {
retval.append(toTag);
}
}
return retval.toString().toLowerCase();
|
public abstract java.lang.String | getFirstLine()Returns the encoded first line.
|
public FromHeader | getFromHeader()Gets the from header.
return (FromHeader) fromHeader;
|
public java.lang.String | getFromHeaderTag()Returns the from tag.
return fromHeader == null? null: fromHeader.getTag();
|
public Header | getHeader(java.lang.String headerName)Gets the first header of the given name.
if (headerName == null)
throw new NullPointerException("bad name");
headerName = NameMap.expandHeaderName(headerName).toLowerCase();
Header sipHeader = (Header)nameTable.get(headerName);
if (sipHeader == null) {
return null;
}
if (sipHeader instanceof HeaderList) {
return (Header) ((HeaderList) sipHeader).getFirst();
} else {
return (Header) sipHeader;
}
|
public HeaderList | getHeaderList(java.lang.String headerName)Gets a SIP Header list given its name.
Header header = (Header)nameTable.get(
NameMap.expandHeaderName(headerName).toLowerCase());
if (header == null) {
return null;
}
if (header instanceof HeaderList) {
return (HeaderList)header;
} else {
HeaderList hl = new HeaderList();
hl.add(header);
return hl;
}
|
public java.util.Enumeration | getHeaderNames()Gets the header names.
Enumeration li = this.headers.elements();
Vector retval = new Vector();
while (li.hasMoreElements()) {
Header sipHeader = (Header) li.nextElement();
String name = sipHeader.getName();
retval.addElement(name);
}
return retval.elements();
|
public java.util.Enumeration | getHeaders()Returns an iterator for the list of headers in this message.
return headers.elements();
|
public java.util.Enumeration | getHeaders(java.lang.String headerName)Gets a SIP header or Header list given its name.
if (headerName == null) {
throw new NullPointerException("null headerName");
}
Header sipHeader = (Header)nameTable.get(
NameMap.expandHeaderName(headerName).toLowerCase());
// empty iterator
if (sipHeader == null) {
return new Vector().elements();
}
if (sipHeader instanceof HeaderList) {
return ((HeaderList) sipHeader).getElements();
} else {
Vector v = new Vector();
v.addElement(sipHeader);
return v.elements();
}
|
public java.lang.String | getMessageContent()Gets 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.
if (this.messageContent == null && this.messageContentBytes == null)
return null;
else if (this.messageContent == null) {
ContentTypeHeader contentTypeHeader =
(ContentTypeHeader) this.nameTable
.get(Header.CONTENT_TYPE.toLowerCase());
if (contentTypeHeader != null) {
String charset = contentTypeHeader.getCharset();
if (charset != null) {
this.messageContent =
new String(messageContentBytes, charset);
} else {
this.messageContent =
new String(messageContentBytes, DEFAULT_ENCODING);
}
} else this.messageContent =
new String(messageContentBytes, DEFAULT_ENCODING);
}
return this.messageContent;
|
public byte[] | getRawContent()Gets 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.
try {
if (this.messageContent == null &&
this.messageContentBytes == null &&
this.messageContentObject == null) {
return null;
} else if (this.messageContentObject != null) {
String messageContent = this.messageContentObject.toString();
byte[] messageContentBytes;
ContentTypeHeader contentTypeHeader =
(ContentTypeHeader)this.nameTable.get
(Header.CONTENT_TYPE.toLowerCase());
if (contentTypeHeader != null) {
String charset = contentTypeHeader.getCharset();
if (charset != null) {
messageContentBytes = messageContent.getBytes(charset);
} else {
messageContentBytes =
messageContent.getBytes(DEFAULT_ENCODING);
}
} else messageContentBytes =
messageContent.getBytes(DEFAULT_ENCODING);
return messageContentBytes;
} else if (this.messageContent != null) {
byte[] messageContentBytes;
ContentTypeHeader contentTypeHeader =
(ContentTypeHeader)this.nameTable.get
(Header.CONTENT_TYPE.toLowerCase());
if (contentTypeHeader != null) {
String charset = contentTypeHeader.getCharset();
if (charset != null) {
messageContentBytes =
this.messageContent.getBytes(charset);
} else {
messageContentBytes =
this.messageContent.getBytes(DEFAULT_ENCODING);
}
} else messageContentBytes =
this.messageContent.getBytes(DEFAULT_ENCODING);
return messageContentBytes;
} else {
return messageContentBytes;
}
} catch (UnsupportedEncodingException ex) {
InternalErrorHandler.handleException(ex);
return null;
}
|
public RecordRouteList | getRecordRouteHeaders()Gets the RecordRoute header list (null if one does not exist).
return (RecordRouteList) this.getHeaderList(Header.RECORD_ROUTE);
|
public RouteList | getRouteHeaders()Gets the Route List of headers (null if one does not exist).
return (RouteList) getHeaderList(Header.ROUTE);
|
public abstract java.lang.String | getSIPVersion()Gets the SIP vesrion string.
|
public ToHeader | getTo()Gets the To header (null if one does not exist).
return (ToHeader) toHeader;
|
public java.lang.String | getToTag()Returns the To tag.
return toHeader == null ? null : toHeader.getTag();
|
public ViaHeader | getTopmostVia()Gets the topmost via header.
if (getViaHeaders() == null)
return null;
else
return (ViaHeader) (getViaHeaders().getFirst());
|
public java.lang.String | getTransactionId()Generates (compute) a transaction ID for this SIP message.
ViaHeader topVia = null;
if (! this.getViaHeaders().isEmpty()) {
topVia = (ViaHeader) this.getViaHeaders().first();
}
// Have specified a branch Identifier so we can use it to identify
// the transaction.
if (topVia.getBranch() != null &&
topVia.getBranch().startsWith
(SIPConstants.GENERAL_BRANCH_MAGIC_COOKIE)) {
// Bis 09 compatible branch assignment algorithm.
// implies that the branch id can be used as a transaction
// identifier.
return topVia.getBranch().toLowerCase();
} else {
// Old style client so construct the transaction identifier
// from various fields of the request.
StringBuffer retval = new StringBuffer();
FromHeader from = (FromHeader) this.getFromHeader();
ToHeader to = (ToHeader) this.getTo();
String hpFromHeader = from.getUserAtHostPort();
retval.append(hpFromHeader).append(":");
if (from.hasTag()) retval.append(from.getTag()).append(":");
String hpTo = to.getUserAtHostPort();
retval.append(hpTo).append(":");
String cid = this.callIdHeader.getCallId();
retval.append(cid).append(":");
retval.append(this.cSeqHeader.getSequenceNumber()).append(":").
append(this.cSeqHeader.getMethod());
if (topVia != null) {
retval.append(":").append(topVia.getSentBy().encode());
if (!topVia.getSentBy().hasPort()) {
retval.append(":").append(5060);
}
}
String hc =
Utils.toHexString(retval.toString().toLowerCase().getBytes());
if (hc.length() < 32)
return hc;
else return hc.substring(hc.length() - 32, hc.length() -1);
}
// Convert to lower case
|
public java.util.Enumeration | getUnrecognizedHeaders()Gets a list containing the unrecognized headers.
return unrecognizedHeaders.elements();
|
public ViaList | getViaHeaders()Gets the Via list of headers (null if one does not exist).
return (ViaList) getHeaderList(Header.VIA);
|
public boolean | hasContent()Returns true if this message has a body.
return messageContent != null || messageContentBytes != null;
|
public boolean | hasFromHeaderTag()Returns true if the message has a FromHeader header tag.
return fromHeader != null && fromHeader.getTag() != null;
|
public boolean | hasHeader(java.lang.String headerName)Returns true if the Message has a header of the given name.
return nameTable.containsKey(
NameMap.expandHeaderName(headerName).toLowerCase());
|
public boolean | hasToTag()Returns true if the message has a To header tag.
return toHeader != null && toHeader.getTag() != null;
|
public static boolean | isRequestHeader(Header sipHeader)Returns true if the header belongs only in a Request.
return sipHeader.getHeaderName().equals(Header.ALERT_INFO) ||
sipHeader.getHeaderName().equals(Header.IN_REPLY_TO) ||
sipHeader.getHeaderName().equals(Header.AUTHORIZATION) ||
sipHeader.getHeaderName().equals(Header.MAX_FORWARDS) ||
sipHeader.getHeaderName().equals(Header.PRIORITY) ||
sipHeader.getHeaderName().equals(Header.PROXY_AUTHORIZATION) ||
sipHeader.getHeaderName().equals(Header.PROXY_REQUIRE) ||
sipHeader.getHeaderName().equals(Header.ROUTE) ||
sipHeader.getHeaderName().equals(Header.SUBJECT) ||
sipHeader.getHeaderName().equals(Header.ACCEPT_CONTACT);
|
public static boolean | isResponseHeader(Header sipHeader)Returns true if the header belongs only in a response.
return sipHeader.getHeaderName().equals(Header.ERROR_INFO) ||
sipHeader.getHeaderName().equals(Header.PROXY_AUTHENTICATE) ||
sipHeader.getHeaderName().equals(Header.SERVER) ||
sipHeader.getHeaderName().equals(Header.UNSUPPORTED) ||
sipHeader.getHeaderName().equals(Header.RETRY_AFTER) ||
sipHeader.getHeaderName().equals(Header.WARNING) ||
sipHeader.getHeaderName().equals(Header.WWW_AUTHENTICATE);
|
public void | removeContent()Removes the message content if it exists.
messageContent = null;
messageContentBytes = null;
messageContentObject = null;
|
public void | removeHeader(java.lang.String headerName, boolean top)Removes 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.
// System.out.println("removeHeader " + headerName);
headerName = NameMap.expandHeaderName(headerName).toLowerCase();
Header toRemove = (Header) nameTable.get(headerName);
// nothing to do then we are done.
if (toRemove == null)
return;
if (toRemove instanceof HeaderList) {
HeaderList hdrList = (HeaderList) toRemove;
if (top) hdrList.removeFirst();
else hdrList.removeLast();
// Clean up empty list
if (hdrList.isEmpty()) {
removeHeaderFromList(headerName);
}
} else {
nameTable.remove(headerName);
if (toRemove instanceof FromHeader) {
this.fromHeader = null;
} else if (toRemove instanceof ToHeader) {
this.toHeader = null;
} else if (toRemove instanceof CSeqHeader) {
this.cSeqHeader = null;
} else if (toRemove instanceof CallIdHeader) {
this.callIdHeader = null;
} else if (toRemove instanceof ContentLengthHeader) {
this.contentLengthHeader = null;
}
removeHeaderFromList(headerName);
}
|
public void | removeHeader(java.lang.String headerName)Removes all headers given its name.
if (headerName == null) {
throw new NullPointerException("null arg");
}
headerName = NameMap.expandHeaderName(headerName).toLowerCase();
Header toRemove = (Header) nameTable.get(headerName);
// nothing to do then we are done.
if (toRemove == null)
return;
nameTable.remove(headerName);
// Remove the fast accessor fields.
if (toRemove instanceof FromHeader) {
this.fromHeader = null;
} else if (toRemove instanceof ToHeader) {
this.toHeader = null;
} else if (toRemove instanceof CSeqHeader) {
this.cSeqHeader = null;
} else if (toRemove instanceof CallIdHeader) {
this.callIdHeader = null;
} else if (toRemove instanceof ContentLengthHeader) {
this.contentLengthHeader = null;
}
removeHeaderFromList(headerName);
|
private void | removeHeaderFromList(java.lang.String headerName)Removes the specified header from "headers" list.
Enumeration li = headers.elements();
int index = -1;
while (li.hasMoreElements()) {
Header sipHeader = (Header) li.nextElement();
index ++;
String currName = NameMap.expandHeaderName(
sipHeader.getName());
if (Utils.equalsIgnoreCase(currName, headerName)) {
break;
}
}
if (index != -1 && index < headers.size()) {
headers.removeElementAt(index);
}
|
public void | setCSeqHeader(CSeqHeader cseqHeader)Sets the CSeqHeader header.
setHeader(cseqHeader);
|
public void | setCallId(CallIdHeader callId)Sets the call id header.
setHeader(callId);
|
public void | setCallId(java.lang.String callId)Gets the CallIdHeader header (null if one does not exist)
if (callIdHeader == null) {
setHeader(new CallIdHeader());
}
callIdHeader.setCallId(callId);
|
public void | setContent(java.lang.Object content, ContentTypeHeader contentTypeHeader)Sets the message content after converting the given object to a
String.
if (content == null) {
throw new NullPointerException("null content");
}
String contentString = content.toString();
this.setMessageContent(contentString);
this.setHeader(contentTypeHeader);
this.removeContent();
if (content instanceof String) {
this.messageContent = (String)content;
} else if (content instanceof byte[]) {
this.messageContentBytes = (byte[]) content;
} else this.messageContentObject = content;
int length = -1;
if (content instanceof String)
length = ((String)content).length();
else if (content instanceof byte[])
length = ((byte[])content).length;
ContentLengthHeader h = getContentLengthHeader();
if (length != -1 && h != null) {
h.setContentLength(length);
}
|
public void | setContent(java.lang.Object content)Sets the message content after converting the given object to a
String.
if (content == null)
throw new NullPointerException("null content");
String contentString = content.toString();
this.setMessageContent(contentString);
this.removeContent();
if (content instanceof String) {
this.messageContent = (String)content;
} else if (content instanceof byte[]) {
this.messageContentBytes = (byte[]) content;
} else this.messageContentObject = content;
int length = -1;
if (content instanceof String)
length = ((String)content).length();
else if (content instanceof byte[])
length = ((byte[])content).length;
ContentLengthHeader h = getContentLengthHeader();
if (length != -1 && h != null) {
h.setContentLength(length);
}
|
public void | setContentLength(ContentLengthHeader contentLength)Sets the content length header.
setHeader(contentLength);
|
public void | setFromHeader(FromHeader from)Sets the From header field value.
setHeader(from);
|
public void | setFromHeaderTag(java.lang.String tag)Sets the FromHeader Tag.
fromHeader.setTag(tag);
|
public void | setHeader(Header header)Attaches a header (replacing the original header).
if (header == null)
throw new IllegalArgumentException("null header!");
if (header instanceof HeaderList) {
HeaderList hl = (HeaderList) header;
// Ignore empty lists.
if (hl.isEmpty())
return;
}
attachHeader(header, true, false);
|
public void | setHeader(HeaderList sipHeaderList)Sets the header given a list of headers.
setHeader((Header)sipHeaderList);
|
public void | setHeaders(java.util.Vector headers)Sets a header from a linked list of headers.
Enumeration elements = headers.elements();
while (elements.hasMoreElements()) {
Header sipHeader = (Header) elements.nextElement();
attachHeader(sipHeader, false);
}
|
public void | setMessageContent(java.lang.String type, java.lang.String subType, java.lang.String messageContent)Sets the message content given type and subtype.
if (messageContent == null) {
throw new IllegalArgumentException("messgeContent is null");
}
ContentTypeHeader ct = new ContentTypeHeader(type, subType);
try {
setHeader(ct);
} catch (SipException se) {
throw new IllegalArgumentException(se.getMessage());
}
messageContent = messageContent;
messageContentBytes = null;
messageContentObject = null;
ContentLengthHeader h = getContentLengthHeader();
if (h != null) {
h.setContentLength(messageContent.length());
}
|
public void | setMessageContent(java.lang.String type, java.lang.String subType, byte[] messageContent)Sets the message content for a given type and subtype.
ContentTypeHeader ct = new ContentTypeHeader(type, subType);
setHeader(ct);
setMessageContent(messageContent);
ContentLengthHeader h = getContentLengthHeader();
if (h != null) {
h.setContentLength(messageContent.length);
}
|
public void | setMessageContent(java.lang.String content)Sets the message content for this message.
ContentLengthHeader h = getContentLengthHeader();
if (h != null) {
int clength = (content == null ? 0: content.length());
h.setContentLength(clength);
}
messageContent = content;
messageContentBytes = null;
messageContentObject = null;
|
public void | setMessageContent(byte[] content)Sets the message content as an array of bytes.
ContentLengthHeader h = getContentLengthHeader();
if (h != null) {
h.setContentLength(content.length);
}
messageContentBytes = content;
messageContent = null;
messageContentObject = null;
|
public abstract void | setSIPVersion(java.lang.String sipVersion)Sets the SIP version header.
|
public void | setTo(ToHeader to)Sets the To header field value.
setHeader(to);
|
public void | setToTag(java.lang.String tag)Sets the to tag.
toHeader.setTag(tag);
|
public void | setVia(ViaList viaList)Sets a list of via headers.
setHeader(viaList);
|
public void | setVia(java.util.Vector viaList)Sets a list of via headers.
this.removeHeader(ViaHeader.NAME);
for (int i = 0; i < viaList.size(); i++) {
ViaHeader via = (ViaHeader) viaList.elementAt(i);
this.addHeader(via);
}
|