MCPcopy Create free account
hub / github.com/apache/calcite / replace

Method replace

core/src/main/java/org/apache/calcite/util/Util.java:618–644  ·  view source on GitHub ↗

Replaces every occurrence of find in s with replace .

(
      String s,
      String find,
      String replace)

Source from the content-addressed store, hash-verified

616 * <code>replace</code>.
617 */
618 public static String replace(
619 String s,
620 String find,
621 String replace) {
622 // let's be optimistic
623 int found = s.indexOf(find);
624 if (found == -1) {
625 return s;
626 }
627 StringBuilder sb = new StringBuilder(s.length());
628 int start = 0;
629 for (;;) {
630 for (; start < found; start++) {
631 sb.append(s.charAt(start));
632 }
633 if (found == s.length()) {
634 break;
635 }
636 sb.append(replace);
637 start += find.length();
638 found = s.indexOf(find, start);
639 if (found == -1) {
640 found = s.length();
641 }
642 }
643 return sb.toString();
644 }
645
646 /** Right-pads a string with {@code padChar} until it reaches {@code size}.
647 *

Callers 15

printJavaStringMethod · 0.95
stripDoubleQuotesMethod · 0.95
quoteForJavaMethod · 0.95
toJavaStringMethod · 0.95
build.gradle.ktsFile · 0.45
checkFoodMartAllMethod · 0.45
queryMethod · 0.45
checkQueryMethod · 0.45
addViewMethod · 0.45
valueMethod · 0.45
convertMethod · 0.45
convertMethod · 0.45

Calls 5

charAtMethod · 0.80
indexOfMethod · 0.65
appendMethod · 0.65
toStringMethod · 0.65
lengthMethod · 0.45

Tested by 15

quoteForJavaMethod · 0.76
toJavaStringMethod · 0.76
checkFoodMartAllMethod · 0.36
queryMethod · 0.36
checkQueryMethod · 0.36
acceptMethod · 0.36
checkResultUnorderedMethod · 0.36
assertModelMethod · 0.36
testPlanMethod · 0.36
checkUnionPruningMethod · 0.36
testSortPlanMethod · 0.36