(URI uri)
| 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 | /// |
nothing calls this directly
no test coverage detected