aQute.lib.strings.Strings Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bnd Show documentation
Show all versions of bnd Show documentation
A command line utility and Ant plugin to wrap, build, or examine bundles.
package aQute.lib.strings;
import java.util.regex.*;
import aQute.lib.collections.*;
public class Strings {
public static String join(String middle, Iterable< ? > objects) {
return join(middle, objects, null, null);
}
public static String join(Iterable< ? > objects) {
return join(",", objects, null, null);
}
public static String join(String middle, Iterable< ? > objects, Pattern pattern, String replace) {
StringBuilder sb = new StringBuilder();
join(sb, middle, objects, pattern, replace);
return sb.toString();
}
public static void join(StringBuilder sb, String middle, Iterable< ? > objects, Pattern pattern, String replace) {
String del = "";
if (objects == null)
return;
for (Object o : objects) {
if (o != null) {
sb.append(del);
String s = o.toString();
if (pattern != null) {
Matcher matcher = pattern.matcher(s);
if (!matcher.matches())
continue;
s = matcher.replaceAll(replace);
}
sb.append(s);
del = middle;
}
}
}
public static String join(String middle, Object[] segments) {
return join(middle, new ExtList
© 2015 - 2024 Weber Informatics LLC | Privacy Policy