MCPcopy Index your code
hub / github.com/antlr/codebuff / format

Method format

output/java_guava/1.4.17/Preconditions.java:1351–1380  ·  view source on GitHub ↗
(String template, @Nullable Object... args)

Source from the content-addressed store, hash-verified

1349
1350
1351 static String format(String template, @Nullable Object... args) {
1352 template = String.valueOf(template); // null -> "null"
1353
1354 // start substituting the arguments into the '%s' placeholders
1355 StringBuilder builder = new StringBuilder(template.length() + 16 * args.length);
1356 int templateStart = 0;
1357 int i = 0;
1358 while (i < args.length) {
1359 int placeholderStart = template.indexOf("%s", templateStart);
1360 if (placeholderStart == -1) {
1361 break;
1362 }
1363 builder.append(template, templateStart, placeholderStart);
1364 builder.append(args[i++]);
1365 templateStart = placeholderStart + 2;
1366 }
1367 builder.append(template, templateStart, template.length());
1368
1369 // if we run out of placeholders, append the extra args in square braces
1370 if (i < args.length) {
1371 builder.append(" [");
1372 builder.append(args[i++]);
1373 while (i < args.length) {
1374 builder.append(", ");
1375 builder.append(args[i++]);
1376 }
1377 builder.append(']');
1378 }
1379 return builder.toString();
1380 }
1381}

Callers 15

checkArgumentMethod · 0.95
checkStateMethod · 0.95
checkNotNullMethod · 0.95
badElementIndexMethod · 0.95
badPositionIndexMethod · 0.95
badPositionIndexesMethod · 0.95
hmacToStringMethod · 0.45
toStringMethod · 0.45
toStringMethod · 0.45
toStringMethod · 0.45
toStringMethod · 0.45

Calls 5

toStringMethod · 0.65
valueOfMethod · 0.45
lengthMethod · 0.45
indexOfMethod · 0.45
appendMethod · 0.45

Tested by 1

newDataOutputMethod · 0.36