List of usage examples for com.google.common.base Strings repeat
public static String repeat(String string, int count)
From source file:org.apache.servicecomb.samples.apm.impl.output.AbstractOutputGenerator.java
protected static String generateFmt(int leftPad, int keyLen) { return Strings.repeat(" ", leftPad) + "%-" + keyLen + "s: %s\n"; }
From source file:org.opendaylight.yangtools.yang.data.codec.gson.JsonWriterFactory.java
/** * Create a new JsonWriter, which writes to the specified output writer. * * @param writer Output writer/* w w w .j a va 2s. c o m*/ * @param indentSize size of the indent * @return A JsonWriter instance */ public static JsonWriter createJsonWriter(final Writer writer, final int indentSize) { JsonWriter jsonWriter = new JsonWriter(writer); final String indent = Strings.repeat(" ", indentSize); jsonWriter.setIndent(indent); return jsonWriter; }
From source file:com.facebook.presto.sql.parser.TreePrinter.java
private static String treeToString(Tree tree, int depth) { if (tree.getChildCount() == 0) { return quotedString(tree.toString()); }/* w w w.j av a 2 s .c o m*/ StringBuilder sb = new StringBuilder(); sb.append("("); sb.append(tree.toString()); for (Tree t : children(tree)) { if (hasSubtree(t) && (leafCount(tree) > 2)) { sb.append("\n"); sb.append(Strings.repeat(" ", depth)); } else { sb.append(" "); } sb.append(treeToString(t, depth + 1)); } sb.append(")"); return sb.toString(); }
From source file:io.gomint.server.util.DumpUtil.java
private static void dumpNBTTag(NBTTagCompound entity, int depth) { for (Map.Entry<String, Object> stringObjectEntry : entity.entrySet()) { Object obj = stringObjectEntry.getValue(); if (obj instanceof List) { System.out.println(Strings.repeat(" ", depth * 2) + stringObjectEntry.getKey() + ": ["); List v = (List) obj; if (v.size() > 0) { System.out.println(Strings.repeat(" ", (depth + 1) * 2) + "-----------"); }/*w w w. ja v a 2 s . c o m*/ for (Object o : v) { if (o instanceof NBTTagCompound) { dumpNBTTag((NBTTagCompound) o, depth + 1); System.out.println(Strings.repeat(" ", (depth + 1) * 2) + "-----------"); } else { System.out.println(Strings.repeat(" ", (depth + 1) * 2) + o); } } if (v.size() > 0) { System.out.println(Strings.repeat(" ", (depth + 1) * 2) + "-----------"); } System.out.println(Strings.repeat(" ", depth * 2) + "]"); } else if (obj instanceof NBTTagCompound) { System.out.println(Strings.repeat(" ", depth * 2) + stringObjectEntry.getKey() + ": "); dumpNBTTag((NBTTagCompound) obj, depth + 1); } else { System.out.println(Strings.repeat(" ", depth * 2) + stringObjectEntry.getKey() + ": " + obj); } } }
From source file:org.apache.servicecomb.samples.apm.impl.output.AbstractOutputGenerator.java
protected static String generateTimeFmt(int leftPad) { return Strings.repeat(" ", leftPad) + "%-" + (27 - leftPad) + "s: %.3fms\n"; }
From source file:org.raml.utilities.IndentedAppendable.java
public static IndentedAppendable forNoSpaces(int noSpaces, Appendable appendable) { checkArgument(noSpaces >= 0);/*from w w w . ja v a 2 s .co m*/ checkNotNull(appendable); return new IndentedAppendable(Strings.repeat(" ", noSpaces), appendable); }
From source file:org.sosy_lab.cpachecker.util.statistics.StatisticsUtils.java
public static void write(PrintStream target, int indentLevel, int outputNameColWidth, String name, Object value) {/*from w w w . j ava2 s .co m*/ String indentation = Strings.repeat(" ", indentLevel); target.println(String.format("%-" + outputNameColWidth + "s %s", indentation + name + ":", value)); }
From source file:com.github.dirkraft.jash.JasherFormatter.java
public static String bulleted(List<String> messages, int width) { final String bulletLead = " " + BULLET + ' '; final String whitespaceLead = Strings.repeat(" ", bulletLead.length()); StringBuilder sb = new StringBuilder(); for (String message : messages) { BreakIterator boundary = BreakIterator.getLineInstance(); boundary.setText(message);//from www . ja va 2s .c o m StringBuilder line = new StringBuilder(bulletLead); int start = boundary.first(); for (int end = boundary.next(); end != BreakIterator.DONE; start = end, end = boundary.next()) { String token = message.substring(start, end); if (line.length() != 0 && line.length() + token.length() > width) { line.append(NEW_LINE).append(whitespaceLead); sb.append(line); line = new StringBuilder(); } line.append(token); } sb.append(line); } return sb.toString(); }
From source file:squirrels.ircd.commands.Flood.java
@Override public void execute(ParsedMessage command, Session session) { if (session.getMode().contains(REQUIRED_USER_MODE)) { logger.info("Flooding " + session); for (char i = 'A'; i < 'A' + NUM_MESSAGES; i++) { session.receive(session.getIdentity(), "PRIVMSG").add(session.getNick()) .setPayload("{" + Strings.repeat(Character.toString(i), MESSAGE_SIZE - 2) + "}").send(); }/*from www . j a v a 2s . c om*/ } else { session.receive(session.getIdentity(), "PRIVMSG").add(session.getNick()) .setPayload("You do not have a license.").send(); } }
From source file:additionalpipes.item.ItemTeleportTether.java
@SuppressWarnings({ "unchecked", "rawtypes" }) @Override// w ww.j a v a 2s . co m public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean check) { int[] dirs = BlockTeleportTether.getDirectionsForStack(stack); String line = Strings.repeat("X", dirs[3] + 1 + dirs[1]); for (int y = 0; y < dirs[0]; y++) { list.add(line); } list.add(line.substring(0, dirs[3]) + "O" + line.substring(0, dirs[1])); for (int y = 0; y < dirs[2]; y++) { list.add(line); } //list.add(Ints.join(", ", dirs)); //list.add(String.format("%d x %d", dirs[1] + 1 + dirs[3], dirs[0] + 1 + dirs[2])); }