public UriResolver(final String baseUriStr, final String uriStr, final Class calling) throws IOException { this.calling = calling != null ? calling : getClass(); if (uriStr.startsWith("classpath:")) { tryClasspath(uriStr); } else if (baseUriStr != null && baseUriStr.startsWith("jar:")) { tryJar(baseUriStr, uriStr); } else if (uriStr.startsWith("jar:")) { tryJar(uriStr); } else { tryFileSystem(baseUriStr, uriStr); } }
private void tryJar(final String baseStr, final String uriStr) throws IOException { final int i = baseStr.indexOf('!'); if (i == -1) { tryFileSystem(baseStr, uriStr); } final String jarBase = baseStr.substring(0, i + 1); final String jarEntry = baseStr.substring(i + 1); final URI u = URLs.uri(jarEntry).resolve(uriStr); tryJar(jarBase + u.toString()); if (is != null) { if (u.isAbsolute()) { url = u.toURL(); } return; } tryFileSystem("", uriStr); }
final File file = new File(importUrl.toURI()); if (file.exists()) { final UriResolver resolver = new UriResolver(parent.toString(), importLocation); inputSource = new InputSource(resolver.getInputStream()); } else { final UriResolver resolver = new UriResolver(importLocation); if (resolver.isResolved()) { inputSource = new InputSource(resolver.getInputStream());
private void tryClasspath(String uriStr) throws IOException { if (uriStr.startsWith("classpath:")) { uriStr = uriStr.substring(10); } url = getResource(uriStr, calling); if (url == null) { tryRemote(uriStr); } else { try { uri = url.toURI(); } catch (URISyntaxException e) { // processing the jar:file:/ type value String urlStr = url.toString(); if (urlStr.startsWith("jar:")) { int pos = urlStr.indexOf('!'); if (pos != -1) { try { uri = new URI("classpath:" + urlStr.substring(pos + 1)); } catch (URISyntaxException ue) { // ignore } } } } is = url.openStream(); } }
private void tryJar(String uriStr) throws IOException { int i = uriStr.indexOf('!'); if (i == -1) { return; } url = new URL(uriStr); try { is = url.openStream(); try { uri = url.toURI(); } catch (URISyntaxException ex) { // ignore } } catch (IOException e) { uriStr = uriStr.substring(i + 1); tryClasspath(uriStr); } }
return getResource('/' + resourceName, callingClass);
public InputSource getImportInputSource(final String parent, final String importLocation) { this.baseUri = parent; final URL parentUrl; try { parentUrl = new URL(parent); final URL importUrl = new URL(parentUrl, importLocation); if (importUrl != null && !importUrl.getProtocol().startsWith("file")) { final URLConnection con = importUrl.openConnection(); con.setUseCaches(false); inputSource = new InputSource(con.getInputStream()); } else { final File file = new File(importUrl.toURI()); if (file.exists()) { final UriResolver resolver = new UriResolver(parent.toString(), importLocation); inputSource = new InputSource(resolver.getInputStream()); } else { final UriResolver resolver = new UriResolver(importLocation); if (resolver.isResolved()) { inputSource = new InputSource(resolver.getInputStream()); } } } importedUri = importUrl.toURI().toString(); } catch (final URISyntaxException | IOException e) { // no-op } return inputSource; }
private void tryJar(final String baseStr, final String uriStr) throws IOException { final int i = baseStr.indexOf('!'); if (i == -1) { tryFileSystem(baseStr, uriStr); } final String jarBase = baseStr.substring(0, i + 1); final String jarEntry = baseStr.substring(i + 1); final URI u = URLs.uri(jarEntry).resolve(uriStr); tryJar(jarBase + u.toString()); if (is != null) { if (u.isAbsolute()) { url = u.toURL(); } return; } tryFileSystem("", uriStr); }
private void tryClasspath(String uriStr) throws IOException { if (uriStr.startsWith("classpath:")) { uriStr = uriStr.substring(10); } url = getResource(uriStr, calling); if (url == null) { tryRemote(uriStr); } else { try { uri = url.toURI(); } catch (final URISyntaxException e) { // processing the jar:file:/ type value final String urlStr = url.toString(); if (urlStr.startsWith("jar:")) { final int pos = urlStr.indexOf('!'); if (pos != -1) { uri = URLs.uri("classpath:" + urlStr.substring(pos + 1)); } } } is = IO.read(url); } }
private void tryJar(String uriStr) throws IOException { final int i = uriStr.indexOf('!'); if (i == -1) { return; } url = new URL(uriStr); try { is = IO.read(url); try { uri = url.toURI(); } catch (final URISyntaxException ex) { // ignore } } catch (final IOException e) { uriStr = uriStr.substring(i + 1); tryClasspath(uriStr); } }
return getResource('/' + resourceName, callingClass);
public UriResolver(String baseUriStr, String uriStr, Class calling) throws IOException { this.calling = (calling != null) ? calling : getClass(); if (uriStr.startsWith("classpath:")) { tryClasspath(uriStr); } else if (baseUriStr != null && baseUriStr.startsWith("jar:")) { tryJar(baseUriStr, uriStr); } else if (uriStr.startsWith("jar:")) { tryJar(uriStr); } else { tryFileSystem(baseUriStr, uriStr); } }
File file = new File(importUrl.toURI()); if (file.exists()) { UriResolver resolver = new UriResolver(parent.toString(), importLocation); inputSource = new InputSource(resolver.getInputStream()); } else { UriResolver resolver = new UriResolver(importLocation); if (resolver.isResolved()) { inputSource = new InputSource(resolver.getInputStream());
private void tryJar(String baseStr, String uriStr) throws IOException { int i = baseStr.indexOf('!'); if (i == -1) { tryFileSystem(baseStr, uriStr); } String jarBase = baseStr.substring(0, i + 1); String jarEntry = baseStr.substring(i + 1); try { URI u = new URI(jarEntry).resolve(uriStr); tryJar(jarBase + u.toString()); if (is != null) { if (u.isAbsolute()) { url = u.toURL(); } return; } } catch (URISyntaxException e) { // do nothing } tryFileSystem("", uriStr); }
private void tryClasspath(String uriStr) throws IOException { if (uriStr.startsWith("classpath:")) { uriStr = uriStr.substring(10); } url = getResource(uriStr, calling); if (url == null) { tryRemote(uriStr); } else { try { uri = url.toURI(); } catch (final URISyntaxException e) { // processing the jar:file:/ type value final String urlStr = url.toString(); if (urlStr.startsWith("jar:")) { final int pos = urlStr.indexOf('!'); if (pos != -1) { uri = URLs.uri("classpath:" + urlStr.substring(pos + 1)); } } } is = IO.read(url); } }
private void tryJar(String uriStr) throws IOException { final int i = uriStr.indexOf('!'); if (i == -1) { return; } url = new URL(uriStr); try { is = IO.read(url); try { uri = url.toURI(); } catch (final URISyntaxException ex) { // ignore } } catch (final IOException e) { uriStr = uriStr.substring(i + 1); tryClasspath(uriStr); } }
return getResource('/' + resourceName, callingClass);
public UriResolver(final String baseUriStr, final String uriStr, final Class calling) throws IOException { this.calling = calling != null ? calling : getClass(); if (uriStr.startsWith("classpath:")) { tryClasspath(uriStr); } else if (baseUriStr != null && baseUriStr.startsWith("jar:")) { tryJar(baseUriStr, uriStr); } else if (uriStr.startsWith("jar:")) { tryJar(uriStr); } else { tryFileSystem(baseUriStr, uriStr); } }
uri = base; } else { tryClasspath(base.toString().startsWith("file:") ? base.toString().substring(5) : base.toString()); tryClasspath(base.toString().startsWith("file:") ? base.toString().substring(5) : base.toString()); tryClasspath(uriStr);
public void resolve(final String baseUriStr, final String uriStr, final Class callingCls) throws IOException { this.calling = callingCls != null ? callingCls : getClass(); this.file = null; this.uri = null; this.is = null; if (uriStr.startsWith("classpath:")) { tryClasspath(uriStr); } else if (baseUriStr != null && baseUriStr.startsWith("jar:")) { tryJar(baseUriStr, uriStr); } else if (uriStr.startsWith("jar:")) { tryJar(uriStr); } else { tryFileSystem(baseUriStr, uriStr); } }