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

Method format

corpus/java/training/guava/base/Preconditions.java:1279–1309  ·  view source on GitHub ↗
(String template, @Nullable Object... args)

Source from the content-addressed store, hash-verified

1277 */
1278 // Note that this is somewhat-improperly used from Verify.java as well.
1279 static String format(String template, @Nullable Object... args) {
1280 template = String.valueOf(template); // null -> "null"
1281
1282 // start substituting the arguments into the '%s' placeholders
1283 StringBuilder builder = new StringBuilder(template.length() + 16 * args.length);
1284 int templateStart = 0;
1285 int i = 0;
1286 while (i < args.length) {
1287 int placeholderStart = template.indexOf("%s", templateStart);
1288 if (placeholderStart == -1) {
1289 break;
1290 }
1291 builder.append(template, templateStart, placeholderStart);
1292 builder.append(args[i++]);
1293 templateStart = placeholderStart + 2;
1294 }
1295 builder.append(template, templateStart, template.length());
1296
1297 // if we run out of placeholders, append the extra args in square braces
1298 if (i < args.length) {
1299 builder.append(" [");
1300 builder.append(args[i++]);
1301 while (i < args.length) {
1302 builder.append(", ");
1303 builder.append(args[i++]);
1304 }
1305 builder.append(']');
1306 }
1307
1308 return builder.toString();
1309 }
1310}

Callers 15

checkArgumentMethod · 0.95
checkStateMethod · 0.95
checkNotNullMethod · 0.95
badElementIndexMethod · 0.95
badPositionIndexMethod · 0.95
badPositionIndexesMethod · 0.95
newDataOutputMethod · 0.45
formatCompact4DigitsMethod · 0.45
verifyMethod · 0.45
hmacToStringMethod · 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