element.addElement("ShortMessage").addText(bugInstance.toString());
BugPattern bugPattern = bugInstance.getBugPattern();  element.addElement("ShortMessage").addText( bugPattern != null ? bugPattern.getShortDescription() : bugInstance.toString());
	public void execute() {		Iterator elementIter = document.selectNodes("/BugCollection/BugInstance").iterator();		Iterator<BugInstance> bugInstanceIter = bugCollection.iterator();		Set<String> bugTypeSet = new HashSet<String>();		// Add short and long descriptions to BugInstance elements.		// We rely on the Document and the BugCollection storing		// the bug instances in the same order.		while (elementIter.hasNext() && bugInstanceIter.hasNext()) {			Element element = (Element) elementIter.next();			BugInstance bugInstance = bugInstanceIter.next();			String bugType = bugInstance.getType();			bugTypeSet.add(bugType);			element.addElement("ShortMessage").addText(bugInstance.toString());			element.addElement("LongMessage").addText(bugInstance.getMessage());		}		// Add BugPattern elements for each referenced bug types.		Element root = document.getRootElement();		for (Iterator<String> bugTypeIter = bugTypeSet.iterator(); bugTypeIter.hasNext(); ) {			String bugType = bugTypeIter.next();			BugPattern bugPattern = I18N.instance().lookupBugPattern(bugType);			if (bugPattern == null)				continue;			Element details = root.addElement("BugPattern");			details				.addAttribute("type", bugType)				.addAttribute("abbrev", bugPattern.getAbbrev())				.addAttribute("category", bugPattern.getCategory());			details				.addElement("ShortDescription")				.addText(bugPattern.getShortDescription());			details				.addElement("Details")				.addCDATA(bugPattern.getDetailText());		}	}