Methods Summary |
---|
public void | clearPassword()Clears the password from the user part if it exists.
if (this.authority != null) {
UserInfo userInfo = authority.getUserInfo();
if (userInfo != null) userInfo.clearPassword();
}
|
public void | clearQheaders()Clears all Qheaders.
qheaders = new NameValueList("qheaders");
|
public void | clearUriParms()Clears all URI Parameters.
uriParms = new NameValueList("uriparms");
|
public java.lang.Object | clone()Copies the current instance.
SipURI retval = new SipURI();
retval.scheme = new String(this.scheme);
retval.authority = (Authority) this.authority.clone();
retval.uriParms = (NameValueList) this.uriParms.clone();
if (this.qheaders != null)
retval.qheaders =
(NameValueList) this.qheaders.clone();
if (this.telephoneSubscriber != null) {
retval.telephoneSubscriber =
(TelephoneNumber)
this.telephoneSubscriber.clone();
}
return retval;
|
public java.lang.String | encode()Constructs a URL from the parsed structure.
StringBuffer retval =
new StringBuffer(scheme).append(Separators.COLON);
if (authority != null) {
retval.append(authority.encode());
}
if (!uriParms.isEmpty()) {
retval.append(Separators.SEMICOLON).append(uriParms.encode());
}
if (!qheaders.isEmpty()) {
retval.append(Separators.QUESTION).append(qheaders.encode());
}
return retval.toString();
|
public boolean | equals(java.lang.Object that)Compares two URIs and return true if they are equal.
if (that == null) {
return false;
}
if (!this.getClass().equals(that.getClass())) {
return false;
}
SipURI other = (SipURI) that;
// Compare the authority portion.
if (!this.authority.equals(other.authority))
return false;
// compare the parameter lists.
// Assuming default for TRANSPORT so cannot use the method
// of NameValueList to check for equality
NameValueList hisParms = other.uriParms;
// transport comparation
String currTransport = uriParms.getValueDefault
(SIPConstants.GENERAL_TRANSPORT, SIPConstants.TRANSPORT_UDP);
String hisTransport = hisParms.getValueDefault
(SIPConstants.GENERAL_TRANSPORT, SIPConstants.TRANSPORT_UDP);
if (!currTransport.equals(hisTransport))
return false;
// other parameters
Enumeration enumNames = uriParms.getKeys();
String currKey;
while (enumNames.hasMoreElements()) {
currKey = (String)enumNames.nextElement();
if (currKey.equals(SIPConstants.GENERAL_TRANSPORT)) continue;
// check that other URI contains this parameter
if (!hisParms.hasNameValue(currKey))
return false;
// check that other URI contains the same value of this parameter
if (!uriParms.getValue(currKey).equals(
hisParms.getValue(currKey)))
return false;
}
// leave headers alone - they are just a screwy way of constructing
// an entire sip message header as part of a URL.
return true;
|
public Authority | getAuthority()Gets the authority.
return this.authority;
|
public int | getDefaultPort()Returns default port number according to current scheme.
return (scheme.equalsIgnoreCase(SIPConstants.SCHEME_SIP)) ?
SIPConstants.DEFAULT_NONTLS_PORT : SIPConstants.DEFAULT_TLS_PORT;
|
public java.lang.String | getHeader(java.lang.String name)Returns the value of the named header, or null if it is not set.
SIP/SIPS URIs may specify headers. As an example, the URI
sip:joe@jcp.org?priority=urgent has a header "priority" whose
value is "urgent".
return this.qheaders.getValue(name) != null ?
this.qheaders.getValue(name).toString() : null;
|
public java.util.Vector | getHeaderNames()Returns an Iterator over the names (Strings) of all headers present
in this SipURI.
return this.qheaders.getNames();
|
public java.lang.String | getHost()Gets the host protion of the URI.
Host h = authority.getHost();
return (h == null) ? "" : h.encode();
|
public HostPort | getHostPort()Gets the host and port of the server.
if (authority == null)
return null;
else {
return authority.getHostPort();
}
|
public java.lang.String | getLrParam()Returns the value of the lr parameter, or null if this
is not set. This is equivalent to getParameter("lr").
boolean haslr = this.hasParameter(LR);
return haslr? "true":null;
|
public java.lang.String | getMAddrParam()Returns the value of the maddr parameter, or null if this
is not set. This is equivalent to getParameter("maddr").
NameValue maddr = uriParms.getNameValue(MADDR);
if (maddr == null)
return null;
String host = (String) maddr.getValue();
return host;
|
public java.lang.String | getMethod()Gets the method parameter.
return (String) getParm(SIPConstants.GENERAL_METHOD);
|
public java.lang.String | getMethodParam()Returns the value of the method parameter, or null if this
is not set. This is equivalent to getParameter("method").
return this.getParameter(METHOD);
|
public java.lang.String | getParameter(java.lang.String name)Returns the value of the named parameter, or null if it is not set. A
zero-length String indicates flag parameter.
Object val = uriParms.getValue(name.toLowerCase());
if (val == null)
return null;
if (val instanceof GenericObject)
return ((GenericObject)val).encode();
else return val.toString();
|
public java.util.Vector | getParameterNames()Returns an Iterator over the names (Strings) of all parameters present
in this ParametersHeader.
return uriParms.getNames();
|
public java.lang.Object | getParm(java.lang.String parmname)Gets the parameter (do a name lookup) and return null if none exists.
Object obj = uriParms.getValue(parmname);
return obj;
|
public java.lang.String | getPlainURI()Returns the URI part of the address (without parameters)
i.e. scheme:user@host:port.
StringBuffer retval =
new StringBuffer(scheme).append(Separators.COLON);
retval.append(getUserAtHostPort());
return retval.toString();
|
public int | getPort()Gets the port from the authority field.
HostPort hp = this.getHostPort();
if (hp == null) {
return -1;
}
return hp.getPort();
|
public NameValueList | getQheaders()Accessor forSIPObjects
return qheaders;
|
public int | getTTLParam()Returns the value of the "ttl" parameter, or -1 if this is not set.
This method is equivalent to getParameter("ttl").
Integer ttl = (Integer) uriParms.getValue(SIPConstants.GENERAL_TTL);
if (ttl != null)
return ttl.intValue();
else
return -1;
|
public TelephoneNumber | getTelephoneSubscriber()Returns the stucture corresponding to the telephone number
provided that the user is a telephone subscriber.
if (telephoneSubscriber == null) {
telephoneSubscriber = new TelephoneNumber();
}
return telephoneSubscriber;
|
public java.lang.String | getTransportParam()Returns the value of the "transport" parameter, or null if this is not
set. This is equivalent to getParameter("transport").
if (uriParms != null) {
return (String) uriParms.getValue(SIPConstants.GENERAL_TRANSPORT);
} else return null;
|
public java.lang.String | getTypeParam()Returns the value of the "type" parameter, or null if this is not
set. This is equivalent to getParameter("type"). The result is
unquoted
if (uriParms != null) {
NameValue nv = uriParms.getNameValue(SIPConstants.GENERAL_TYPE);
if (nv == null) {
return null;
}
return (String)nv.getUnquotedValue();
} else return null;
|
public NameValueList | getUriParms()Accessor for URI parameters
return uriParms;
|
public java.lang.String | getUser()Returns the value of the userParam ,
or null if this is not set.
This is equivalent to getParameter("user").
return authority.getUser();
|
public java.lang.String | getUserAtHost()Gets user at host information.
if (authority == null) {
return null;
}
String user = authority.getUserInfo().getUser();
String host = authority.getHost().encode();
return new StringBuffer(user).
append(Separators.AT).append(host).toString();
|
public java.lang.String | getUserAtHostPort()Gets user at host and port infromation.
instead of the current function body.
return authority.encode();
|
public java.lang.String | getUserParam()Returns the user part of this SipURI, or null if it is not set.
return getParameter("user");
|
public java.lang.String | getUserPassword()Gets the password of the user.
if (authority == null)
return null;
return authority.getPassword();
|
public java.lang.String | getUserType()Gets the user parameter.
return (String) uriParms.getValue(SIPConstants.GENERAL_USER);
|
public boolean | hasLrParam()Returns whether the the lr parameter is set. This is
equivalent to hasParameter("lr"). This interface has no getLrParam as
RFC3261 does not specify any values for the "lr" paramater.
return uriParms.getNameValue(SIPConstants.GENERAL_LR) != null;
|
public boolean | hasParameter(java.lang.String name)Boolean to check if a parameter of a given name exists.
return uriParms.getValue(name) != null;
|
public boolean | hasTransport()Returns true if the transport parameter is defined.
return hasParameter(TRANSPORT);
|
public boolean | isSecure()Returns true if this SipURI is secure i.e. if this SipURI represents a
sips URI. A sip URI returns false.
return equalsIgnoreCase(this.getScheme(), SIPConstants.SCHEME_SIPS);
|
public boolean | isServer()Checks if URI is shared.
return isServer;
|
public boolean | isShared()Checks if URI is shared.
return isShared;
|
public boolean | isSipURI()This method determines if this is a URI with a scheme of "sip"
or "sips".
return true;
|
public boolean | isTelURL()This method determines if this is a URI with a scheme of
"tel"
return false;
|
public boolean | isUserTelephoneSubscriber()Returns true if the user is a telephone subscriber.
If the host is an Internet telephony
gateway, a telephone-subscriber field MAY be used instead
of a user field. The telephone-subscriber field uses the
notation of RFC 2806 [19]. Any characters of the un-escaped
"telephone-subscriber" that are not either in the set
"unreserved" or "user-unreserved" MUST be escaped. The set
of characters not reserved in the RFC 2806 description of
telephone-subscriber contains a number of characters in
various syntax elements that need to be escaped when used
in SIP URLs, for example quotation marks (%22), hash (%23),
colon (%3a), at-sign (%40) and the "unwise" characters,
i.e., punctuation of %5b and above.
The telephone number is a special case of a user name and
cannot be distinguished by a BNF. Thus, a URL parameter,
user, is added to distinguish telephone numbers from user
names.
The user parameter value "phone" indicates that the user
part contains a telephone number. Even without this
parameter, recipients of SIP URLs MAY interpret the pre-@
part as a telephone number if local restrictions on the
String usrtype = (String) uriParms.getValue(USER);
if (usrtype == null) {
return false;
}
return usrtype.equals("phone");
|
public void | removeHeader(java.lang.String name)Removes a header given its name (provided it exists).
if (qheaders != null) qheaders.delete(name);
|
public void | removeHeaders()Removes all headers.
qheaders = new NameValueList("qheaders");
|
public void | removeMAddr()Removes the maddr param if it exists.
if (uriParms != null) uriParms.delete(MADDR);
|
public void | removeMethod()Removes the Method.
if (uriParms != null) uriParms.delete(METHOD);
|
public void | removeParameter(java.lang.String name)Removes a parameter given its name
uriParms.delete(name);
|
public void | removePort()Removes the port setting.
authority.removePort();
|
public void | removeTTL()Removes the ttl value from the parameter list if it exists.
if (uriParms != null) uriParms.delete(TTL);
|
public void | removeTransport()Deletes the transport string.
if (uriParms != null) uriParms.delete(TRANSPORT);
|
public void | removeUriParms()Removes the URI parameters.
uriParms = new NameValueList();
|
public void | removeUser()Removes the user.
authority.removeUserInfo();
|
public void | removeUserType()Sets the user type.
if (uriParms != null) uriParms.delete(USER);
|
public void | setAuthority(Authority newAuthority)Sets the authority member
authority = newAuthority;
|
public void | setDefaultParm(java.lang.String name, java.lang.Object value)Sets the default parameters for this URI.
Do nothing if the parameter is already set to some value.
Otherwise set it to the given value.
if (uriParms.getValue(name) == null) {
NameValue nv = new NameValue(name, value);
uriParms.add(nv);
}
|
public void | setHeader(java.lang.String name, java.lang.String value)Sets the value of the specified header fields to be included in a
request constructed from the URI. If the header already had a value it
will be overwritten.
if (qheaders.getValue(name) == null) {
NameValue nv = new NameValue(name, value);
qheaders.add(nv);
} else {
NameValue nv = qheaders.getNameValue(name);
nv.setValue(value);
}
|
public void | setHost(Host h)Sets the host for this URI.
// authority = new Authority();
if (authority == null) {
authority = new Authority();
}
authority.setHost(h);
|
public void | setHost(java.lang.String host)Returns the host part of this SipURI.
Lexer lexer = new Lexer("sip_urlLexer", host);
HostNameParser hnp = new HostNameParser(lexer);
try {
Host h = new Host(hnp.hostName());
if (GenericObject.compareToIgnoreCase(h.getHostname(), host) == 0) {
this.setHost(h);
return;
}
} catch (ParseException e) {
throw new IllegalArgumentException(e.getMessage());
}
throw new IllegalArgumentException("Illegal host name");
|
public void | setHostPort(HostPort hostPort)Sets the hostPort field of the embedded authority field.
if (this.authority == null) {
this.authority = new Authority();
}
authority.setHostPort(hostPort);
|
public void | setIsdnSubAddress(java.lang.String isdnSubAddress)Sets ISDN subaddress of SipURL.
if (telephoneSubscriber == null)
telephoneSubscriber = new TelephoneNumber();
telephoneSubscriber.setIsdnSubaddress(isdnSubAddress);
|
public void | setLrParam()Sets the value of the lr parameter of this SipURI. The lr
parameter, when present, indicates that the element responsible for
this resource implements the routing mechanisms specified in RFC 3261.
This parameter will be used in the URIs proxies place in the
Record-Route header field values, and may appear in the URIs in a
pre-existing route set.
if (uriParms.getValue(SIPConstants.GENERAL_LR) != null)
return;
NameValue nv = new NameValue(SIPConstants.GENERAL_LR, null);
uriParms.add(nv);
|
public void | setMAddr(java.lang.String mAddr)Sets the MADDR parameter.
NameValue nameValue = uriParms.getNameValue(MADDR);
Host host = new Host();
host.setAddress(mAddr);
if (nameValue != null) {
nameValue.setValue(host);
} else {
nameValue = new NameValue(MADDR, host);
uriParms.add(nameValue);
}
|
public void | setMAddrParam(java.lang.String maddr)Sets the value of the maddr parameter of this SipURI. The
maddr parameter indicates the server address to be contacted for this
user, overriding any address derived from the host field. This is
equivalent to setParameter("maddr", maddr).
if (maddr == null)
throw new NullPointerException("bad maddr");
setParameter(SIPConstants.GENERAL_MADDR, maddr);
|
public void | setMethod(java.lang.String method)Sets the Method.
uriParms.add(METHOD, method);
|
public 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 URI. This is
equivalent to setParameter("method", method).
setParameter(SIPConstants.GENERAL_METHOD, method);
|
public void | setParameter(java.lang.String name, java.lang.String value)Sets the value of the specified parameter. If the parameter already had
a value it will be overwritten. A zero-length String indicates flag
parameter.
if (name.equalsIgnoreCase(SIPConstants.GENERAL_TTL)) {
try {
int ttl = Integer.parseInt(value);
} catch (NumberFormatException ex) {
throw new ParseException("bad parameter " + value, 0);
}
}
name = name.toLowerCase();
// If the value is null the parameter is interpreted
// as a parameter without value.
NameValue nv = new NameValue(name,
(value == null) ? "" : value);
uriParms.delete(name);
uriParms.add(nv);
|
public void | setPort(int p)Sets the port to a given value.
if (authority == null) authority = new Authority();
authority.setPort(p);
|
public void | setQHeader(NameValue nameValue)Sets the query header when provided as a name-value pair.
this.qheaders.set(nameValue);
|
public void | setQheaders(NameValueList parms)Sets the qheaders member.
qheaders = parms;
|
public void | setScheme(java.lang.String scheme)Constructor given the scheme.
The scheme must be either Sip or Sips.
if (compareToIgnoreCase(scheme, SIPConstants.SCHEME_SIP) != 0 &&
compareToIgnoreCase(scheme, SIPConstants.SCHEME_SIPS) != 0)
throw new IllegalArgumentException("bad scheme " + scheme);
this.scheme = scheme.toLowerCase();
|
public void | setSecure(boolean secure)Sets the scheme of this URI to sip or sips depending on whether the
argument is true or false. The default value is false.
if (secure)
scheme = SIPConstants.SCHEME_SIPS;
else
scheme = SIPConstants.SCHEME_SIP;
|
public void | setServer()Sets URI as server.
isServer = true;
|
public void | setShared()Sets URI as shared.
isShared = true;
|
public 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).
if (ttl <= 0)
throw new IllegalArgumentException("Bad ttl value");
if (uriParms != null) {
uriParms.delete(SIPConstants.GENERAL_TTL);
NameValue nv = new NameValue(SIPConstants.GENERAL_TTL,
new Integer(ttl));
uriParms.add(nv);
}
|
public void | setTelephoneSubscriber(TelephoneNumber tel)Sets the telephone subscriber field.
telephoneSubscriber = tel;
|
public 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). Transport parameter constants
are defined in the {@link gov.nist.siplite.ListeningPoint}.
if (transport == null)
throw new NullPointerException("null arg");
if (equalsIgnoreCase(transport, SIPConstants.TRANSPORT_UDP) ||
equalsIgnoreCase(transport, SIPConstants.TRANSPORT_TCP)) {
NameValue nv = new NameValue(SIPConstants.GENERAL_TRANSPORT,
transport.toLowerCase());
uriParms.delete(SIPConstants.GENERAL_TRANSPORT);
uriParms.add(nv);
} else
throw new ParseException("bad transport " + transport, 0);
|
public void | setUriParameter(NameValue nameValue)Sets the parameter as given.
uriParms.set(nameValue);
|
public void | setUser(java.lang.String uname)Sets the user of SipURI. The identifier of a particular resource at
the host being addressed. The user and the user password including the
"at" sign make up the user-info.
if (authority == null) {
authority = new Authority();
}
authority.setUser(uname);
|
public void | setUserParam(java.lang.String usertype)Sets the value of the user parameter. The user URI parameter exists to
distinguish telephone numbers from user names that happen to look like
telephone numbers. This is equivalent to setParameter("user", user).
uriParms.delete(USER);
uriParms.add(USER, usertype);
|
public void | setUserPassword(java.lang.String password)Sets the user password.
if (authority == null) {
authority = new Authority();
}
authority.setPassword(password);
|
public java.lang.String | toString()Returns a string representation. return this.encode();
|