public void save(File dir) {
    Element root = DocumentHelper.createElement("builds");
    root.addAttribute("version", VERSION);

    Document doc = DocumentHelper.createDocument(root);

    synchronized (builds) {
      for (BuildFragment build : builds) {
        root.add(build.toXML());
      }
    }

    File file = new File(dir, OUTPUT_NAME);
    try {
      XMLHelper.writeXML(doc, file);
    } catch (MonitorException e) {
      logger.error("Write document " + file + " failed!", e);
    }
  }
  @SuppressWarnings("unchecked")
  public void load(File dir) {
    File file = new File(dir, OUTPUT_NAME);
    if (!file.exists()) {
      return;
    }

    try {
      Document doc = XMLHelper.readXML(file);
      List<Element> elements = doc.getRootElement().elements();

      synchronized (builds) {
        for (Element node : elements) {
          BuildFragment build = new BuildFragment();
          build.fromXML(node);
          builds.add(build);
        }
      }
    } catch (MonitorException e) {
      logger.error("Read document " + file + " failed!", e);
    }
  }