protected void writeAttributes(DOMOutput out) throws IOException { Figure prototype = (Figure) out.getPrototype(); boolean isElementOpen = false; for (Map.Entry<AttributeKey, Object> entry : attributes.entrySet()) { AttributeKey key = entry.getKey(); if (forbiddenAttributes == null || !forbiddenAttributes.contains(key)) { @SuppressWarnings("unchecked") Object prototypeValue = prototype.get(key); @SuppressWarnings("unchecked") Object attributeValue = get(key); if (prototypeValue != attributeValue || (prototypeValue != null && attributeValue != null && !prototypeValue.equals(attributeValue))) { if (!isElementOpen) { out.openElement("a"); isElementOpen = true; } out.openElement(key.getKey()); out.writeObject(entry.getValue()); out.closeElement(); } } } if (isElementOpen) { out.closeElement(); } }