/** * Writes the index file out to <code>jos</code>. <code>oldEntries</code> gives the names of the * files that were removed, <code>movedMap</code> maps from the new name to the old name. */ private static void createIndex(JarOutputStream jos, List oldEntries, Map movedMap) throws IOException { StringWriter writer = new StringWriter(); writer.write(VERSION_HEADER); writer.write("\r\n"); // Write out entries that have been removed for (int counter = 0; counter < oldEntries.size(); counter++) { String name = (String) oldEntries.get(counter); writer.write(REMOVE_COMMAND); writer.write(" "); writeEscapedString(writer, name); writer.write("\r\n"); } // And those that have moved Iterator names = movedMap.keySet().iterator(); if (names != null) { while (names.hasNext()) { String newName = (String) names.next(); String oldName = (String) movedMap.get(newName); writer.write(MOVE_COMMAND); writer.write(" "); writeEscapedString(writer, oldName); writer.write(" "); writeEscapedString(writer, newName); writer.write("\r\n"); } } JarEntry je = new JarEntry(INDEX_NAME); byte[] bytes = writer.toString().getBytes("UTF-8"); writer.close(); jos.putNextEntry(je); jos.write(bytes, 0, bytes.length); }
public Manifest getManifest() throws IOException { if (!isSuperMan()) { return null; } Manifest man = new Manifest(); Attributes attr = man.getMainAttributes(); attr.putAll((Map) superAttr.clone()); // now deep copy the manifest entries if (superEntries != null) { Map entries = man.getEntries(); Iterator it = superEntries.keySet().iterator(); while (it.hasNext()) { Object key = it.next(); Attributes at = (Attributes) superEntries.get(key); entries.put(key, at.clone()); } } return man; }