Skip to content

Commit

Permalink
Improved: Remove unused ‘StringUtil#appendTo’ methods
Browse files Browse the repository at this point in the history
(OFBIZ-11014)


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1859934 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
mthl committed May 25, 2019
1 parent 047340f commit 008fd8d
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.LinkedList;
Expand All @@ -36,7 +35,6 @@

import org.apache.commons.codec.DecoderException;
import org.apache.commons.codec.binary.Hex;
import org.apache.ofbiz.base.lang.Appender;

/**
* Misc String Utility Functions
Expand Down Expand Up @@ -438,33 +436,6 @@ public static StringWrapper makeStringWrapper(String theString) {
return new StringWrapper(theString);
}

public static StringBuilder appendTo(StringBuilder sb, Iterable<? extends Appender<StringBuilder>> iterable, String prefix, String suffix, String sep) {
return appendTo(sb, iterable, prefix, suffix, null, sep, null);
}

public static StringBuilder appendTo(StringBuilder sb, Iterable<? extends Appender<StringBuilder>> iterable, String prefix, String suffix, String sepPrefix, String sep, String sepSuffix) {
Iterator<? extends Appender<StringBuilder>> it = iterable.iterator();
while (it.hasNext()) {
if (prefix != null) {
sb.append(prefix);
}
it.next().appendTo(sb);
if (suffix != null) {
sb.append(suffix);
}
if (it.hasNext() && sep != null) {
if (sepPrefix != null) {
sb.append(sepPrefix);
}
sb.append(sep);
if (sepSuffix != null) {
sb.append(sepSuffix);
}
}
}
return sb;
}

/**
* A super-lightweight object to wrap a String object. Mainly used with FTL templates
* to avoid the general HTML auto-encoding that is now done through the Screen Widget.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,17 +243,4 @@ public StringBuilder appendTo(StringBuilder sb) {
return sb.append(s);
}
}

public void testAppendTo() {
assertEquals("111", "[1],[2]", StringUtil.appendTo(new StringBuilder(), list(new TestAppender("1"), new TestAppender("2")), "[", "]", ",").toString());
assertEquals("011", "1],2]", StringUtil.appendTo(new StringBuilder(), list(new TestAppender("1"), new TestAppender("2")), null, "]", ",").toString());
assertEquals("101", "[1,[2", StringUtil.appendTo(new StringBuilder(), list(new TestAppender("1"), new TestAppender("2")), "[", null, ",").toString());
assertEquals("110", "[1][2]", StringUtil.appendTo(new StringBuilder(), list(new TestAppender("1"), new TestAppender("2")), "[", "]", null).toString());
assertEquals("11111", "[1]<,>[2]", StringUtil.appendTo(new StringBuilder(), list(new TestAppender("1"), new TestAppender("2")), "[", "]", "<", ",", ">").toString());
assertEquals("01111", "1]<,>2]", StringUtil.appendTo(new StringBuilder(), list(new TestAppender("1"), new TestAppender("2")), null, "]", "<", ",", ">").toString());
assertEquals("10111", "[1<,>[2", StringUtil.appendTo(new StringBuilder(), list(new TestAppender("1"), new TestAppender("2")), "[", null, "<", ",", ">").toString());
assertEquals("11011", "[1],>[2]", StringUtil.appendTo(new StringBuilder(), list(new TestAppender("1"), new TestAppender("2")), "[", "]", null, ",", ">").toString());
assertEquals("11101", "[1][2]", StringUtil.appendTo(new StringBuilder(), list(new TestAppender("1"), new TestAppender("2")), "[", "]", "<", null, ">").toString());
assertEquals("11110", "[1]<,[2]", StringUtil.appendTo(new StringBuilder(), list(new TestAppender("1"), new TestAppender("2")), "[", "]", "<", ",", null).toString());
}
}

0 comments on commit 008fd8d

Please sign in to comment.