Java Code Examples for java.net.JarURLConnection#getEntryName()
The following examples show how to use
java.net.JarURLConnection#getEntryName() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PackageInternalsFinder.java From SkaETL with Apache License 2.0 | 6 votes |
private List<JavaFileObject> processJar(URL packageFolderURL) { List<JavaFileObject> result = new ArrayList<>(); try { String jarUri = packageFolderURL.toExternalForm().substring(0, packageFolderURL.toExternalForm().lastIndexOf("!/")); JarURLConnection jarConn = (JarURLConnection) packageFolderURL.openConnection(); String rootEntryName = jarConn.getEntryName(); int rootEnd = rootEntryName.length() + 1; Enumeration<JarEntry> entryEnum = jarConn.getJarFile().entries(); while (entryEnum.hasMoreElements()) { JarEntry jarEntry = entryEnum.nextElement(); String name = jarEntry.getName(); if (name.startsWith(rootEntryName) && name.indexOf('/', rootEnd) == -1 && name.endsWith(CLASS_FILE_EXTENSION)) { URI uri = URI.create(jarUri + "!/" + name); String binaryName = name.replaceAll("/", "."); binaryName = binaryName.replaceAll(CLASS_FILE_EXTENSION + "$", ""); result.add(new CustomJavaFileObject(binaryName, uri)); } } } catch (Exception e) { throw new RuntimeException("Wasn't able to open " + packageFolderURL + " as a jar file", e); } return result; }
Example 2
Source File: PackageInternalsFinder.java From arthas with Apache License 2.0 | 6 votes |
private List<JavaFileObject> processJar(URL packageFolderURL) { List<JavaFileObject> result = new ArrayList<JavaFileObject>(); try { String jarUri = packageFolderURL.toExternalForm().substring(0, packageFolderURL.toExternalForm().lastIndexOf("!/")); JarURLConnection jarConn = (JarURLConnection) packageFolderURL.openConnection(); String rootEntryName = jarConn.getEntryName(); int rootEnd = rootEntryName.length() + 1; Enumeration<JarEntry> entryEnum = jarConn.getJarFile().entries(); while (entryEnum.hasMoreElements()) { JarEntry jarEntry = entryEnum.nextElement(); String name = jarEntry.getName(); if (name.startsWith(rootEntryName) && name.indexOf('/', rootEnd) == -1 && name.endsWith(CLASS_FILE_EXTENSION)) { URI uri = URI.create(jarUri + "!/" + name); String binaryName = name.replaceAll("/", "."); binaryName = binaryName.replaceAll(CLASS_FILE_EXTENSION + "$", ""); result.add(new CustomJavaFileObject(binaryName, uri)); } } } catch (Exception e) { throw new RuntimeException("Wasn't able to open " + packageFolderURL + " as a jar file", e); } return result; }
Example 3
Source File: SHACLManifestTestSuiteFactory.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
private String getManifestFile(boolean officialWorkingGroupTests, boolean useRemote) { if (useRemote) { return "https://raw.githubusercontent.com/w3c/data-shapes/gh-pages/data-shapes-test-suite/tests/manifest.ttl"; } URL url = SHACLManifestTestSuiteFactory.class.getResource("/data-shapes-test-suite/tests/manifest.ttl"); if ("jar".equals(url.getProtocol())) { // Extract manifest files to a temporary directory try { tmpDir = FileUtil.createTempDir("data-shapes-test-evaluation"); JarURLConnection con = (JarURLConnection) url.openConnection(); JarFile jar = con.getJarFile(); ZipUtil.extract(jar, tmpDir); File localFile = new File(tmpDir, con.getEntryName()); return localFile.toURI().toURL().toString(); } catch (IOException e) { throw new AssertionError(e); } } else { return url.toString(); } }
Example 4
Source File: JavaCodeScriptEngine.java From chaosblade-exec-jvm with Apache License 2.0 | 5 votes |
private List<JavaFileObject> processJar(URL packageFolderURL) { List<JavaFileObject> result = new ArrayList<JavaFileObject>(); try { String externalURL = packageFolderURL.toExternalForm(); int laste = externalURL.lastIndexOf('!'); String jarUri = laste <= 0 ? externalURL : externalURL.substring(0, laste); JarURLConnection jarConn = (JarURLConnection)packageFolderURL.openConnection(); String rootEntryName = jarConn.getEntryName(); int rootEnd = rootEntryName.length() + 1; Enumeration<JarEntry> entryEnum = jarConn.getJarFile().entries(); while (entryEnum.hasMoreElements()) { JarEntry jarEntry = entryEnum.nextElement(); String name = jarEntry.getName(); if (name.startsWith(rootEntryName) && name.indexOf('/', rootEnd) == -1 && name.endsWith(CLASS_FILE_EXTENSION)) { URI uri = URI.create(jarUri + "!/" + name); String binaryName = name.replace('/', '.'); binaryName = binaryName.replaceAll(CLASS_FILE_EXTENSION + "$", ""); result.add(new InputClassJavaFileObject(binaryName, uri)); } } } catch (Exception e) { throw new RuntimeException("Fail to open " + packageFolderURL + " as a jar file", e); } return result; }
Example 5
Source File: NativeJavaCompiler.java From kogito-runtimes with Apache License 2.0 | 5 votes |
private List<JavaFileObject> processJar(URL packageFolderURL) throws IOException { String jarUri = packageFolderURL.toExternalForm(); int separator = jarUri.indexOf('!'); if (separator >= 0) { jarUri = jarUri.substring(0, separator); } URLConnection urlConnection = packageFolderURL.openConnection(); if (!(urlConnection instanceof JarURLConnection)) { return null; } JarURLConnection jarConn = (JarURLConnection) urlConnection; String rootEntryName = jarConn.getEntryName(); int rootEnd = rootEntryName.length()+1; List<JavaFileObject> result = null; Enumeration<JarEntry> entryEnum = jarConn.getJarFile().entries(); while (entryEnum.hasMoreElements()) { String name = entryEnum.nextElement().getName(); if (name.startsWith(rootEntryName) && name.indexOf('/', rootEnd) == -1 && name.endsWith(".class")) { URI uri = URI.create(jarUri + "!/" + name); String binaryName = name.substring(0, name.length()-6).replace('/', '.'); if (result == null) { result = new ArrayList<JavaFileObject>(); } result.add(new CustomJavaFileObject(binaryName, uri)); } } return result; }
Example 6
Source File: SPARQL11ManifestTest.java From database with GNU General Public License v2.0 | 5 votes |
private static String getManifestFile(boolean officialWorkingGroupTests, boolean useRemote) { String manifestFile = null; if (useRemote) { manifestFile = "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/manifest-all.ttl"; } else { URL url = null; if (officialWorkingGroupTests) { url = SPARQL11ManifestTest.class.getResource("/testcases-sparql-1.1-w3c/manifest-all.ttl"); } else { url = SPARQL11ManifestTest.class.getResource("/testcases-sparql-1.1/manifest-evaluation.ttl"); } if ("jar".equals(url.getProtocol())) { // Extract manifest files to a temporary directory try { tmpDir = FileUtil.createTempDir("sparql11-test-evaluation"); JarURLConnection con = (JarURLConnection)url.openConnection(); JarFile jar = con.getJarFile(); ZipUtil.extract(jar, tmpDir); File localFile = new File(tmpDir, con.getEntryName()); manifestFile = localFile.toURI().toURL().toString(); } catch (IOException e) { throw new AssertionError(e); } } else { manifestFile = url.toString(); } } return manifestFile; }
Example 7
Source File: PackageInternalsFinder.java From light with Apache License 2.0 | 5 votes |
private List<JavaFileObject> processJar(URL packageFolderURL) { List<JavaFileObject> result = new ArrayList<JavaFileObject>(); try { String jarUri = packageFolderURL.toExternalForm().split("!")[0]; JarURLConnection jarConn = (JarURLConnection) packageFolderURL .openConnection(); String rootEntryName = jarConn.getEntryName(); int rootEnd = rootEntryName.length() + 1; Enumeration<JarEntry> entryEnum = jarConn.getJarFile().entries(); while (entryEnum.hasMoreElements()) { JarEntry jarEntry = entryEnum.nextElement(); String name = jarEntry.getName(); if (name.startsWith(rootEntryName) && name.indexOf('/', rootEnd) == -1 && name.endsWith(CLASS_FILE_EXTENSION)) { URI uri = URI.create(jarUri + "!/" + name); String binaryName = name.replaceAll("/", "."); binaryName = binaryName.replaceAll(CLASS_FILE_EXTENSION + "$", ""); result.add(new CustomJavaFileObject(binaryName, uri)); } } } catch (Exception e) { throw new RuntimeException("Wasn't able to open " + packageFolderURL + " as a jar file", e); } return result; }
Example 8
Source File: HttpResponseUtils.java From enkan with Eclipse Public License 1.0 | 4 votes |
public static boolean isJarDirectory(JarURLConnection conn) throws IOException { JarFile jarFile = conn.getJarFile(); String entryName = conn.getEntryName(); ZipEntry dirEntry = jarFile.getEntry(addEndingSlash(entryName)); return dirEntry != null && dirEntry.isDirectory(); }