Element root = document.addElement("FindBugsSummary"); DateFormat df = new SimpleDateFormat( "EEE, d MMM yyyy HH:mm:ss Z" ); root.addAttribute("timestamp", df.format(new Date() )); root.addAttribute( "total_classes", String.valueOf( totalClasses ) ); root.addAttribute( "total_bugs", String.valueOf( totalErrors ) ); root.addAttribute( "num_packages", String.valueOf( packageStatsMap.size() ) ); Iterator<PackageStats> i = packageStatsMap.values().iterator(); while( i.hasNext() ) { PackageStats stats = i.next(); stats.toElement( root ); }
stats.setDate(new Date()); stats.toElement(document);
  public void reportSummary( OutputStream out ) {     Document document = DocumentHelper.createDocument();     Element root = document.addElement("FindBugsSummary");     DateFormat df = new SimpleDateFormat( "EEE, d MMM yyyy HH:mm:ss Z" );     root.addAttribute("timestamp", df.format(new Date() ));     root.addAttribute( "total_classes", String.valueOf( totalClasses ) );     root.addAttribute( "total_bugs", String.valueOf( totalErrors ) );     root.addAttribute( "num_packages", String.valueOf( packageStatsMap.size() ) );	 Iterator<PackageStats> i = packageStatsMap.values().iterator();     while( i.hasNext() ) {       PackageStats stats = i.next();       stats.toElement( root );     }      try {       XMLWriter writer = new XMLWriter(out, OutputFormat.createPrettyPrint());       writer.write(document);     }     catch ( Exception e ) {       e.printStackTrace();     }  }