Document (MigrationMap map) { Element root = new Element(MIGRATION_MAP); Element nameElement = new Element(NAME); nameElement.setAttribute(VALUE, map.getName()); root.addContent(nameElement); Element orderElement = new Element(ORDER); orderElement.setAttribute(VALUE, String.valueOf(map.getOrder())); root.addContent(orderElement); Element descriptionElement = new Element(DESCRIPTION); descriptionElement.setAttribute(VALUE, map.getDescription()); root.addContent(descriptionElement); for(int i = 0; i < map.getEntryCount(); i++){ MigrationMapEntry entry = map.getEntryAt(i); Element element = new Element(ENTRY); element.setAttribute(OLD_NAME, entry.getOldName()); element.setAttribute(NEW_NAME, entry.getNewName()); if (entry.getType() == MigrationMapEntry.PACKAGE){ element.setAttribute(TYPE, PACKAGE_TYPE); element.setAttribute(RECURSIVE, Boolean.valueOf(entry.isRecursive()).toString()); } else{ element.setAttribute(TYPE, CLASS_TYPE); } root.addContent(element); } return new Document(root); }