javax.servlet.sip
Interface SipURI

All Superinterfaces:
java.lang.Cloneable, URI

public interface SipURI
extends URI

Represents sip and sips URIs.

SIP and SIPS URIs are used for addressing. They are similar to email addresses in that they are of the form user@host where user is either a user name or telephone number, and host is a host or domain name, or a numeric IP address. Additionally, SIP and SIPS URIs may contain parameters and headers (although headers are not legal in all contexts).

Syntactically, SIP and SIPS URIs are identical except for the name of URI scheme. The semantics differs in that the SIPS scheme implies that the identified resource is to be contacted using TLS. The following quote is from RFC 3261:

"A SIPS URI specifies that the resource be contacted securely. This means, in particular, that TLS is to be used between the UAC and the domain that owns the URI. From there, secure communications are used to reach the user, where the specific security mechanism depends on the policy of the domain. Any resource described by a SIP URI can be "upgraded" to a SIPS URI by just changing the scheme, if it is desired to communicate with that resource securely."

Because sip and sips URIs are syntactically identical and because they're used the same way, they're both represented by the SipURI interface.

The string form of SIP and SIPS URIs may contain escaped characters. The SIP servlet container is responsible for unescaping those characters before presenting URIs to servlets. Likewise, string values passed to setters for various SIP(S) URI components may contain reserved or excluded characters that need escaping before being used. The container is responsible for escaping those values.

See Also:
Address, SipFactory.createSipURI(java.lang.String, java.lang.String), SipServletRequest.getRequestURI()

Method Summary
 boolean equals(java.lang.Object o)
          Compares the given SipURI with this SipURI.
 java.lang.String getHeader(java.lang.String name)
          Returns the value of the specified header.
 java.util.Iterator<java.lang.String> getHeaderNames()
          Returns an Iterator over the names of all headers present in this SipURI.
 java.lang.String getHost()
          Returns the host part of this SipURI.
 boolean getLrParam()
          Returns true if the "lr" flag parameter is set, and false otherwise.
 java.lang.String getMAddrParam()
          Returns the value of the "maddr" parameter, or null if this is not set.
 java.lang.String getMethodParam()
          Returns the value of the "method" parameter, or null if this is not set.
 int getPort()
          Returns the port number of this SipURI, or -1 if this is not set.
 java.lang.String getTransportParam()
          Returns the value of the "transport" parameter, or null if this is not set.
 int getTTLParam()
          Returns the value of the "ttl" parameter, or -1 if this is not set.
 java.lang.String getUser()
          Returns the user part of this SipURI.
 java.lang.String getUserParam()
          Returns the value of the "user" parameter, or null if this is not set.
 java.lang.String getUserPassword()
          Returns the password of this SipURI, or null if this is not set.
 boolean isSecure()
          Returns true if this SipURI is secure, that is, if this it represents a sips URI.
 void removeHeader(java.lang.String name)
          Removes the named header from this SipURI.
 void setHeader(java.lang.String name, java.lang.String value)
          Sets the value of the specified header in this SipURI.
 void setHost(java.lang.String host)
          Sets the host part of this SipURI.
 void setLrParam(boolean flag)
          Sets or removes the "lr" parameter depending on the value of the flag.
 void setMAddrParam(java.lang.String maddr)
          Sets the value of the "maddr" parameter.
 void setMethodParam(java.lang.String method)
          Sets the value of the "method" parameter.
 void setPort(int port)
          Sets the port number of this SipURI.
 void setSecure(boolean b)
          Sets the scheme of this URI to sip or sips depending on whether the argument is true or not.
 void setTransportParam(java.lang.String transport)
          Sets the value of the "transport" parameter.
 void setTTLParam(int ttl)
          Sets the value of the "ttl" parameter.
 void setUser(java.lang.String user)
          Sets the user part of this SipURI.
 void setUserParam(java.lang.String user)
          Sets the value of the "user" parameter.
 void setUserPassword(java.lang.String password)
          Sets the password of this SipURI.
 java.lang.String toString()
          Returns the String representation of this SipURI.
 
Methods inherited from interface javax.servlet.sip.URI
clone, getParameter, getParameterNames, getScheme, isSipURI, removeParameter, setParameter
 

Method Detail

getUser

java.lang.String getUser()
Returns the user part of this SipURI.

Returns:
the user part of this SipURI

setUser

void setUser(java.lang.String user)
Sets the user part of this SipURI.

Parameters:
user - the new user part

getUserPassword

java.lang.String getUserPassword()
Returns the password of this SipURI, or null if this is not set.

Returns:
the password of this SipURI

setUserPassword

void setUserPassword(java.lang.String password)
Sets the password of this SipURI. The use of passwords in SIP or SIPS URIs is discouraged as sending passwords in clear text is a security risk.

Parameters:
password - the new password

getHost

java.lang.String getHost()
Returns the host part of this SipURI.

Returns:
the host part of this SipURI

setHost

void setHost(java.lang.String host)
Sets the host part of this SipURI. This should be a fully qualified domain name or a numeric IP address.

