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

Method resolve

vm/JavaAPI/src/java/net/URI.java:820–856  ·  view source on GitHub ↗

Resolve a relative URI by merging it with this URI. @param uri a URI to resolve against this URI. @return a new URI created by merging given URI with this URI. @see http://docs.oracle.com/javase/6/docs/ap

(URI uri)

Source from the content-addressed store, hash-verified

818 * @see <a href="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</a>
819 */
820 public URI resolve(URI uri) {
821 if (isOpaque() || uri.isAbsolute()) {
822 return uri;
823 }
824 String thatPath = uri.getPath();
825 String thatQuery = uri.getQuery();
826 String thatAuthority = uri.getAuthority();
827 String thatFragment = uri.getFragment();
828 try {
829 // if standalone fragment was passed.
830 if (thatFragment != null
831 && (uri.getScheme() == null && thatPath == null && thatQuery == null && thatAuthority == null)) {
832 return new URI(getScheme(), getAuthority(), getPath(), getQuery(), thatFragment);
833 }
834 if (thatAuthority != null) {
835 return new URI(getScheme(), thatAuthority, thatPath, thatQuery, thatFragment);
836 }
837 // an absolute path was passed
838 if (thatPath != null && thatPath.charAt(0) == PATH_SEPARATOR) {
839 return new URI(getScheme(), getAuthority(), thatPath, thatQuery, thatFragment);
840 }
841 // a relative path was passed
842 String thisPath = getPath();
843 if (thisPath != null) {
844 int index = thisPath.lastIndexOf(PATH_SEPARATOR);
845 if (index != -1) {
846 thisPath = thisPath.substring(index);
847 }
848 }
849 thisPath += PATH_SEPARATOR + thatPath;
850 return new URI(getScheme(), getAuthority(), thisPath, thatQuery, thatFragment).normalize();
851 } catch (URISyntaxException use) {
852 // since both uri's are already validated, should never get here
853 throw new IllegalArgumentException(use.getMessage());
854 }
855
856 }
857
858 /**
859 * Normalize a URI by removing any "./" segments, and "path/../" segments.

Callers 15

split_courses.pyFile · 0.45
normalizeJdkHomeMethod · 0.45
detectJdkVersionMethod · 0.45
compileMethod · 0.45
compileAndRunMethod · 0.45
copyDirectoryMethod · 0.45
translateBuildAndRunMethod · 0.45
findPathMethod · 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 15

normalizeJdkHomeMethod · 0.36
detectJdkVersionMethod · 0.36
compileMethod · 0.36
compileAndRunMethod · 0.36
copyDirectoryMethod · 0.36
translateBuildAndRunMethod · 0.36
findPathMethod · 0.36
unzipMethod · 0.36
writeReportMethod · 0.36
runJavaMainMethod · 0.36