@Test public void testStringGetter() throws IOException, LibraryNotFoundException, ResourceNotFoundException { LoadedJarLibrary testee = LoadedJarLibrary .createFromJar("export/jars/i5.las2peer.classLoaders.testPackage1-1.1.jar"); String test = testee.getResourceAsString("i5/las2peer/classLoaders/testPackage1/test.properties"); test = test.replace("\n", "").replace("\r", ""); assertEquals("attribute=otherValueinteger=987", test); }
public static LoadedJarLibrary createFromJar(String filename) throws IllegalArgumentException, IOException { JarFile jfFile = new JarFile(filename); String sName = jfFile.getManifest().getMainAttributes() .getValue(LibraryIdentifier.MANIFEST_LIBRARY_NAME_ATTRIBUTE); String sVersion = jfFile.getManifest().getMainAttributes() .getValue(LibraryIdentifier.MANIFEST_LIBRARY_VERSION_ATTRIBUTE); if (sName == null || sVersion == null) { LibraryIdentifier tmpId = LibraryIdentifier.fromFilename(filename); if (sName == null) { sName = tmpId.getName(); } if (sVersion == null) { sVersion = tmpId.getVersion().toString(); } } jfFile.close(); return new LoadedJarLibrary(filename, new LibraryIdentifier(sName, sVersion)); }
LoadedJarLibrary extends LoadedLibrary { public static LoadedJarLibrary createFromJar(String filename) throws IllegalArgumentException, IOException { JarFile jfFile = new JarFile(filename); String sName = jfFile.getManifest().getMainAttributes() .getValue(LibraryIdentifier.MANIFEST_LIBRARY_NAME_ATTRIBUTE); String sVersion = jfFile.getManifest().getMainAttributes() .getValue(LibraryIdentifier.MANIFEST_LIBRARY_VERSION_ATTRIBUTE); if (sName == null || sVersion == null) { LibraryIdentifier tmpId = LibraryIdentifier.fromFilename(filename); if (sName == null) { sName = tmpId.getName(); } if (sVersion == null) { sVersion = tmpId.getVersion().toString(); } } jfFile.close(); return new LoadedJarLibrary(filename, new LibraryIdentifier(sName, sVersion)); } }
LoadedJarLibrary extends LoadedLibrary { public static LoadedJarLibrary createFromJar(String filename) throws IllegalArgumentException, IOException { JarFile jfFile = new JarFile(filename); String sName = jfFile.getManifest().getMainAttributes() .getValue(LibraryIdentifier.MANIFEST_LIBRARY_NAME_ATTRIBUTE); String sVersion = jfFile.getManifest().getMainAttributes() .getValue(LibraryIdentifier.MANIFEST_LIBRARY_VERSION_ATTRIBUTE); if (sName == null || sVersion == null) { LibraryIdentifier tmpId = LibraryIdentifier.fromFilename(filename); if (sName == null) { sName = tmpId.getName(); } if (sVersion == null) { sVersion = tmpId.getVersion().toString(); } } jfFile.close(); return new LoadedJarLibrary(filename, new LibraryIdentifier(sName, sVersion)); } LoadedJarLibrary(String filename, LibraryIdentifier ident); }
LoadedJarLibrary extends LoadedLibrary { public static LoadedJarLibrary createFromJar(String filename) throws IllegalArgumentException, IOException { JarFile jfFile = new JarFile(filename); String sName = jfFile.getManifest().getMainAttributes() .getValue(LibraryIdentifier.MANIFEST_LIBRARY_NAME_ATTRIBUTE); String sVersion = jfFile.getManifest().getMainAttributes() .getValue(LibraryIdentifier.MANIFEST_LIBRARY_VERSION_ATTRIBUTE); if (sName == null || sVersion == null) { LibraryIdentifier tmpId = LibraryIdentifier.fromFilename(filename); if (sName == null) { sName = tmpId.getName(); } if (sVersion == null) { sVersion = tmpId.getVersion().toString(); } } jfFile.close(); return new LoadedJarLibrary(filename, new LibraryIdentifier(sName, sVersion)); } LoadedJarLibrary(String filename, LibraryIdentifier ident); @Override URL getResourceAsUrl(String name); String[] getContainedClasses(); String[] getContainedResources(); LinkedList<String> getContainedFiles(); String getJarFileName(); static LoadedJarLibrary createFromJar(String filename); }
LoadedJarLibrary extends LoadedLibrary { public static LoadedJarLibrary createFromJar(String filename) throws IllegalArgumentException, IOException { JarFile jfFile = new JarFile(filename); String sName = jfFile.getManifest().getMainAttributes() .getValue(LibraryIdentifier.MANIFEST_LIBRARY_NAME_ATTRIBUTE); String sVersion = jfFile.getManifest().getMainAttributes() .getValue(LibraryIdentifier.MANIFEST_LIBRARY_VERSION_ATTRIBUTE); if (sName == null || sVersion == null) { LibraryIdentifier tmpId = LibraryIdentifier.fromFilename(filename); if (sName == null) { sName = tmpId.getName(); } if (sVersion == null) { sVersion = tmpId.getVersion().toString(); } } jfFile.close(); return new LoadedJarLibrary(filename, new LibraryIdentifier(sName, sVersion)); } LoadedJarLibrary(String filename, LibraryIdentifier ident); @Override URL getResourceAsUrl(String name); String[] getContainedClasses(); String[] getContainedResources(); LinkedList<String> getContainedFiles(); String getJarFileName(); static LoadedJarLibrary createFromJar(String filename);  }