( String str, String target, String replacement )
| 297 | |
| 298 | //fast Replace |
| 299 | public static String fastReplace( String str, String target, String replacement ) { |
| 300 | if (str == null) { |
| 301 | return null; |
| 302 | } |
| 303 | int targetLength = target.length(); |
| 304 | if( targetLength == 0 ) { |
| 305 | return str; |
| 306 | } |
| 307 | int idx2 = str.indexOf( target ); |
| 308 | if( idx2 < 0 ) { |
| 309 | return str; |
| 310 | } |
| 311 | StringBuilder sb = new StringBuilder( targetLength > replacement.length() ? str.length() : str.length() * 2 ); |
| 312 | int idx1 = 0; |
| 313 | do { |
| 314 | sb.append( str, idx1, idx2 ); |
| 315 | sb.append( replacement ); |
| 316 | idx1 = idx2 + targetLength; |
| 317 | idx2 = str.indexOf( target, idx1 ); |
| 318 | } while( idx2 > 0 ); |
| 319 | sb.append( str, idx1, str.length() ); |
| 320 | return sb.toString(); |
| 321 | } |
| 322 | //Convert to Mana String |
| 323 | public static String toManaString(String ManaProduced) { |
| 324 | if ("mana".equals(ManaProduced) || ManaProduced.contains("Combo")|| ManaProduced.contains("Any")) |
no test coverage detected