public ArchiveManifest makeManifest(InputStream in) throws IOException { ArchiveManifest mf = new ArchiveManifestImpl(in); setManifest(mf); return mf; }
/** * Adds the key/value pair to the attributes for the given entry name; if the entry does not * exist, creates a new attributes */ public void addEntryAttribute(String entryName, String key, String value) { Attributes attr = getAttributes(entryName); if (attr == null) addEntry(entryName); attr = getAttributes(entryName); attr.putValue(key, value); }
/** * @see com.ibm.etools.archive.ArchiveManifest */ public void mergeClassPath(java.lang.String[] classPathEntries) { StringBuffer sb = new StringBuffer(); java.util.List existing = java.util.Arrays.asList(getClassPathTokenized()); String cp = getClassPath(); if (cp != null) sb.append(cp); boolean empty = cp == null || "".equals(cp); //$NON-NLS-1$ for (int i = 0; i < classPathEntries.length; i++) { if (!existing.contains(classPathEntries[i])) { if (!empty) sb.append(" "); //$NON-NLS-1$ else empty = false; sb.append(classPathEntries[i]); } } setClassPath(sb.toString()); }
/** * @see com.ibm.etools.archive.ArchiveManifest */ public void appendClassPath(java.lang.String extension) { String classPath = getClassPath(); if (classPath != null) setClassPath(classPath + " " + extension);//$NON-NLS-1$ else setClassPath(extension); }
public void addVersionIfNecessary() { //This is a hack because of the fact that the manifest does not serialize correctly if //The version is not set. In addition to saves, the serialization is used for copy if (getManifestVersion() == null || getManifestVersion().equals(""))//$NON-NLS-1$ setManifestVersion("1.0");//$NON-NLS-1$ }
/** * Writes the Manifest to the specified OutputStream, splitting each classpath entry on a line * by itself. * * @param out * the output stream * @exception IOException * if an I/O error has occurred */ public void writeSplittingClasspath(OutputStream out) throws IOException { DataOutputStream dos = new DataOutputStream(out); // Write out the main attributes for the manifest writeMainSplittingClasspath(getMainAttributes(), dos); // Now write out the pre-entry attributes Iterator it = getEntries().entrySet().iterator(); while (it.hasNext()) { Map.Entry e = (Map.Entry) it.next(); StringBuffer buffer = new StringBuffer("Name: "); //$NON-NLS-1$ buffer.append((String) e.getKey()); buffer.append("\r\n"); //$NON-NLS-1$ localMake72Safe(buffer); dos.writeBytes(buffer.toString()); write((Attributes) e.getValue(), dos); } dos.flush(); }
protected void writeMainSplittingClasspath(Attributes attributes, DataOutputStream out) throws IOException { String version = toUtf8(attributes.getValue(vername)); if (version == null) { vername = Attributes.Name.SIGNATURE_VERSION.toString(); version = toUtf8(attributes.getValue(vername)); if ((version != null) && !(name.equalsIgnoreCase(vername))) { if (name.equalsIgnoreCase(Attributes.Name.CLASS_PATH.toString())) { writeSplit(out, name, toUtf8((String) e.getValue())); continue; buffer.append(toUtf8((String) e.getValue())); buffer.append("\r\n"); //$NON-NLS-1$ localMake72Safe(buffer); out.writeBytes(buffer.toString());
public String getImplementationVersion() { return getMainAttributes().getValue(Attributes.Name.IMPLEMENTATION_VERSION); }
protected void write(Attributes attributes, DataOutputStream os) throws IOException { Iterator it = attributes.entrySet().iterator(); while (it.hasNext()) { Map.Entry e = (Map.Entry) it.next(); StringBuffer buffer = new StringBuffer(((Attributes.Name) e.getKey()).toString()); buffer.append(": "); //$NON-NLS-1$ buffer.append(toUtf8((String) e.getValue())); buffer.append("\r\n"); //$NON-NLS-1$ localMake72Safe(buffer); os.writeBytes(buffer.toString()); } os.writeBytes("\r\n"); //$NON-NLS-1$ }
public String getEntryAttribute(String entryName, String key) { Attributes attr = getAttributes(entryName); if (attr == null) return null; return attr.getValue(key); }
public void removeEntry(String entryName) { getEntries().remove(entryName); }
/** * Creates a new manifest entry (attributes) for the given name */ public void addEntry(String entryName) { Attributes attr = new Attributes(); addEntry(entryName, attr); }
/** * @see com.ibm.etools.archive.ArchiveManifest */ public java.lang.String[] getClassPathTokenized() { String classPath = getClassPath(); if (classPath == null) return new String[0]; return org.eclipse.jst.j2ee.commonarchivecore.internal.util.ArchiveUtil.getTokens(classPath); }
protected void writeSplit(DataOutputStream out, String name, String value) throws IOException { StringTokenizer tok = new StringTokenizer(value); int inc = 0; while (tok.hasMoreTokens()) { StringBuffer buffer = null; if (inc == 0) { buffer = new StringBuffer(name); buffer.append(": "); //$NON-NLS-1$ } else { buffer = new StringBuffer(); buffer.append(' '); } buffer.append(tok.nextToken()); if (tok.countTokens() > 0) buffer.append(" \r\n"); //$NON-NLS-1$ else buffer.append("\r\n"); //$NON-NLS-1$ localMake72Safe(buffer); out.writeBytes(buffer.toString()); inc++; } }
public String getManifestVersion() { return getMainAttributes().getValue(Attributes.Name.MANIFEST_VERSION); }
public void removeEntryAttribute(String entryName, Object key) { Attributes attr = getAttributes(entryName); if (attr != null) attr.remove(key); }
public void addEntry(String entryName, Attributes attr) { getEntries().put(entryName, attr); }
/** * @see com.ibm.etools.commonarchive.Archive */ public void setManifest(java.util.jar.Manifest aManifest) { setManifest((ArchiveManifest) new org.eclipse.jst.j2ee.commonarchivecore.internal.helpers.ArchiveManifestImpl(aManifest)); }
/** * @see com.ibm.etools.archive.ArchiveManifest */ public void setManifestVersion(java.lang.String version) { Attributes attributes = getMainAttributes(); attributes.putValue(Attributes.Name.MANIFEST_VERSION.toString(), version); }
public ArchiveManifest makeManifest() { ArchiveManifest mf = new ArchiveManifestImpl(); setManifest(mf); return mf; }