public void setManifest(Manifest manifest) { check(); manifestFirst = true; this.manifest = manifest; }
public void setManifest(Manifest manifest) { check(); manifestFirst = true; this.manifest = manifest; }
private String getDirectory(String path) { check(); int n = path.lastIndexOf('/'); if (n < 0) return ""; return path.substring(0, n); }
public void setManifestName(String manifestName) { check(); if (manifestName == null || manifestName.length() == 0) throw new IllegalArgumentException("Manifest name cannot be null or empty!"); this.manifestName = manifestName; }
private String getDirectory(String path) { check(); int n = path.lastIndexOf('/'); if (n < 0) return ""; return path.substring(0, n); }
public List<String> getPackages() { check(); List<String> list = new ArrayList<String>(directories.size()); for (Map.Entry<String,Map<String,Resource>> i : directories.entrySet()) { if (i.getValue() != null) { String path = i.getKey(); String pack = path.replace('/', '.'); list.add(pack); } } return list; }
public List<String> getPackages() { check(); return directories.entrySet() .stream() .filter(e -> e.getValue() != null) .map(e -> e.getKey() .replace('/', '.')) .collect(Collectors.toList()); }
public Resource remove(String path) { check(); Resource resource = resources.remove(path); if (resource != null) { String dir = getDirectory(path); Map<String, Resource> mdir = directories.get(dir); // must be != null mdir.remove(path); } return resource; }
public boolean addDirectory(Map<String, Resource> directory, boolean overwrite) { check(); boolean duplicates = false; if (directory == null) return false; for (Map.Entry<String, Resource> entry : directory.entrySet()) { duplicates |= putResource(entry.getKey(), entry.getValue(), overwrite); } return duplicates; }
private void doManifest(Set<String> done, ZipOutputStream jout) throws Exception { check(); if (nomanifest) return; JarEntry ze = new JarEntry("META-INF/MANIFEST.MF"); jout.putNextEntry(ze); writeManifest(jout); jout.closeEntry(); done.add(ze.getName()); }
public String getVersion() throws Exception { check(); Manifest m = getManifest(); if (m == null) return null; String s = m.getMainAttributes().getValue(Constants.BUNDLE_VERSION); if (s == null) return null; return s.trim(); }
public void setManifest(File file) throws IOException { check(); FileInputStream fin = new FileInputStream(file); try { Manifest m = new Manifest(fin); setManifest(m); } finally { fin.close(); } }
public Resource remove(String path) { check(); Resource resource = resources.remove(path); String dir = getDirectory(path); Map<String,Resource> mdir = directories.get(dir); // must be != null mdir.remove(path); return resource; }
public Manifest getManifest() throws Exception { check(); if (manifest == null) { Resource manifestResource = getResource("META-INF/MANIFEST.MF"); if (manifestResource != null) { InputStream in = manifestResource.openInputStream(); manifest = new Manifest(in); in.close(); } } return manifest; }
public void setManifest(File file) throws IOException { check(); try (InputStream fin = IO.stream(file)) { Manifest m = new Manifest(fin); setManifest(m); } }
public Manifest getManifest() throws Exception { check(); if (manifest == null) { Resource manifestResource = getResource(manifestName); if (manifestResource != null) { try (InputStream in = manifestResource.openInputStream()) { manifest = new Manifest(in); } } } return manifest; }
public void copy(Jar srce, String path, boolean overwrite) { check(); addDirectory(srce.getDirectories() .get(path), overwrite); }
public boolean rename(String oldPath, String newPath) { check(); Resource resource = remove(oldPath); if (resource == null) return false; return putResource(newPath, resource); }
public void write(File file) throws Exception { check(); try (OutputStream out = IO.outputStream(file)) { write(out); } catch (Exception t) { IO.delete(file); throw t; } file.setLastModified(lastModified); }
/** * Cleanup the manifest for writing. Cleaning up consists of adding a space * after any \n to prevent the manifest to see this newline as a delimiter. * * @param out Output * @throws IOException */ public void writeManifest(OutputStream out) throws Exception { check(); stripSignatures(); writeManifest(getManifest(), out); }