You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@juneau.apache.org by ja...@apache.org on 2026/08/12 19:11:50 UTC

(juneau) branch master updated: TODO-351 B-marshall-4: rename XmlFormat.ELEMENTS to FREEFORM (10.0 breaking-change window)

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

jamesbognar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/juneau.git


The following commit(s) were added to refs/heads/master by this push:
     new 4588677ffb TODO-351 B-marshall-4: rename XmlFormat.ELEMENTS to FREEFORM (10.0 breaking-change window)
4588677ffb is described below

commit 4588677ffbede7055a786f1b78f31aa6028ef9a1
Author: James Bognar <ja...@apache.org>
AuthorDate: Wed Aug 12 15:11:45 2026 -0400

    TODO-351 B-marshall-4: rename XmlFormat.ELEMENTS to FREEFORM (10.0 breaking-change window)
---
 .../juneau/bean/html5/HtmlElementContainer.java    |  2 +-
 .../apache/juneau/marshall/xml/XmlBeanMeta.java    | 10 +++----
 .../org/apache/juneau/marshall/xml/XmlFormat.java  |  6 ++--
 .../juneau/marshall/xml/XmlParserSession.java      |  8 ++---
 .../apache/juneau/AnnotationInheritance_Test.java  |  4 +--
 .../apache/juneau/marshall/xml/BasicXml_Test.java  |  2 +-
 .../juneau/marshall/xml/InvalidXmlBeans_Test.java  | 34 +++++++++++-----------
 .../marshall/xml/XmlIgnoreComments_Test.java       |  2 +-
 .../juneau/marshall/xml/XmlParserSession_Test.java |  6 ++--
 .../XmlSerializerSession_BranchCoverage_Test.java  |  2 +-
 10 files changed, 38 insertions(+), 38 deletions(-)

diff --git a/juneau-bean/juneau-bean-html5/src/main/java/org/apache/juneau/bean/html5/HtmlElementContainer.java b/juneau-bean/juneau-bean-html5/src/main/java/org/apache/juneau/bean/html5/HtmlElementContainer.java
index 10e491b5c5..5bf1f39955 100644
--- a/juneau-bean/juneau-bean-html5/src/main/java/org/apache/juneau/bean/html5/HtmlElementContainer.java
+++ b/juneau-bean/juneau-bean-html5/src/main/java/org/apache/juneau/bean/html5/HtmlElementContainer.java
@@ -126,7 +126,7 @@ public abstract class HtmlElementContainer<SELF extends HtmlElementContainer<SEL
 	 *
 	 * @return The children of this element, or <jk>null</jk> if no children are set.
 	 */
