MCPcopy Create free account
hub / github.com/codenameone/CodenameOne / relativize

Method relativize

Ports/CLDC11/src/java/net/URI.java:699–724  ·  view source on GitHub ↗
(URI uri)

Source from the content-addressed store, hash-verified

697 ///
698 /// - [http://docs.oracle.com/javase/6/docs/api/java/net/URI.html#relativize%28java.net.URI%29](http://docs.oracle.com/javase/6/docs/api/java/net/URI.html#relativize%28java.net.URI%29)
699 public URI relativize(URI uri) {
700 if (isOpaque() || uri.isOpaque()) {
701 return uri;
702 }
703 if (getScheme() == null || uri.getScheme() == null || getScheme().equals(uri.getScheme()) == false) {
704 return uri;
705 }
706 String thisAuthority = null;
707 String thatAuthority = null;
708 String thisPath = null;
709 String thatPath = null;
710 if ((thisAuthority = getAuthority()) == null || (thatAuthority = uri.getAuthority()) == null
711 || thisAuthority.equals(thatAuthority) == false) {
712 return uri;
713 }
714 if ((thisPath = getPath()) == null || (thatPath = uri.getPath()) == null
715 || thatPath.startsWith(thisPath + PATH_SEPARATOR) == false) {
716 return uri;
717 }
718 try {
719 return new URI(null, null, thatPath.substring(thisPath.length() + 1), uri.getQuery(), uri.getFragment());
720 } catch (URISyntaxException e) {
721 // Since the two URIs are pre-validated, we should never get here.
722 throw new IllegalArgumentException(e.getMessage());
723 }
724 }
725
726 /// Resolve a relative URI by merging it with this URI.
727 ///

Callers

nothing calls this directly

Calls 12

isOpaqueMethod · 0.95
getSchemeMethod · 0.95
getAuthorityMethod · 0.95
equalsMethod · 0.95
getPathMethod · 0.95
startsWithMethod · 0.95
substringMethod · 0.95
lengthMethod · 0.95
equalsMethod · 0.65
getQueryMethod · 0.65
getMessageMethod · 0.65
getFragmentMethod · 0.45

Tested by

no test coverage detected