blob: e3ea10c6d694b60724b81e8c3b2e974a1d237401 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
package com.android.mail.utils;
import android.support.v4.text.BidiFormatter;
/**
* A small utility class for working with strings.
*/
public class StringUtils {
/**
* Returns a string containing the tokens joined by delimiters.
* Additionally, each token is first passed through {@link BidiFormatter#unicodeWrap(String)}
* before appending to the string.
*/
public static String joinAndBidiFormat(String delimiter, Iterable<String> tokens) {
return joinAndBidiFormat(delimiter, tokens, BidiFormatter.getInstance());
}
/**
* Returns a string containing the tokens joined by delimiters.
* Additionally, each token is first passed through {@link BidiFormatter#unicodeWrap(String)}
* before appending to the string.
*/
public static String joinAndBidiFormat(
String delimiter, Iterable<String> tokens, BidiFormatter bidiFormatter) {
final StringBuilder sb = new StringBuilder();
boolean firstTime = true;
for (String token : tokens) {
if (firstTime) {
firstTime = false;
} else {
sb.append(delimiter);
}
sb.append(bidiFormatter.unicodeWrap(token));
}
return sb.toString();
}
}
|