-	@Xml(format = ELEMENTS)
+	@Xml(format = FREEFORM)
 	@BeanProp(name="c") @MarshalledProp(dictionary=HtmlBeanDictionary.class)
 	public List<Object> getChildren() { return u(children); }
 
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/marshall/xml/XmlBeanMeta.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/marshall/xml/XmlBeanMeta.java
index f6a895d36d..908f17d861 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/marshall/xml/XmlBeanMeta.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/marshall/xml/XmlBeanMeta.java
@@ -58,13 +58,13 @@ public class XmlBeanMeta extends ExtendedBeanMeta {
 				var xf = x.format();
 				if (xf == ATTRS)
 					defaultFormat.set(XmlFormat.ATTR);
-				else if (xf.isOneOf(ELEMENTS, DEFAULT))
+				else if (xf.isOneOf(FREEFORM, DEFAULT))
 					defaultFormat.set(ELEMENT);
 				else if (xf == VOID) {
 					contentFormat = VOID;
 					defaultFormat.set(VOID);
 				} else
-					throw brex(c, "Invalid format specified in @Xml annotation on bean: %s.  Must be one of the following: DEFAULT,ATTRS,ELEMENTS,VOID", x.format());
+					throw brex(c, "Invalid format specified in @Xml annotation on bean: %s.  Must be one of the following: DEFAULT,ATTRS,FREEFORM,VOID", x.format());
 			});
 
 			beanMeta.getProperties().values().forEach(p -> {
@@ -87,8 +87,8 @@ public class XmlBeanMeta extends ExtendedBeanMeta {
 					if (! pcm.isMapOrBean())
 						throw brex(c, "Invalid type for ATTRS property.  Only properties of type Map and bean can be used.");
 					attrsProperty = p;
-				} else if (xf.isOneOf(ELEMENTS, MIXED, MIXED_PWS, TEXT, TEXT_PWS, XMLTEXT)) {
-					if (xf.isOneOf(ELEMENTS, MIXED, MIXED_PWS) && ! pcm.isCollectionOrArray())
+				} else if (xf.isOneOf(FREEFORM, MIXED, MIXED_PWS, TEXT, TEXT_PWS, XMLTEXT)) {
+					if (xf.isOneOf(FREEFORM, MIXED, MIXED_PWS) && ! pcm.isCollectionOrArray())
 						throw brex(c, "Invalid type for %s property.  Only properties of type Collection and array can be used.", xf);
 					if (nn(contentProperty)) {
 						if (xf == contentFormat)
@@ -167,7 +167,7 @@ public class XmlBeanMeta extends ExtendedBeanMeta {
 	 * <p>
 	 * Can be one of the following:
 	 * <ul>
-	 * 	<li>{@link XmlFormat#ELEMENTS}
+	 * 	<li>{@link XmlFormat#FREEFORM}
 	 * 	<li>{@link XmlFormat#MIXED}
 	 * 	<li>{@link XmlFormat#MIXED_PWS}
 	 * 	<li>{@link XmlFormat#TEXT}
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/marshall/xml/XmlFormat.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/marshall/xml/XmlFormat.java
index c1a1af903d..d918d709bd 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/marshall/xml/XmlFormat.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/marshall/xml/XmlFormat.java
@@ -30,7 +30,7 @@ public enum XmlFormat {
 	 * Normal formatting (default).
 	 *
 	 * <p>
-	 * On a bean class, implies {@link #ELEMENTS} meaning bean properties will be serialized as child elements by default.
+	 * On a bean class, implies {@link #FREEFORM} meaning bean properties will be serialized as child elements by default.
 	 *
 	 * <p>
 	 * On a bean property, implies {@link #ELEMENT} meaning the bean property will be serialized as a child element.
@@ -87,10 +87,10 @@ public enum XmlFormat {
 	 * On a bean property, implies that the bean property value itself should be serialized as child elements of the
 	 * bean element.
 	 */
-	ELEMENTS,
+	FREEFORM,
 
 	/**
-	 * Same as {@link #ELEMENTS} except primitive types (string/boolean/number/null for example) are not wrapped in elements.
+	 * Same as {@link #FREEFORM} except primitive types (string/boolean/number/null for example) are not wrapped in elements.
 	 *
 	 * <p>
 	 * Only applicable for bean properties, not bean classes.
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/marshall/xml/XmlParserSession.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/marshall/xml/XmlParserSession.java
index aea7da285e..3530d13668 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/marshall/xml/XmlParserSession.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/marshall/xml/XmlParserSession.java
@@ -400,7 +400,7 @@ public class XmlParserSession extends ReaderParserSession implements RecordReada
 			var event = r.next();
 			String currAttr;
 			// We only care about text in MIXED mode.
-			// Ignore if in ELEMENTS mode.
+			// Ignore if in FREEFORM mode.
 			if (event == CHARACTERS) {
 				if (nn(cp) && cpf.isOneOf(MIXED, MIXED_PWS)) {
 					if (cpcm.isCollectionOrArray()) {
@@ -410,7 +410,7 @@ public class XmlParserSession extends ReaderParserSession implements RecordReada
 					} else {
 						cp.set(m, null, getText(r, trim));
 					}
-				} else if (cpf != ELEMENTS) {
+				} else if (cpf != FREEFORM) {
 					var s = getText(r, trim);
 					if (nn(s)) {
 						if (sb == null)
@@ -418,7 +418,7 @@ public class XmlParserSession extends ReaderParserSession implements RecordReada
 						sb.append(s);
 					}
 				} else {
-					// Do nothing...we're in ELEMENTS mode.
+					// Do nothing...we're in FREEFORM mode.
 				}
 			} else if (event == START_ELEMENT) {
 				if (nn(cp) && cpf.isOneOf(TEXT, TEXT_PWS)) {
@@ -452,7 +452,7 @@ public class XmlParserSession extends ReaderParserSession implements RecordReada
 							cp.set(m, null, readAnything(cpcm, cp.getName(), r, m.getBean(false), false, cp));
 						}
 					}
-				} else if (nn(cp) && cpf == ELEMENTS) {
+				} else if (nn(cp) && cpf == FREEFORM) {
 					cp.add(m, null, readAnything(cpcm.getElementType(), cp.getName(), r, m.getBean(false), false, cp));
 				} else {
 					currAttr = getNameProperty(r);
diff --git a/juneau-core/juneau-marshall/src/test/java/org/apache/juneau/AnnotationInheritance_Test.java b/juneau-core/juneau-marshall/src/test/java/org/apache/juneau/AnnotationInheritance_Test.java
index 55576612b1..0d1dde98b1 100644
--- a/juneau-core/juneau-marshall/src/test/java/org/apache/juneau/AnnotationInheritance_Test.java
+++ b/juneau-core/juneau-marshall/src/test/java/org/apache/juneau/AnnotationInheritance_Test.java
@@ -265,7 +265,7 @@ class AnnotationInheritance_Test extends TestBase {
 	public static class G1_Parent {
 		private List<Object> children;
 
-		@Xml(format=XmlFormat.ELEMENTS)
+		@Xml(format=XmlFormat.FREEFORM)
 		@BeanProp(name="c")
 		public List<Object> getChildren() {
 			return children;
@@ -279,7 +279,7 @@ class AnnotationInheritance_Test extends TestBase {
 	}
 
 	public static class G1_Child extends G1_Parent {
-		// This override previously caused "ELEMENTS and ELEMENT properties cannot be mixed" error
+		// This override previously caused "FREEFORM and ELEMENT properties cannot be mixed" error
 		// Now it should work because @MarshalledProp("c") is inherited, keeping the same property name
 		@Override
 		public G1_Child setChildren(List<Object> children) {
diff --git a/juneau-core/juneau-marshall/src/test/java/org/apache/juneau/marshall/xml/BasicXml_Test.java b/juneau-core/juneau-marshall/src/test/java/org/apache/juneau/marshall/xml/BasicXml_Test.java
index c4591d63af..b8f1a3e413 100644
--- a/juneau-core/juneau-marshall/src/test/java/org/apache/juneau/marshall/xml/BasicXml_Test.java
+++ b/juneau-core/juneau-marshall/src/test/java/org/apache/juneau/marshall/xml/BasicXml_Test.java
@@ -1549,7 +1549,7 @@ class BasicXml_Test extends TestBase {
 	public static class BeanWithXmlFormatElementsPropertyCollection {
 		@Xml(format=XmlFormat.ATTR)
 		public String a;
-		@Xml(format=XmlFormat.ELEMENTS)
+		@Xml(format=XmlFormat.FREEFORM)
 		public Object[] b;
 		BeanWithXmlFormatElementsPropertyCollection init() {
 			a = "foo";
diff --git a/juneau-core/juneau-marshall/src/test/java/org/apache/juneau/marshall/xml/InvalidXmlBeans_Test.java b/juneau-core/juneau-marshall/src/test/java/org/apache/juneau/marshall/xml/InvalidXmlBeans_Test.java
index 2516104155..0f5f431a5e 100644
--- a/juneau-core/juneau-marshall/src/test/java/org/apache/juneau/marshall/xml/InvalidXmlBeans_Test.java
+++ b/juneau-core/juneau-marshall/src/test/java/org/apache/juneau/marshall/xml/InvalidXmlBeans_Test.java
@@ -41,22 +41,22 @@ class InvalidXmlBeans_Test extends TestBase {
 		input(
 			"BeanWithAttrFormat",
 			new BeanWithAttrFormat(),
-			"org.apache.juneau.marshall.xml.InvalidXmlBeansTest$BeanWithAttrFormat: Invalid format specified in @Xml annotation on bean: ATTR.  Must be one of the following: DEFAULT,ATTRS,ELEMENTS,VOID"
+			"org.apache.juneau.marshall.xml.InvalidXmlBeansTest$BeanWithAttrFormat: Invalid format specified in @Xml annotation on bean: ATTR.  Must be one of the following: DEFAULT,ATTRS,FREEFORM,VOID"
 		),
 		input(
 			"BeanWithElementFormat",
 			new BeanWithElementFormat(),
-			"org.apache.juneau.marshall.xml.InvalidXmlBeansTest$BeanWithElementFormat: Invalid format specified in @Xml annotation on bean: ELEMENT.  Must be one of the following: DEFAULT,ATTRS,ELEMENTS,VOID"
+			"org.apache.juneau.marshall.xml.InvalidXmlBeansTest$BeanWithElementFormat: Invalid format specified in @Xml annotation on bean: ELEMENT.  Must be one of the following: DEFAULT,ATTRS,FREEFORM,VOID"
 		),
 		input(
 			"BeanWithCollapsedFormat",
 			new BeanWithCollapsedFormat(),
-			"org.apache.juneau.marshall.xml.InvalidXmlBeansTest$BeanWithCollapsedFormat: Invalid format specified in @Xml annotation on bean: COLLAPSED.  Must be one of the following: DEFAULT,ATTRS,ELEMENTS,VOID"
+			"org.apache.juneau.marshall.xml.InvalidXmlBeansTest$BeanWithCollapsedFormat: Invalid format specified in @Xml annotation on bean: COLLAPSED.  Must be one of the following: DEFAULT,ATTRS,FREEFORM,VOID"
 		),
 		input(
 			"BeanWithMixedFormat",
 			new BeanWithMixedFormat(),
-			"org.apache.juneau.marshall.xml.InvalidXmlBeansTest$BeanWithMixedFormat: Invalid format specified in @Xml annotation on bean: MIXED.  Must be one of the following: DEFAULT,ATTRS,ELEMENTS,VOID"
+			"org.apache.juneau.marshall.xml.InvalidXmlBeansTest$BeanWithMixedFormat: Invalid format specified in @Xml annotation on bean: MIXED.  Must be one of the following: DEFAULT,ATTRS,FREEFORM,VOID"
 		),
 		input(
 			"BeanWithMultipleAttrs",
@@ -71,12 +71,12 @@ class InvalidXmlBeans_Test extends TestBase {
 		input(
 			"BeanWithMulipleElements",
 			new BeanWithMulipleElements(),
-			"org.apache.juneau.marshall.xml.InvalidXmlBeansTest$BeanWithMulipleElements: Multiple instances of ELEMENTS properties defined on class.  Only one property can be designated as such."
+			"org.apache.juneau.marshall.xml.InvalidXmlBeansTest$BeanWithMulipleElements: Multiple instances of FREEFORM properties defined on class.  Only one property can be designated as such."
 		),
 		input(
 			"BeanWithWrongElementsType",
 			new BeanWithWrongElementsType(),
-			"org.apache.juneau.marshall.xml.InvalidXmlBeansTest$BeanWithWrongElementsType: Invalid type for ELEMENTS property.  Only properties of type Collection and array can be used."
+			"org.apache.juneau.marshall.xml.InvalidXmlBeansTest$BeanWithWrongElementsType: Invalid type for FREEFORM property.  Only properties of type Collection and array can be used."
 		),
 		input(
 			"BeanWithMulipleMixed",
@@ -91,22 +91,22 @@ class InvalidXmlBeans_Test extends TestBase {
 		input(
 			"BeanWithElementsAndMixed",
 			new BeanWithElementsAndMixed(),
-			"org.apache.juneau.marshall.xml.InvalidXmlBeansTest$BeanWithElementsAndMixed: ELEMENTS and MIXED properties found on the same bean.  Only one property can be designated as such."
+			"org.apache.juneau.marshall.xml.InvalidXmlBeansTest$BeanWithElementsAndMixed: FREEFORM and MIXED properties found on the same bean.  Only one property can be designated as such."
 		),
 		input(
 			"BeanWithElementsAndElement",
 			new BeanWithElementsAndElement(),
-			"org.apache.juneau.marshall.xml.InvalidXmlBeansTest$BeanWithElementsAndElement: ELEMENTS and ELEMENT properties found on the same bean.  These cannot be mixed."
+			"org.apache.juneau.marshall.xml.InvalidXmlBeansTest$BeanWithElementsAndElement: FREEFORM and ELEMENT properties found on the same bean.  These cannot be mixed."
 		),
 		input(
 			"BeanWithElementsAndDefault",
 			new BeanWithElementsAndDefault(),
-			"org.apache.juneau.marshall.xml.InvalidXmlBeansTest$BeanWithElementsAndDefault: ELEMENTS and ELEMENT properties found on the same bean.  These cannot be mixed."
+			"org.apache.juneau.marshall.xml.InvalidXmlBeansTest$BeanWithElementsAndDefault: FREEFORM and ELEMENT properties found on the same bean.  These cannot be mixed."
 		),
 		input(
 			"BeanWithElementsAndCollapsed",
 			new BeanWithElementsAndCollapsed(),
-			"org.apache.juneau.marshall.xml.InvalidXmlBeansTest$BeanWithElementsAndCollapsed: ELEMENTS and COLLAPSED properties found on the same bean.  These cannot be mixed."
+			"org.apache.juneau.marshall.xml.InvalidXmlBeansTest$BeanWithElementsAndCollapsed: FREEFORM and COLLAPSED properties found on the same bean.  These cannot be mixed."
 		),
 		input(
 			"BeanWithChildAndPropNameConflict",
@@ -176,14 +176,14 @@ class InvalidXmlBeans_Test extends TestBase {
 	}
 
 	public static class BeanWithMulipleElements {
-		@Xml(format=XmlFormat.ELEMENTS)
+		@Xml(format=XmlFormat.FREEFORM)
 		public JsonList f1;
-		@Xml(format=XmlFormat.ELEMENTS)
+		@Xml(format=XmlFormat.FREEFORM)
 		public JsonList f2;
 	}
 
 	public static class BeanWithWrongElementsType {
-		@Xml(format=XmlFormat.ELEMENTS)
+		@Xml(format=XmlFormat.FREEFORM)
 		public JsonMap f1;
 	}
 
@@ -202,27 +202,27 @@ class InvalidXmlBeans_Test extends TestBase {
 	}
 
 	public static class BeanWithElementsAndMixed {
-		@Xml(format=XmlFormat.ELEMENTS)
+		@Xml(format=XmlFormat.FREEFORM)
 		public JsonList f1;
 		@Xml(format=XmlFormat.MIXED)
 		public JsonList f2;
 	}
 
 	public static class BeanWithElementsAndElement {
-		@Xml(format=XmlFormat.ELEMENTS)
+		@Xml(format=XmlFormat.FREEFORM)
 		public JsonList f1;
 		@Xml(format=XmlFormat.ELEMENT)
 		public JsonList f2;
 	}
 
 	public static class BeanWithElementsAndDefault {
-		@Xml(format=XmlFormat.ELEMENTS)
+		@Xml(format=XmlFormat.FREEFORM)
 		public JsonList f1;
 		public JsonList f2;
 	}
 
 	public static class BeanWithElementsAndCollapsed {
-		@Xml(format=XmlFormat.ELEMENTS)
+		@Xml(format=XmlFormat.FREEFORM)
 		public JsonList f1;
 		@Xml(format=XmlFormat.COLLAPSED)
 		public JsonList f2;
diff --git a/juneau-core/juneau-marshall/src/test/java/org/apache/juneau/marshall/xml/XmlIgnoreComments_Test.java b/juneau-core/juneau-marshall/src/test/java/org/apache/juneau/marshall/xml/XmlIgnoreComments_Test.java
index bcea130d00..6fc33fb470 100644
--- a/juneau-core/juneau-marshall/src/test/java/org/apache/juneau/marshall/xml/XmlIgnoreComments_Test.java
+++ b/juneau-core/juneau-marshall/src/test/java/org/apache/juneau/marshall/xml/XmlIgnoreComments_Test.java
@@ -1012,7 +1012,7 @@ class XmlIgnoreComments_Test extends TestBase {
 	public static class BeanWithXmlFormatElementsPropertyCollection {
 		@Xml(format=XmlFormat.ATTR)
 		public String a;
-		@Xml(format=XmlFormat.ELEMENTS)
+		@Xml(format=XmlFormat.FREEFORM)
 		public Object[] b;
 		BeanWithXmlFormatElementsPropertyCollection init() {
 			a = "foo";
diff --git a/juneau-core/juneau-marshall/src/test/java/org/apache/juneau/marshall/xml/XmlParserSession_Test.java b/juneau-core/juneau-marshall/src/test/java/org/apache/juneau/marshall/xml/XmlParserSession_Test.java
index 606079f7df..7d532b77ce 100644
--- a/juneau-core/juneau-marshall/src/test/java/org/apache/juneau/marshall/xml/XmlParserSession_Test.java
+++ b/juneau-core/juneau-marshall/src/test/java/org/apache/juneau/marshall/xml/XmlParserSession_Test.java
@@ -33,7 +33,7 @@ import org.junit.jupiter.api.*;
  *  - readIntoMap with non-string key types and duplicate keys (JsonList accumulation)
  *  - readIntoCollection with arrays and varargs
  *  - readAnything error / non-bean fallback / proxy / number / boolean / nil branches
- *  - XmlFormat variants: ATTR, COLLAPSED, TEXT, XMLTEXT, MIXED, ELEMENTS
+ *  - XmlFormat variants: ATTR, COLLAPSED, TEXT, XMLTEXT, MIXED, FREEFORM
  *  - Comments / processing instructions / CDATA inside elements
  *  - Accessors: isPreserveRootElement, isValidating, isWhitespaceElement, getEventAllocator,
  *    getReporter, getResolver, getXmlBeanMeta, getXmlBeanPropertyMeta, getXmlClassMeta
@@ -266,7 +266,7 @@ class XmlParserSession_Test extends TestBase {
 	}
 
 	// -----------------------------------------------------------------------------------------------------------------
-	// i01 - Beans with @Xml format variants (ATTR / COLLAPSED / TEXT / XMLTEXT / MIXED / ELEMENTS)
+	// i01 - Beans with @Xml format variants (ATTR / COLLAPSED / TEXT / XMLTEXT / MIXED / FREEFORM)
 	// -----------------------------------------------------------------------------------------------------------------
 
 	public static class AttrBean {
@@ -328,7 +328,7 @@ class XmlParserSession_Test extends TestBase {
 	public static class ElementsBean {
 		@Xml(format = XmlFormat.ATTR)
 		public String a;
-		@Xml(format = XmlFormat.ELEMENTS)
+		@Xml(format = XmlFormat.FREEFORM)
 		public Object[] b;
 	}
 
diff --git a/juneau-core/juneau-marshall/src/test/java/org/apache/juneau/marshall/xml/XmlSerializerSession_BranchCoverage_Test.java b/juneau-core/juneau-marshall/src/test/java/org/apache/juneau/marshall/xml/XmlSerializerSession_BranchCoverage_Test.java
index aef394935a..914d44ab5e 100644
--- a/juneau-core/juneau-marshall/src/test/java/org/apache/juneau/marshall/xml/XmlSerializerSession_BranchCoverage_Test.java
+++ b/juneau-core/juneau-marshall/src/test/java/org/apache/juneau/marshall/xml/XmlSerializerSession_BranchCoverage_Test.java
@@ -270,7 +270,7 @@ class XmlSerializerSession_BranchCoverage_Test extends TestBase {
 
 	/** Bean with list property annotated as XML elements format. */
 	public static class BeanWithListProp {
-		@Xml(format=XmlFormat.ELEMENTS)
+		@Xml(format=XmlFormat.FREEFORM)
 		public List<String> items = List.of("a", "b", "c");
 	}