public MergeableManifest(InputStream in) throws IOException { try { Field field = Manifest.class.getDeclaredField("attr"); field.setAccessible(true); field.set(this, new OrderAwareAttributes()); } catch (Exception e) { throw new IllegalStateException(e); } read(in); // hack: reconstruct linebreaks addRequiredBundles(Collections.<String>emptySet()); addExportedPackages(Collections.<String>emptySet()); addImportedPackages(Collections.<String>emptySet()); modified = false; }
@SuppressWarnings("deprecation") @Override public void write(OutputStream out) throws IOException { DataOutputStream dos = new DataOutputStream(out); // Write out the main attributes for the manifest ((OrderAwareAttributes) getMainAttributes()).myWriteMain(dos); // Now write out the pre-entry attributes Iterator<Map.Entry<String, Attributes>> it = getEntries().entrySet().iterator(); while (it.hasNext()) { Map.Entry<String, Attributes> e = it.next(); StringBuffer buffer = new StringBuffer("Name: "); String value = e.getKey(); if (value != null) { byte[] vb = value.getBytes("UTF8"); value = new String(vb, 0, 0, vb.length); } buffer.append(value); buffer.append("\r\n"); dos.writeBytes(make512Safe(buffer)); ((OrderAwareAttributes) e.getValue()).myWrite(dos); } dos.flush(); }
public void myWriteMain(DataOutputStream out) throws IOException { String version = getValue(vername); if (version == null) { vername = Name.SIGNATURE_VERSION.toString(); version = getValue(vername); Iterator<Map.Entry<Object, Object>> it = entrySet().iterator(); while (it.hasNext()) { Map.Entry<Object, Object> e = it.next();
String bundleName = (String) getMainAttributes().get(BUNDLE_SYMBOLIC_NAME); if (bundleName != null) { int idx = bundleName.indexOf(';'); bundlesToMerge = bundles; String s = (String) getMainAttributes().get(REQUIRE_BUNDLE); Wrapper<Boolean> modified = Wrapper.wrap(this.modified); String result = mergeIntoCommaSeparatedList(s, bundlesToMerge, modified, lineDelimiter); this.modified = modified.get(); getMainAttributes().put(REQUIRE_BUNDLE, result);
@SuppressWarnings("deprecation") public void myWrite(DataOutputStream out) throws IOException { Iterator<Map.Entry<Object, Object>> it = entrySet().iterator(); while (it.hasNext()) { Map.Entry<Object, Object> e = it.next(); String value = (String) e.getValue(); if (Strings.isEmpty(value)) { StringBuffer buffer = new StringBuffer(((Name) e.getKey()).toString()); buffer.append(": "); byte[] vb = value.trim().getBytes("UTF8"); value = new String(vb, 0, 0, vb.length); buffer.append(value); if (it.hasNext()) buffer.append(LINEBREAK); out.writeBytes(make512Safe(buffer)); } } out.writeBytes(LINEBREAK); } }
public void myWrite(DataOutputStream out) throws IOException { Iterator<Map.Entry<Object, Object>> it = entrySet().iterator(); while (it.hasNext()) { Map.Entry<Object, Object> e = it.next(); String value = (String) e.getValue(); if (Strings.isEmpty(value)) { StringBuffer buffer = new StringBuffer(((Name) e.getKey()).toString()); buffer.append(": "); byte[] vb = value.trim().getBytes("UTF8"); value = new String(vb, 0, 0, vb.length); buffer.append(value); if (it.hasNext()) buffer.append(lineDelimiter); out.writeBytes(make512Safe(buffer, lineDelimiter)); } } out.writeBytes(lineDelimiter); } }
@Override public void write(OutputStream out) throws IOException { DataOutputStream dos = new DataOutputStream(out); // Write out the main attributes for the manifest getMainAttributes().myWriteMain(dos); // Now write out the pre-entry attributes Iterator<Map.Entry<String, Attributes>> it = getEntries().entrySet().iterator(); while (it.hasNext()) { Map.Entry<String, Attributes> e = it.next(); StringBuffer buffer = new StringBuffer("Name: "); String value = e.getKey(); if (value != null) { byte[] vb = value.getBytes("UTF8"); value = new String(vb, 0, 0, vb.length); } buffer.append(value); buffer.append(lineDelimiter); dos.writeBytes(make512Safe(buffer, lineDelimiter)); ((OrderAwareAttributes) e.getValue()).myWrite(dos); } dos.flush(); }
public MergeableManifest(InputStream in) throws IOException { try { Field field = Manifest.class.getDeclaredField("attr"); field.setAccessible(true); field.set(this, new OrderAwareAttributes()); } catch (Exception e) { throw new IllegalStateException(e); } read(in); // hack: reconstruct linebreaks addRequiredBundles(Collections.<String>emptySet()); addExportedPackages(Collections.<String>emptySet()); addImportedPackages(Collections.<String>emptySet()); modified = false; }
/** * @since 2.9 */ public String getBundleActivator() { return (String) getMainAttributes().get(BUNDLE_ACTIVATOR); }
/** * adds the qualified names to the export-package attribute, if not already * present. * * @param packages - passing parameterized packages is not supported */ public void addExportedPackages(Set<String> packages) { String s = (String) getMainAttributes().get(EXPORT_PACKAGE); Wrapper<Boolean> modified = Wrapper.wrap(this.modified); String result = mergeIntoCommaSeparatedList(s, packages, modified, lineDelimiter); this.modified = modified.get(); getMainAttributes().put(EXPORT_PACKAGE, result); }
/** * @since 2.9 */ public String getBREE() { return (String) getMainAttributes().get(BUNDLE_REQUIRED_EXECUTION_ENV); }
/** * @since 2.9 */ public void setBREE(String bree) { String oldValue = getBREE(); if (Objects.equal(oldValue, bree)) { return; } getMainAttributes().put(BUNDLE_REQUIRED_EXECUTION_ENV, bree); this.modified = true; }
public void addImportedPackages(Set<String> packages) { String s = (String) getMainAttributes().get(IMPORT_PACKAGE); Wrapper<Boolean> modified = Wrapper.wrap(this.modified); String result = mergeIntoCommaSeparatedList(s, packages, modified, lineDelimiter); this.modified = modified.get(); getMainAttributes().put(IMPORT_PACKAGE, result); }
/** * @since 2.9 */ public void setBundleActivator(String activator) { String oldValue = getBundleActivator(); if (Objects.equal(oldValue, activator)) { return; } getMainAttributes().put(BUNDLE_ACTIVATOR, activator); this.modified = true; }