Commit 2a5fa25b authored by Thomas Mortagne's avatar Thomas Mortagne
Browse files

XCOMMONS-2448: Multiline value should not be inlined in the XML serializer

parent 97738e5f
......@@ -77,4 +77,8 @@
void onChildWithDefaultValue(@Name("int") @Default("42") int integer,
@Name("string") @Default("default value") String string, @Name("color") @Default("#ffffff") Color color,
@Name("map") @Default("") Map<String, String> map);
void beginContainerWithMultilineParameter(String multi);
void endContainerWithMultilineParameter(String multi);
}
......@@ -108,6 +108,18 @@ public void onChildWithDefaultValue(int integer, String string, Color color, Map
}
@Override
public void beginContainerWithMultilineParameter(String multiline)
{
}
@Override
public void endContainerWithMultilineParameter(String multiline)
{
}
// Reserved names
@Override
......
......@@ -142,9 +142,12 @@ private void writeInlineParameters(List<Object> parameters, FilterElementDescrip
if (attributeName != null) {
if (parameterValue instanceof String) {
this.xmlStreamWriter.writeAttribute(attributeName, (String) parameterValue);
// Multiline attributes are really not easy to read
if (!((String) parameterValue).contains("\n")) {
this.xmlStreamWriter.writeAttribute(attributeName, (String) parameterValue);
parameters.set(filterParameter.getIndex(), null);
parameters.set(filterParameter.getIndex(), null);
}
} else if (XMLUtils.isSimpleType(typeClass)) {
this.xmlStreamWriter.writeAttribute(attributeName,
this.converter.<String>convert(String.class, parameterValue));
......
......@@ -153,6 +153,13 @@ void containerWithMap() throws Exception
"<containerWithMap><p><_0><entry><string>key</string><int>1</int></entry></_0></p></containerWithMap>");
}
@Test
void containerWithMultilineParameter() throws Exception
{
assertParseAndSerialize("<containerWithMultilineParameter><p><multi>line1\n"
+ "line2</multi></p></containerWithMultilineParameter>");
}
@Test
void customData() throws Exception
{
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment