49 public class Manifest implements Cloneable { |
49 public class Manifest implements Cloneable { |
50 // manifest main attributes |
50 // manifest main attributes |
51 private Attributes attr = new Attributes(); |
51 private Attributes attr = new Attributes(); |
52 |
52 |
53 // manifest entries |
53 // manifest entries |
54 private Map entries = new HashMap(); |
54 private Map<String, Attributes> entries = new HashMap<>(); |
55 |
55 |
56 /** |
56 /** |
57 * Constructs a new, empty Manifest. |
57 * Constructs a new, empty Manifest. |
58 */ |
58 */ |
59 public Manifest() { |
59 public Manifest() { |
146 public void write(OutputStream out) throws IOException { |
146 public void write(OutputStream out) throws IOException { |
147 DataOutputStream dos = new DataOutputStream(out); |
147 DataOutputStream dos = new DataOutputStream(out); |
148 // Write out the main attributes for the manifest |
148 // Write out the main attributes for the manifest |
149 attr.writeMain(dos); |
149 attr.writeMain(dos); |
150 // Now write out the pre-entry attributes |
150 // Now write out the pre-entry attributes |
151 Iterator it = entries.entrySet().iterator(); |
151 Iterator<Map.Entry<String, Attributes>> it = entries.entrySet().iterator(); |
152 while (it.hasNext()) { |
152 while (it.hasNext()) { |
153 Map.Entry e = (Map.Entry)it.next(); |
153 Map.Entry<String, Attributes> e = it.next(); |
154 StringBuffer buffer = new StringBuffer("Name: "); |
154 StringBuffer buffer = new StringBuffer("Name: "); |
155 String value = (String)e.getKey(); |
155 String value = e.getKey(); |
156 if (value != null) { |
156 if (value != null) { |
157 byte[] vb = value.getBytes("UTF8"); |
157 byte[] vb = value.getBytes("UTF8"); |
158 value = new String(vb, 0, 0, vb.length); |
158 value = new String(vb, 0, 0, vb.length); |
159 } |
159 } |
160 buffer.append(value); |
160 buffer.append(value); |
161 buffer.append("\r\n"); |
161 buffer.append("\r\n"); |
162 make72Safe(buffer); |
162 make72Safe(buffer); |
163 dos.writeBytes(buffer.toString()); |
163 dos.writeBytes(buffer.toString()); |
164 ((Attributes)e.getValue()).write(dos); |
164 e.getValue().write(dos); |
165 } |
165 } |
166 dos.flush(); |
166 dos.flush(); |
167 } |
167 } |
168 |
168 |
169 /** |
169 /** |