Element () { Element state = new Element("state"); for (Map.Entry<String, String> entry : lastSelectedUrls.entrySet()) { Element child = new Element("entry"); child.setAttribute("context", entry.getKey()); child.setAttribute("url", entry.getValue()); state.addContent(child); } if (lastSelectedFileUrl != null) { state.setAttribute("lastSelectedFileUrl", lastSelectedFileUrl); } return state; }