private URL getArchiveURL() throws MalformedURLException { String jarLoc= fArchiveField.getText(); String innerPath= fArchivePathField.getText().trim(); StringBuffer buf= new StringBuffer(); buf.append("jar:"); //$NON-NLS-1$ if (fWorkspaceRadio.isSelected()) { IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot(); IResource res= root.findMember(new Path(jarLoc)); if (res != null) { buf.append("platform:/resource").append(encodeExclamationMarks(res.getFullPath().toString())); //$NON-NLS-1$ } } else { buf.append(encodeExclamationMarks(new File(jarLoc).toURL().toExternalForm())); } buf.append('!'); if (innerPath.length() > 0) { if (innerPath.charAt(0) != '/') { buf.append('/'); } buf.append(innerPath); } else { buf.append('/'); } return new URL(buf.toString()); }
private URL getArchiveURL() throws MalformedURLException { String jarLoc= fArchiveField.getText(); String innerPath= fArchivePathField.getText().trim(); try { URI baseUri; if (fWorkspaceRadio.isSelected()) { IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot(); IResource res= root.findMember(new Path(jarLoc)); if (res != null) { // 3-arg constructor of URI is broken, see http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7177117 baseUri= new URI("platform", null, "/resource" + res.getFullPath().toString(), null, null); //$NON-NLS-1$ //$NON-NLS-2$ } else { throw new URISyntaxException(jarLoc, ""); //$NON-NLS-1$ } } else { baseUri= new File(jarLoc).toURI(); } if (innerPath.length() == 0 || innerPath.charAt(0) != '/') { innerPath= '/' + innerPath; } String encodedInnerPath= new URI(null, null, innerPath, null, null).getRawSchemeSpecificPart(); return new URI("jar:" + encodeExclamationMarks(baseUri.toString()) + '!' + encodeExclamationMarks(encodedInnerPath)).toURL(); //$NON-NLS-1$ } catch (URISyntaxException e) { throw new MalformedURLException(e.getMessage()); } }
private URL getArchiveURL() throws MalformedURLException { String jarLoc= fArchiveField.getText(); String innerPath= fArchivePathField.getText().trim(); try { URI baseUri; if (fWorkspaceRadio.isSelected()) { IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot(); IResource res= root.findMember(new Path(jarLoc)); if (res != null) { // 3-arg constructor of URI is broken, see http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7177117 baseUri= new URI("platform", null, "/resource" + res.getFullPath().toString(), null, null); //$NON-NLS-1$ //$NON-NLS-2$ } else { throw new URISyntaxException(jarLoc, ""); //$NON-NLS-1$ } } else { baseUri= new File(jarLoc).toURI(); } if (innerPath.length() == 0 || innerPath.charAt(0) != '/') { innerPath= '/' + innerPath; } String encodedInnerPath= new URI(null, null, innerPath, null, null).getRawSchemeSpecificPart(); return new URI("jar:" + encodeExclamationMarks(baseUri.toString()) + '!' + encodeExclamationMarks(encodedInnerPath)).toURL(); //$NON-NLS-1$ } catch (URISyntaxException e) { throw new MalformedURLException(e.getMessage()); } }