本文整理汇总了Java中javax.sip.InvalidArgumentException类的典型用法代码示例。如果您正苦于以下问题:Java InvalidArgumentException类的具体用法?Java InvalidArgumentException怎么用?Java InvalidArgumentException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
InvalidArgumentException类属于javax.sip包,在下文中一共展示了InvalidArgumentException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: computeContentLength
import javax.sip.InvalidArgumentException; //导入依赖的package包/类
/**
* Compute and set the Content-length header based on the given content object.
*
* @param content is the content, as String, array of bytes, or other object.
*/
private void computeContentLength(Object content) {
int length = 0;
if (content != null) {
if (content instanceof String) {
try {
length = ((String) content).getBytes( getCharset() ).length;
} catch (UnsupportedEncodingException ex) {
InternalErrorHandler.handleException(ex);
}
} else if (content instanceof byte[]) {
length = ((byte[]) content).length;
} else {
length = content.toString().length();
}
}
try {
contentLengthHeader.setContentLength(length);
} catch (InvalidArgumentException e) {
// Cannot happen.
}
}
示例2: addHeader
import javax.sip.InvalidArgumentException; //导入依赖的package包/类
/**
* Add a SIP header.
*
* @param sipHeader -- sip header to add.
*/
public void addHeader(Header sipHeader) {
// Content length is never stored. Just computed.
SIPHeader sh = (SIPHeader) sipHeader;
try {
if ((sipHeader instanceof ViaHeader) || (sipHeader instanceof RecordRouteHeader)) {
attachHeader(sh, false, true);
} else {
attachHeader(sh, false, false);
}
} catch (SIPDuplicateHeaderException ex) {
try {
if (sipHeader instanceof ContentLength) {
ContentLength cl = (ContentLength) sipHeader;
contentLengthHeader.setContentLength(cl.getContentLength());
}
} catch (InvalidArgumentException e) {
}
}
}
示例3: resendAck
import javax.sip.InvalidArgumentException; //导入依赖的package包/类
/**
* Resend the last ack.
*/
public void resendAck() throws SipException {
// Check for null.
if (this.getLastAckSent() != null) {
if (getLastAckSent().getHeader(TimeStampHeader.NAME) != null
&& sipStack.generateTimeStampHeader) {
TimeStamp ts = new TimeStamp();
try {
ts.setTimeStamp(System.currentTimeMillis());
getLastAckSent().setHeader(ts);
} catch (InvalidArgumentException e) {
}
}
this.sendAck(getLastAckSent(), false);
} else {
if(logger.isLoggingEnabled(LogWriter.TRACE_DEBUG)){
logger.logDebug("SIPDialog::resendAck:lastAck sent is NULL hence not resending ACK");
}
}
}
示例4: createRAckHeader
import javax.sip.InvalidArgumentException; //导入依赖的package包/类
/**
* Creates a new RAckHeader based on the newly supplied rSeqNumber,
* cSeqNumber and method values.
*
* @param rSeqNumber - the new integer value of the rSeqNumber.
* @param cSeqNumber - the new integer value of the cSeqNumber.
* @param method - the new string value of the method.
* @throws InvalidArgumentException if supplied rSeqNumber or cSeqNumber is
* less than zero or greater than than 2**31-1.
* @throws ParseException which signals that an error has been reached
* unexpectedly while parsing the method value.
* @return the newly created RAckHeader object.
* @since v1.1
*/
public RAckHeader createRAckHeader(
long rSeqNumber,
long cSeqNumber,
String method)
throws InvalidArgumentException, ParseException {
if (method == null)
throw new NullPointerException("Bad method");
if (cSeqNumber < 0 || rSeqNumber < 0)
throw new InvalidArgumentException("bad cseq/rseq arg");
RAck rack = new RAck();
rack.setMethod(method);
rack.setCSequenceNumber(cSeqNumber);
rack.setRSequenceNumber(rSeqNumber);
return rack;
}
示例5: removeContent
import javax.sip.InvalidArgumentException; //导入依赖的package包/类
/**
* Remove the message content if it exists.
*/
public void removeContent() {
messageContent = null;
messageContentBytes = null;
messageContentObject = null;
try {
this.contentLengthHeader.setContentLength(0);
} catch (InvalidArgumentException ex) {
}
}
示例6: setContentLength
import javax.sip.InvalidArgumentException; //导入依赖的package包/类
/**
* Set the content length header.
*
* @param contentLength -- content length header.
*/
public void setContentLength(ContentLengthHeader contentLength) {
try {
this.contentLengthHeader.setContentLength(contentLength.getContentLength());
} catch (InvalidArgumentException ex) {
}
}
示例7: setSPIServer
import javax.sip.InvalidArgumentException; //导入依赖的package包/类
/**
* Set Server SPI (spi-s parameter)
* @param spis - spi-s value
* @throws InvalidArgumentException - when value is not valid
*/
public void setSPIServer(int spis) throws InvalidArgumentException {
if (spis < 0)
throw new InvalidArgumentException(
"JAIN-SIP "
+ "Exception, SecurityClient, setSPIServer(), the spi-s parameter is <0");
setParameter(ParameterNamesIms.SPI_S, spis);
}
示例8: setPortClient
import javax.sip.InvalidArgumentException; //导入依赖的package包/类
/**
* Set Client Port (port-c parameter)
* @param portC - port-c value
* @throws InvalidArgumentException - when value is not valid
*/
public void setPortClient(int portC) throws InvalidArgumentException {
if (portC < 0)
throw new InvalidArgumentException(
"JAIN-SIP "
+ "Exception, SecurityClient, setPortClient(), the port-c parameter is <0");
setParameter(ParameterNamesIms.PORT_C, portC);
}
示例9: setPortServer
import javax.sip.InvalidArgumentException; //导入依赖的package包/类
/**
* Set Server Port (port-s parameter)
* @param portS - port-s value
* @throws InvalidArgumentException - when value is not valid
*/
public void setPortServer(int portS) throws InvalidArgumentException {
if (portS < 0)
throw new InvalidArgumentException(
"JAIN-SIP "
+ "Exception, SecurityClient, setPortServer(), the port-s parameter is <0");
setParameter(ParameterNamesIms.PORT_S, portS);
}
示例10: setMediaAuthorizationToken
import javax.sip.InvalidArgumentException; //导入依赖的package包/类
/**
* Set the media authorization token.
*
* @param token - media authorization token to set
* @throws InvalidArgumentException - if token is null or empty
*/
public void setMediaAuthorizationToken(String token) throws InvalidArgumentException
{
if (token == null || token.length() == 0)
throw new InvalidArgumentException(" the Media-Authorization-Token parameter is null or empty");
this.token = token;
}
示例11: setCode
import javax.sip.InvalidArgumentException; //导入依赖的package包/类
/**
* Sets code of WarningHeader
* @param code int to set
* @throws SipParseException if code is not accepted by implementation
*/
public void setCode(int code) throws InvalidArgumentException {
if (code >99 && code < 1000) { // check this is a 3DIGIT code
this.code = code;
} else
throw new InvalidArgumentException(
"Code parameter in the Warning header is invalid: code="
+ code);
}
示例12: setMinorVersion
import javax.sip.InvalidArgumentException; //导入依赖的package包/类
/**
* Sets the Minor-Version argument of this MimeVersionHeader to the supplied
* <var>minorVersion</var> value.
*
* @param minorVersion - the new integer Minor version
* @throws InvalidArgumentException
*/
public void setMinorVersion(int minorVersion)
throws InvalidArgumentException {
if (minorVersion < 0)
throw new InvalidArgumentException(
"JAIN-SIP Exception"
+ ", MimeVersion, setMinorVersion(), the minorVersion parameter is null");
this.minorVersion = minorVersion;
}
示例13: setMajorVersion
import javax.sip.InvalidArgumentException; //导入依赖的package包/类
/**
* Sets the Major-Version argument of this MimeVersionHeader to the supplied
* <var>majorVersion</var> value.
*
* @param majorVersion - the new integer Major version
* @throws InvalidArgumentException
*/
public void setMajorVersion(int majorVersion)
throws InvalidArgumentException {
if (majorVersion < 0)
throw new InvalidArgumentException(
"JAIN-SIP Exception"
+ ", MimeVersion, setMajorVersion(), the majorVersion parameter is null");
this.majorVersion = majorVersion;
}
示例14: setSeqNumber
import javax.sip.InvalidArgumentException; //导入依赖的package包/类
public void setSeqNumber(long sequenceNumber) throws InvalidArgumentException {
if (sequenceNumber <= 0 ||sequenceNumber > ((long)1)<<32 - 1)
throw new InvalidArgumentException(
"Bad seq number " + sequenceNumber);
this.sequenceNumber = sequenceNumber;
}
示例15: setQValue
import javax.sip.InvalidArgumentException; //导入依赖的package包/类
/**
* set the Q-value parameter
* @param qValue float to set
*/
public void setQValue(float qValue) throws InvalidArgumentException {
if (qValue != -1 && (qValue < 0 || qValue > 1))
throw new InvalidArgumentException(
"JAIN-SIP Exception, Contact, setQValue(), "
+ "the qValue is not between 0 and 1");
this.parameters.set(Q, Float.valueOf(qValue));
}