| 1 | package net.sourceforge.retroweaver.runtime.java.lang; |
| 2 | |
| 3 | import java.util.regex.Pattern; |
| 4 | |
| 5 | import net.sourceforge.retroweaver.runtime.java.util.Formatter; |
| 6 | |
| 7 | public class String_ { |
| 8 | |
| 9 | private String_() { |
| 10 | // private constructor |
| 11 | } |
| 12 | |
| 13 | public static String replace(String s, CharSequence target, |
| 14 | CharSequence replacement) { |
| 15 | if (target == null || replacement == null) { |
| 16 | throw new NullPointerException(); |
| 17 | } |
| 18 | |
| 19 | Pattern p = Pattern.compile(target.toString(), Pattern.LITERAL); |
| 20 | |
| 21 | return p.matcher(s).replaceAll(replacement.toString()); |
| 22 | } |
| 23 | |
| 24 | public static String format(String s, Object... params) { |
| 25 | return new Formatter().format(s, params).toString(); |
| 26 | } |
| 27 | |
| 28 | public static boolean contains(String s, CharSequence seq) { |
| 29 | if (seq == null) { |
| 30 | throw new NullPointerException(); |
| 31 | } |
| 32 | return s.indexOf(seq.toString()) != -1; |
| 33 | } |
| 34 | |
| 35 | } |