Parameters:
host - the new host name

getPort

int getPort()
Returns the port number of this SipURI, or -1 if this is not set.

Returns:
the port number of this SipURI

setPort

void setPort(int port)
Sets the port number of this SipURI.

Parameters:
port - the new port number. A negative value means the port number is not set and a subsequent call to getPort() should return -1.

isSecure

boolean isSecure()
Returns true if this SipURI is secure, that is, if this it represents a sips URI. For "ordinary" sip URIs, false is returned.

Returns:
true if this SipURI represents a sips URI, and false if it represents a sip URI

setSecure

void setSecure(boolean b)
Sets the scheme of this URI to sip or sips depending on whether the argument is true or not.

Parameters:
b - determines whether the scheme of this SipURI is set to sip or sips

getTransportParam

java.lang.String getTransportParam()
Returns the value of the "transport" parameter, or null if this is not set. This is equivalent to getParameter("transport").

Returns:
the value of the "transport" parameter

setTransportParam

void setTransportParam(java.lang.String transport)
Sets the value of the "transport" parameter. This parameter specifies which transport protocol to use for sending requests and responses to this entity. The following values are defined: "udp", "tcp", "sctp", "tls", but other values may be used also

This method is equivalent to setParameter("transport", transport).

Parameters:
transport - new value for the "transport" parameter

getMAddrParam

java.lang.String getMAddrParam()
Returns the value of the "maddr" parameter, or null if this is not set. This is equivalent to getParameter("maddr").

Returns:
the value of the "maddr" parameter

setMAddrParam

void setMAddrParam(java.lang.String maddr)
Sets the value of the "maddr" parameter. This is equivalent to setParameter("maddr", maddr).

Parameters:
maddr - new value of the "maddr" parameter

getMethodParam

java.lang.String getMethodParam()
Returns the value of the "method" parameter, or null if this is not set. This is equivalent to getParameter("method").

Returns:
the value of the "method" parameter

setMethodParam

void setMethodParam(java.lang.String method)
Sets the value of the "method" parameter. This specifies which SIP method to use in requests directed at this SIP/SIPS URI.

This method is equivalent to setParameter("method", method).

Parameters:
method - new value of the "method" parameter

getTTLParam

int getTTLParam()
Returns the value of the "ttl" parameter, or -1 if this is not set. This method is equivalent to getParameter("ttl").

Returns:
the value of the "ttl" parameter

setTTLParam

void setTTLParam(int ttl)
Sets the value of the "ttl" parameter. The ttl parameter specifies the time-to-live value when packets are sent using UDP multicast.

This is equivalent to setParameter("ttl", ttl).

Parameters:
ttl - new value of the "ttl" parameter

getUserParam

java.lang.String getUserParam()
Returns the value of the "user" parameter, or null if this is not set. This is equivalent to getParameter("user").

Returns:
the value of the "user" parameter

setUserParam

void setUserParam(java.lang.String user)
Sets the value of the "user" parameter. This is equivalent to setParameter("user", user).

Parameters:
user - new value for the "user" parameter

getLrParam

boolean getLrParam()
Returns true if the "lr" flag parameter is set, and false otherwise. This is equivalent to "".equals(getParameter("lr")).

Returns:
true if the "lr" flag parameter is set, and false otherwise

setLrParam

void setLrParam(boolean flag)
Sets or removes the "lr" parameter depending on the value of the flag.

Parameters:
flag - specifies that the "lr" flag parameter is to be set (true) or removed (false)

getHeader

java.lang.String getHeader(java.lang.String name)
Returns the value of the specified header. SIP/SIPS URIs may specify headers. As an example, the URI sip:joe@example.com?Priority=emergency has a header "Priority" whose value is "emergency".

Parameters:
name - the header name
Returns:
the value of the specified header in this SipURI
Throws:
java.lang.NullPointerException - if the name is null.

setHeader

void setHeader(java.lang.String name,
               java.lang.String value)
Sets the value of the specified header in this SipURI.

Parameters:
name - header name
value - header value

removeHeader

void removeHeader(java.lang.String name)
Removes the named header from this SipURI. Nothing is done if the SipURI did not already contain the specific header.

Parameters:
name - header name
Since:
1.1

getHeaderNames

java.util.Iterator<java.lang.String> getHeaderNames()
Returns an Iterator over the names of all headers present in this SipURI.

Returns:
an Iterator over all header names

toString

java.lang.String toString()
Returns the String representation of this SipURI. Any reserved characters will be properly escaped according to RFC2396.

Specified by:
toString in interface URI
Overrides:
toString in class java.lang.Object
Returns:
this sip or sips URI as a String

equals

boolean equals(java.lang.Object o)
Compares the given SipURI with this SipURI. The rules specified in section 19.1.4 RFC 3261 must be used for comparison.

Specified by:
equals in interface URI
Overrides:
equals in class java.lang.Object
Parameters:
o - the URI which is to be compared with this.
Returns:
true if the two SipURIs are equal.
Since:
1.1