URI.CompareTo(URI) Method

Definition

Compares this URI to another object, which must be a URI.

[Android.Runtime.Register("compareTo", "(Ljava/net/URI;)I", "")]
public int CompareTo (Java.Net.URI? that);
[<Android.Runtime.Register("compareTo", "(Ljava/net/URI;)I", "")>]
member this.CompareTo : Java.Net.URI -> int

Parameters

that
URI

The object to which this URI is to be compared

Returns

A negative integer, zero, or a positive integer as this URI is less than, equal to, or greater than the given URI

Attributes

Remarks

Compares this URI to another object, which must be a URI.

When comparing corresponding components of two URIs, if one component is undefined but the other is defined then the first is considered to be less than the second. Unless otherwise noted, string components are ordered according to their natural, case-sensitive ordering as defined by the java.lang.String#compareTo(Object) String.compareTo method. String components that are subject to encoding are compared by comparing their raw forms rather than their encoded forms.

The ordering of URIs is defined as follows:

<ul>

<li>

Two URIs with different schemes are ordered according the ordering of their schemes, without regard to case.

</li>

<li>

A hierarchical URI is considered to be less than an opaque URI with an identical scheme.

</li>

<li>

Two opaque URIs with identical schemes are ordered according to the ordering of their scheme-specific parts.

</li>

<li>

Two opaque URIs with identical schemes and scheme-specific parts are ordered according to the ordering of their fragments.

</li>

<li>

Two hierarchical URIs with identical schemes are ordered according to the ordering of their authority components:

<ul>

<li>

If both authority components are server-based then the URIs are ordered according to their user-information components; if these components are identical then the URIs are ordered according to the ordering of their hosts, without regard to case; if the hosts are identical then the URIs are ordered according to the ordering of their ports.

</li>

<li>

If one or both authority components are registry-based then the URIs are ordered according to the ordering of their authority components.

</li>

</ul></li>

<li>

Finally, two hierarchical URIs with identical schemes and authority components are ordered according to the ordering of their paths; if their paths are identical then they are ordered according to the ordering of their queries; if the queries are identical then they are ordered according to the order of their fragments.

</li>

</ul>

This method satisfies the general contract of the java.lang.Comparable#compareTo(Object) Comparable.compareTo method.

Java documentation for java.net.URI.compareTo(java.net.URI).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to