Element () { Element element = new Element("state"); // Save locations for (Map.Entry<String, Point> entry : myKeyToLocation.entrySet()) { Point point = entry.getValue(); LOG.assertTrue(point != null); Element e = new Element(ELEMENT_LOCATION); e.setAttribute(KEY, entry.getKey()); e.setAttribute(ATTRIBUTE_X, String.valueOf(point.x)); e.setAttribute(ATTRIBUTE_Y, String.valueOf(point.y)); element.addContent(e); } // Save sizes for (Map.Entry<String, Dimension> entry : myKeToSize.entrySet()) { Dimension size = entry.getValue(); LOG.assertTrue(size != null); Element e = new Element(ELEMENT_SIZE); e.setAttribute(KEY, entry.getKey()); e.setAttribute(ATTRIBUTE_WIDTH, String.valueOf(size.width)); e.setAttribute(ATTRIBUTE_HEIGHT, String.valueOf(size.height)); element.addContent(e); } // save extended states for (ObjectIntMap.Entry<String> entry : myKeyToExtendedState.entries()) { Element e = new Element(EXTENDED_STATE); e.setAttribute(KEY, entry.getKey()); e.setAttribute(STATE, Integer.toString(entry.getValue())); element.addContent(e); } return element; }