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

Method resolve

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

Source from the content-addressed store, hash-verified

737 ///
738 /// - [http://docs.oracle.com/javase/6/docs/api/java/net/URI.html#resolve%28java.net.URI%29](http://docs.oracle.com/javase/6/docs/api/java/net/URI.html#resolve%28java.net.URI%29)
739 public URI resolve(URI uri) {
740 if (isOpaque() || uri.isAbsolute()) {
741 return uri;
742 }
743 String thatPath = uri.getPath();
744 String thatQuery = uri.getQuery();
745 String thatAuthority = uri.getAuthority();
746 String thatFragment = uri.getFragment();
747 try {
748 // if standalone fragment was passed.
749 if (thatFragment != null
750 && (uri.getScheme() == null && thatPath == null && thatQuery == null && thatAuthority == null)) {
751 return new URI(getScheme(), getAuthority(), getPath(), getQuery(), thatFragment);
752 }
753 if (thatAuthority != null) {
754 return new URI(getScheme(), thatAuthority, thatPath, thatQuery, thatFragment);
755 }
756 // an absolute path was passed
757 if (thatPath != null && thatPath.charAt(0) == PATH_SEPARATOR) {
758 return new URI(getScheme(), getAuthority(), thatPath, thatQuery, thatFragment);
759 }
760 // a relative path was passed
761 String thisPath = getPath();
762 if (thisPath != null) {
763 int index = thisPath.lastIndexOf(PATH_SEPARATOR);
764 if (index != -1) {
765 thisPath = thisPath.substring(index);
766 }
767 }
768 thisPath += PATH_SEPARATOR + thatPath;
769 return new URI(getScheme(), getAuthority(), thisPath, thatQuery, thatFragment).normalize();
770 } catch (URISyntaxException use) {
771 // since both uri's are already validated, should never get here
772 throw new IllegalArgumentException(use.getMessage());
773 }
774
775 }
776
777 /// Normalize a URI by removing any "./" segments, and "path/../" segments.
778 ///

Callers 1

iter_filesFunction · 0.45

Calls 13

isOpaqueMethod · 0.95
getPathMethod · 0.95
getAuthorityMethod · 0.95
getSchemeMethod · 0.95
getQueryMethod · 0.95
charAtMethod · 0.95
lastIndexOfMethod · 0.95
substringMethod · 0.95
getQueryMethod · 0.65
getMessageMethod · 0.65
isAbsoluteMethod · 0.45
getFragmentMethod · 0.45

Tested by

no test coverage detected