MCPcopy Create free account
hub / github.com/cschanck/single-file-java / center

Method center

src/main/java/org/sfj/SimpleFSM.java:330–341  ·  view source on GitHub ↗
(String text, int total)

Source from the content-addressed store, hash-verified

328 }
329
330 private static String center(String text, int total) {
331 int skip = (total - text.length()) / 2;
332 int rem = total - skip - text.length();
333 if (rem > 0 && skip > 0) {
334 return String.format("%" + skip + "s%s%" + rem + "s", "", text, "");
335 } else if (rem > 0) {
336 return String.format("%s%" + rem + "s", text, "");
337 } else if (skip > 0) {
338 return String.format("%" + skip + "s%s", "", text);
339 }
340 return text;
341 }
342
343 /**
344 * Shutdown this FSM. Does not take lock; clears all records states,

Callers 1

dumpFSMMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected