Skip to content
Permalink
Browse files

Improved: Inline ‘StringUtil#quoteStrList’ method

(OFBIZ-11014)


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1859924 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
mthl committed May 25, 2019
1 parent 7bd5337 commit b97461e47aa7c2623b516fc981f504c7844db3f8
@@ -139,21 +139,6 @@ public static String join(Collection<?> col, CharSequence delim) {
return splitList;
}

/**
* Encloses each of a List of Strings in quotes.
* @param list List of String(s) to quote.
*/
public static List<String> quoteStrList(List<String> list) {
List<String> tmpList = list;

list = new LinkedList<>();
for (String str: tmpList) {
str = "'" + str + "'";
list.add(str);
}
return list;
}

/**
* Creates a Map from an encoded name/value pair string
* @param str The string to decode and format
@@ -79,11 +79,6 @@ public void testSplit() {
assertEquals("no-sep", list("1", "2", "3", "4", "5", "6"), StringUtil.split("1 2\t3\n4\r5\f6", null));
}

public void testQuoteStrList() {
assertEquals("single", list("'1'"), StringUtil.quoteStrList(list("1")));
assertEquals("double", list("'1'", "'2'"), StringUtil.quoteStrList(list("1", "2")));
}

public void testStrToMap() {
assertNull("null-string", StringUtil.strToMap(null, false));
assertEquals("missing =", Collections.emptyMap(), StringUtil.strToMap("1", false));
@@ -34,6 +34,7 @@
import java.util.Set;
import java.util.UUID;
import java.util.WeakHashMap;
import java.util.stream.Collectors;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
@@ -1549,8 +1550,8 @@ public void renderFormatListWrapperOpen(Appendable writer, Map<String, Object> c
fieldNameList.add(childField.getName());
}
}
columnStyleList = StringUtil.quoteStrList(columnStyleList);
String columnStyleListString = StringUtil.join(columnStyleList, ", ");
String columnStyleListString =
columnStyleList.stream().map(str -> "'" + str + "'").collect(Collectors.joining(", "));
StringWriter sr = new StringWriter();
sr.append("<@renderFormatListWrapperOpen ");
sr.append(" formName=\"");

0 comments on commit b97461e

Please sign in to comment.
You can’t perform that action at this time.