/** * Instantiates a new archiv entry. * * @param url * the url */ public ArchivEntry(final URL url) { this(Converter.toURI(url)); }
/** * If a URL contains illegal characters for an URI (like blanks) this * should be automatically converted (e.g. to "%20") * * @param url the URL to be converted * @return the given URL as URI */ public static URI toURI(final URL url) { try { return url.toURI(); } catch (URISyntaxException e) { return toURI(url.toExternalForm()); } }
/** * If a URL contains illegal characters for an URI (like blanks) this should * be automatically converted (e.g. to "%20") * * @param url * the URL to be converted * @return the given URL as URI */ public static URI toURI(final URL url) { try { return url.toURI(); } catch (URISyntaxException ex) { LOG.trace("Cannot convert {} to URI:", url, ex); return toURI(url.toExternalForm()); } }
/** * Instantiates a new archiv entry. * * @param url the url */ public ArchivEntry(URL url) { this.uri = Converter.toURI(url); initArchiv(); }
private static String[] getAsClasspath(final URL[] repositoryURLs) { String[] cp = new String[repositoryURLs.length]; for (int i = 0; i < cp.length; i++) { cp[i] = Converter.toAbsolutePath(Converter.toURI(repositoryURLs[i])); } return cp; }
/** * Gets the resourcepathes which belongs to the given collection of * resources. * * @param resources the resources * @return the resourcepath set * @since 1.6.3 */ public SortedSet<URI> getResourcepathSet(Collection<String> resources) { SortedSet<URI> rscPath = new TreeSet<>(); for (String rsc : resources) { Enumeration<URL> urls = this.getResources(rsc); while (urls.hasMoreElements()) { URL url = urls.nextElement(); URI path = Converter.toURI(url); rscPath.add(ClasspathHelper.getParent(path, rsc)); } } return rscPath; }
private String[] getTomcatClasspath() { try { Field field = ReflectionHelper.getField(classLoader.getClass(), "repositoryURLs"); URL[] repositoryURLs = (URL[]) field.get(classLoader); String[] cp = new String[repositoryURLs.length]; for (int i = 0; i < cp.length; i++) { cp[i] = Converter.toAbsolutePath(Converter.toURI(repositoryURLs[i])); } return cp; } catch (Exception e) { log.warn("can't access field 'repositoryURLs'", e); return getClasspath("java.class.path"); } }
return Converter.toURI(url);
return Converter.toURI(url);
/** * Gets the classpath set. * * @param classes the classes * * @return the classpath set */ private SortedSet<URI> getClasspathSet(final List<Class<?>> classes) { SortedSet<URI> classpath = new TreeSet<URI>(); for (Class<?> cl : classes) { String resource = Converter.toResource(cl); Enumeration<URL> resources = this.getResources(resource); while (resources.hasMoreElements()) { URL url = resources.nextElement(); URI path = Converter.toURI(url); classpath.add(ClasspathHelper.getParent(path, resource)); } } return classpath; }