}
public void addContexts() {
final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
for (final Entry<ContextData, String> entry : this.contextMap.entrySet()) {
final ContextData context = entry.getKey();
final Element contextElement = this.root.addElement("context");
contextElement.addAttribute("id", entry.getValue());
contextElement.addElement("entity").addElement("identifier").addAttribute("scheme", SCHEME_URL).addText(IDENTIFIER);
final Element periodElement = contextElement.addElement("period");
if (context.getPeriodType() == 0) {
periodElement.addElement("instant").addText(format.format(this.endDate));
} else {
periodElement.addElement("startDate").addText(format.format(this.startDate));
periodElement.addElement("endDate").addText(format.format(this.endDate));
}
final String dimension = context.getDimension();
final String dimType = context.getDimensionType();
if (dimType != null && dimension != null) {
contextElement.addElement("scenario").addElement("explicitMember").addAttribute("dimension", dimType).addText(dimension);
}
}