public MessageHeader getEntry(String name) {
   Enumeration enu = entries();
   while (enu.hasMoreElements()) {
     MessageHeader mh = (MessageHeader) enu.nextElement();
     String nameVal = mh.findValue("Name");
     if (nameVal != null && nameVal.equals(name)) {
       return mh;
     }
   }
   return null;
 }
  /* Add a manifest file at current position in a stream
   */
  public void stream(OutputStream os, Vector extraFiles) throws IOException {

    /* the first header in the file should be the global one.
     * It should say "Manifest-Version: x.x"; barf if not
     */
    MessageHeader globals = (MessageHeader) entries.elementAt(0);
    if (globals.findValue("Manifest-Version") == null) {
      throw new IOException("Manifest file requires " + "Manifest-Version: 1.0 in 1st header");
    }

    PrintWriter ps = new PrintWriter(os);
    globals.print(ps);

    for (int i = 1; i < entries.size(); ++i) {
      MessageHeader mh = (MessageHeader) entries.elementAt(i);

      mh.print(ps);

      /* REMIND: could be adding files twice!!! */
      String name = mh.findValue("name");
      if (extraFiles != null && name != null) {
        extraFiles.addElement(name);
      }
    }
  }
 public void addFile(File f) throws IOException {
   MessageHeader mh = new MessageHeader();
   mh.add("Name", f.getPath());
   addEntry(mh);
 }
 /* recursively generate manifests from directory tree */
 public Manifest(String[] files) throws IOException {
   MessageHeader globals = new MessageHeader();
   globals.add("Manifest-Version", "1.0");
   addEntry(globals);
   addFiles(null, files);
 }