You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sl...@apache.org on 2026/09/03 16:08:18 UTC

(maven-doxia) 02/02: Iterate attribute sets through entrySet rather than the Swing Enumeration

This is an automated email from the ASF dual-hosted git repository.

slachiewicz pushed a commit to branch agent/drop-html-attribute
in repository https://gitbox.apache.org/repos/asf/maven-doxia.git

commit ca5c84cd1a8f00840ee2333998419a2dd6ac903a
Author: Sylwester Lachiewicz <sl...@apache.org>
AuthorDate: Thu Sep 3 17:41:43 2026 +0200

    Iterate attribute sets through entrySet rather than the Swing Enumeration
    
    Only two places can move today: both already hold a SinkEventAttributes, so
    they can use the entrySet added in 2.1.0.
    
    SinkUtils.getAttributeString, asCssString and filterAttributes cannot follow.
    They take javax.swing.text.AttributeSet, which has no entrySet, and widening
    those parameters is a binary break. They stay on getAttributeNames until the
    Swing supertype goes in the next major.
    
    Part of #1092
---
 .../java/org/apache/maven/doxia/sink/impl/Xhtml5BaseSink.java |  8 ++------
 .../org/apache/maven/doxia/sink/SinkEventAttributeSet.java    | 11 +++++------
 2 files changed, 7 insertions(+), 12 deletions(-)

diff --git a/doxia-core/src/main/java/org/apache/maven/doxia/sink/impl/Xhtml5BaseSink.java b/doxia-core/src/main/java/org/apache/maven/doxia/sink/impl/Xhtml5BaseSink.java
index c47c5eba..8ab18011 100644
--- a/doxia-core/src/main/java/org/apache/maven/doxia/sink/impl/Xhtml5BaseSink.java
+++ b/doxia-core/src/main/java/org/apache/maven/doxia/sink/impl/Xhtml5BaseSink.java
@@ -1666,12 +1666,8 @@ public class Xhtml5BaseSink extends AbstractXmlSink implements HtmlMarkup {
     private SinkEventAttributes escapeAttributeValues(SinkEventAttributes attributes) {
         SinkEventAttributeSet set = new SinkEventAttributeSet(attributes.getAttributeCount());
 
-        Enumeration<?> names = attributes.getAttributeNames();
-
-        while (names.hasMoreElements()) {
-            Object name = names.nextElement();
-
-            set.addAttribute(name, escapeHTML(attributes.getAttribute(name).toString()));
+        for (Map.Entry<String, Object> attribute : attributes.entrySet()) {
+            set.addAttribute(attribute.getKey(), escapeHTML(attribute.getValue().toString()));
         }
 
         return set;
diff --git a/doxia-sink-api/src/main/java/org/apache/maven/doxia/sink/SinkEventAttributeSet.java b/doxia-sink-api/src/main/java/org/apache/maven/doxia/sink/SinkEventAttributeSet.java
index d77ab4c8..d0531abf 100644
--- a/doxia-sink-api/src/main/java/org/apache/maven/doxia/sink/SinkEventAttributeSet.java
+++ b/doxia-sink-api/src/main/java/org/apache/maven/doxia/sink/SinkEventAttributeSet.java
@@ -375,13 +375,12 @@ public class SinkEventAttributeSet implements SinkEventAttributes, Cloneable {
     @Override
     public String toString() {
         StringBuilder s = new StringBuilder();
-        Enumeration<String> names = getAttributeNames();
 
-        while (names.hasMoreElements()) {
-            String key = names.nextElement();
-            String value = getAttribute(key).toString();
-
-            s.append(' ').append(key).append('=').append(value);
+        for (Map.Entry<String, Object> attribute : entrySet()) {
+            s.append(' ')
+                    .append(attribute.getKey())
+                    .append('=')
+                    .append(attribute.getValue().toString());
         }
 
         return s.toString();