MCPcopy Create free account
hub / github.com/antlr/codebuff / format

Method format

output/java_guava/1.4.13/Preconditions.java:1350–1379  ·  view source on GitHub ↗
(String template, @Nullable Object... args)

Source from the content-addressed store, hash-verified

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

Callers 8

checkArgumentMethod · 0.95
checkStateMethod · 0.95
checkNotNullMethod · 0.95
badElementIndexMethod · 0.95
badPositionIndexMethod · 0.95
badPositionIndexesMethod · 0.95
formatCompact4DigitsMethod · 0.45
verifyMethod · 0.45

Calls 5

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

Tested by

no test coverage detected