MCPcopy Create free account
hub / github.com/davidgiven/luje / compareTo

Method compareTo

lib/java/net/URI.java:851–953  ·  view source on GitHub ↗

Compares this URI with the given argument uri. This method will return a negative value if this URI instance is less than the given argument and a positive value if this URI instance is greater than the given argument. The return value 0 indicates that the two instances represent the

(URI uri)

Source from the content-addressed store, hash-verified

849 * @return the value representing the order of the two instances.
850 */
851 public int compareTo(URI uri) {
852 int ret = 0;
853
854 // compare schemes
855 if (scheme == null && uri.scheme != null) {
856 return -1;
857 } else if (scheme != null && uri.scheme == null) {
858 return 1;
859 } else if (scheme != null && uri.scheme != null) {
860 ret = scheme.compareToIgnoreCase(uri.scheme);
861 if (ret != 0) {
862 return ret;
863 }
864 }
865
866 // compare opacities
867 if (!opaque && uri.opaque) {
868 return -1;
869 } else if (opaque && !uri.opaque) {
870 return 1;
871 } else if (opaque && uri.opaque) {
872 ret = schemespecificpart.compareTo(uri.schemespecificpart);
873 if (ret != 0) {
874 return ret;
875 }
876 } else {
877
878 // otherwise both must be hierarchical
879
880 // compare authorities
881 if (authority != null && uri.authority == null) {
882 return 1;
883 } else if (authority == null && uri.authority != null) {
884 return -1;
885 } else if (authority != null && uri.authority != null) {
886 if (host != null && uri.host != null) {
887 // both are server based, so compare userinfo, host, port
888 if (userinfo != null && uri.userinfo == null) {
889 return 1;
890 } else if (userinfo == null && uri.userinfo != null) {
891 return -1;
892 } else if (userinfo != null && uri.userinfo != null) {
893 ret = userinfo.compareTo(uri.userinfo);
894 if (ret != 0) {
895 return ret;
896 }
897 }
898
899 // userinfo's are the same, compare hostname
900 ret = host.compareToIgnoreCase(uri.host);
901 if (ret != 0) {
902 return ret;
903 }
904
905 // compare port
906 if (port != uri.port) {
907 return port - uri.port;
908 }

Callers

nothing calls this directly

Calls 2

compareToIgnoreCaseMethod · 0.80
compareToMethod · 0.65

Tested by

no test coverage detected