Methods Summary |
---|
public java.lang.String | getHeaderValue()Returns the full header value including parameters.
For example Alice <sip:alice@atlanta.com>;tag=1928301774
return header.getHeaderValue();
|
public java.lang.String | getName()Returns the name of this header
return header.getName();
|
public java.lang.String | getParameter(java.lang.String name)Returns the value of one header parameter.
For example, from value <sip:UserB@192.168.200.201>;expires=3600
the method call getParameter(expires) will return 3600.
NameValueList parameterList = header.getParameters();
if (parameterList == null || name == null) {
return null;
}
name = name.trim();
return parameterList.getParameter(name);
|
public java.lang.String[] | getParameterNames()Returns the names of header parameters. Returns null if there are no
header parameters.
NameValueList parameterList = header.getParameters();
if (parameterList == null || parameterList.size() == 0) {
return null;
}
Vector parameterNameList = parameterList.getNames();
String parameterNames[] = new String[parameterNameList.size()];
for (int i = 0; i < parameterList.size(); i++)
parameterNames[i] = (String)parameterNameList.elementAt(i);
return parameterNames;
|
public java.lang.String | getValue()Returns the header value without header parameters.
For example for header
<sip:UserB@192.168.200.201>;expires=3600 method
returns <sip:UserB@192.168.200.201>
In the case of an authorization or authentication header getValue()
returns only the authentication scheme e.g. Digest.
String name = header.getName();
String value = header.getValue().toString();
if (Header.isAuthorization(name)) {
value = value.trim();
int end = value.indexOf(' ");
if (end == -1) {
end = value.length();
}
return value.substring(0, end);
} else {
return value;
}
|
public void | removeParameter(java.lang.String name)Removes the header parameter, if it is found in this header.
NameValueList parameterList = header.getParameters();
if (parameterList != null && name != null) {
parameterList.delete(name);
}
|
public void | setName(java.lang.String name)Sets the header name, for example Contact
if (name != null) {
name = name.trim();
}
// Validating the name.
if (!Lexer.isValidName(name)) {
throw new IllegalArgumentException("Invalid name: '" + name + "'");
}
header.setHeaderName(name);
|
public void | setParameter(java.lang.String name, java.lang.String value)Sets value of header parameter. If parameter does not exist it
will be added.
For example, for header value <sip:UserB@192.168.200.201>
calling setParameter(expires, 3600) will construct header value
<sip:UserB@192.168.200.201>;expires=3600.
If the value is null, the parameter is interpreted as a parameter
without value.
NameValueList parameterList = header.getParameters();
// Validating the name.
if (name != null) {
name = name.trim();
}
if (!Lexer.isValidName(name)) {
throw new IllegalArgumentException("Invalid parameter's name.");
}
// Validating the value.
if (value != null) {
value = value.trim();
}
if (!Lexer.isValidParameterValue(value)) {
throw new IllegalArgumentException("Invalid parameter's value.");
}
// If the value is null, the parameter is interpreted as a parameter
// without value.
if (value == null) {
value = "";
}
header.setParameter(name, value);
|
public void | setValue(java.lang.String value)Sets the header value as String without parameters.
For example <sip:UserB@192.168.200.201>.
The existing (if any) header parameter values are not modified.
For the authorization and authentication header this method sets
the authentication scheme e.g. Digest.
if (value == null || value.equals("")) {
throw new IllegalArgumentException(
"Value must not be null or empty.");
}
// Validating the value.
if (!Lexer.isValidHeaderValue(value)) {
throw new IllegalArgumentException("Invalid header's value.");
}
String name = header.getName();
if (Header.isAuthorization(name)) {
// Authorization headers need additional validation.
// An existing parser is used to check the validity of the value.
try {
Header h = StackConnector.headerFactory.
createHeader(name, value);
if (((ParametersHeader)h).hasParameters()) {
throw new IllegalArgumentException("Value must not " +
"contain parameters.");
}
} catch (ParseException pe) {
throw new IllegalArgumentException(pe.getMessage());
}
}
header.setHeaderValue(value);
|
public java.lang.String | toString()Returns the String representation of the header according to
header type.
For example:
From: Alice <sip:alice@atlanta.com>;tag=1928301774
WWW-Authenticate: Digest realm=atlanta.com,
domain=sip:boxesbybob.com, qop=auth,
nonce=f84f1cec41e6cbe5aea9c8e88d359,
opaque=, stale=FALSE, algorithm=MD5
return header.toString();
|