return req.getRequestURI().getScheme();
}
if (req.getRequestURI().isSipURI()) {
// these parameters is only valid for SipURI's
SipURI uri = (SipURI) req.getRequestURI();
if (name.equals("request.uri.user")) {
return uri.getUser();
}
if (name.equals("request.uri.host")) {
return uri.getHost();
}
if (name.equals("request.uri.port")) {
return getUriPort(uri);
}
if (name.equals("request.uri.tel") &&
"phone".equals(uri.getParameter("user"))) {
return getPhoneNumber(uri.getUser());
}
} else if (req.getRequestURI().getScheme()
.equalsIgnoreCase(SipConstants.TEL_URI_PROTOCOL)) {
if (name.equals("request.uri.tel")) {
return getPhoneNumber(((TelURL) req.getRequestURI()).getPhoneNumber());
}
}
StringTokenizer token = new StringTokenizer(name, ".");
int ntok = token.countTokens();
String[] elements = new String[ntok];
for (int i = 0; i < ntok; i++) {
elements[i] = token.nextToken();
}
// Request URI parameters
if (name.startsWith("request.uri.param")) {
if (elements.length > 3) {
if (req.getRequestURI() instanceof SipURI) {
SipURI sipUri = (SipURI) req.getRequestURI();
return sipUri.getParameter(elements[3]);
} else {
TelURL telUrl = (TelURL) req.getRequestURI();
return telUrl.getParameter(elements[3]);
}
}
}
// General Headers
//
// request.<header>.uri
// request.<header>.uri.scheme
// request.<header>.uri.user
// request.<header>.uri.host
// request.<header>.uri.port
// request.<header>.uri.display-name
if (name.startsWith("request.")) {
if ((elements.length > 2) && "uri".equals(elements[2])) {
try {
if (elements.length < 4) {
return req.getHeader(elements[1]);
}
// Handle request.<header>.uri.scheme
if ("scheme".equals(elements[3])) {
return req.getAddressHeader(elements[1]).getURI()
.getScheme();
}
// request.<header>.uri.display-name
if ("display-name".equals(elements[3])) {
return req.getAddressHeader(elements[1]).getDisplayName();
}
if (req.getAddressHeader(elements[1]).getURI().isSipURI()) {
SipURI headerURI = (SipURI) req.getAddressHeader(elements[1])
.getURI();
if ("user".equals(elements[3])) {
return headerURI.getUser();
}
if ("host".equals(elements[3])) {
return headerURI.getHost();
}
if ("port".equals(elements[3])) {
return getUriPort(headerURI);
}