List of usage examples for com.google.common.base Strings repeat
public static String repeat(String string, int count)
From source file:com.mattc.argus2.util.Console.java
private static void cause(Throwable t, String details, int depth) { final StackTraceElement[] elements = t.getStackTrace(); final String tabs = Strings.repeat("\t", depth); final String causer = tabs + "===============CAUSED BY==============="; final String separator = tabs + "======================================="; final Throwable cause = t.getCause(); error(causer);/*from w ww . j a v a2s .c om*/ error(tabs + "Exception of type " + t.getClass().getName() + "!"); error(tabs + "Error Message: " + t.getLocalizedMessage()); if (details != null) { error(tabs + String.valueOf(details)); } error(separator); error(tabs + "Stack Trace: "); error(tabs + " " + elements[0]); for (int i = 1; i < elements.length; i++) { error(" " + tabs + "\t" + elements[i]); } if (cause != null) { cause(cause, cause.getLocalizedMessage() + " causing a " + t.getClass().getName(), ++depth); } error(causer); }
From source file:com.google.security.zynamics.binnavi.ZyGraph.Builders.ZyCodeNodeBuilder.java
/** * Inserts the previously created lines into the content with consideration for the comments. * //from w w w .j a v a2 s. co m * @param content The content to which the lines are added. * @param lines The instruction lines to add to the content. * @param comments Information about the instruction comments for each line. * @param maxLineWidth The maximum line width of all instruction lines in characters. */ private static void insertLines(final ZyLabelContent content, final List<Pair<String, List<CStyleRunData>>> lines, final HashMap<Pair<String, List<CStyleRunData>>, ArrayList<CommentContainer>> comments, final int maxLineWidth) { for (final Pair<String, List<CStyleRunData>> lineContent : lines) { final ArrayList<CommentContainer> instructionComments = comments.get(lineContent); final StringBuilder lineBuilder = new StringBuilder(lineContent.first()); final List<CStyleRunData> styleRuns = lineContent.second(); if ((instructionComments == null) || instructionComments.isEmpty()) { final ZyLineContent instructionLine = new ZyLineContent(lineBuilder.toString(), NORMAL_FONT, styleRuns, null); content.addLineContent(instructionLine); continue; } final String instructionFirstCommentLine = instructionComments.get(0).getCommentingString() != null ? instructionComments.get(0).getCommentingString().get(0) : null; if (instructionFirstCommentLine != null) { lineBuilder.append(Strings.repeat(" ", (maxLineWidth - lineBuilder.length()) + 1)); lineBuilder.append(instructionFirstCommentLine); } final ZyLineContent instructionLine = new ZyLineContent(lineBuilder.toString(), NORMAL_FONT, styleRuns, null); if (instructionFirstCommentLine != null) { instructionLine.setFont(maxLineWidth + 1, instructionFirstCommentLine.length(), ITALIC_FONT); instructionLine.setTextColor(maxLineWidth + 1, instructionFirstCommentLine.length(), Color.BLACK); instructionLine.setTextColor(maxLineWidth + 1, instructionComments.get(0).getCommentUserNameLength(), instructionComments.get(0).getCommentColor()); } content.addLineContent(instructionLine); boolean firstCommentContainer = true; for (final CommentContainer commentContainer : instructionComments) { boolean firstCommentLine = true; for (final String partialCommentString : commentContainer.getCommentingString()) { if (firstCommentContainer) { firstCommentContainer = false; continue; } final ZyLineContent commentLine = new ZyLineContent( Strings.repeat(" ", maxLineWidth + 1) + partialCommentString, ITALIC_FONT, null); commentLine.setTextColor(Color.BLACK); if (firstCommentLine) { firstCommentLine = false; commentLine.setTextColor(maxLineWidth + 1, commentContainer.getCommentUserNameLength(), commentContainer.getCommentColor()); } content.addLineContent(commentLine); } } } }
From source file:org.sonatype.nexus.proxy.walker.ParentOMatic.java
protected void dump(final Node<Payload> node, final int depth, final StringBuilder sb) { sb.append(Strings.repeat(" ", depth)); sb.append(node.getLabel());/* w ww . j a va 2 s . co m*/ sb.append(" (").append(node.getPath()).append(")"); if (node.getPayload().isMarked()) { sb.append("*"); } sb.append("\n"); for (Node<Payload> child : node.getChildren()) { dump(child, depth + 1, sb); } }
From source file:com.facebook.presto.cli.Query.java
private static void renderErrorLocation(String query, ErrorLocation location, PrintStream out) { List<String> lines = ImmutableList.copyOf(Splitter.on('\n').split(query).iterator()); String errorLine = lines.get(location.getLineNumber() - 1); String good = errorLine.substring(0, location.getColumnNumber() - 1); String bad = errorLine.substring(location.getColumnNumber() - 1); if ((location.getLineNumber() == lines.size()) && bad.trim().isEmpty()) { bad = " <EOF>"; }/* ww w . j a v a 2s . c o m*/ if (REAL_TERMINAL) { Ansi ansi = Ansi.ansi(); ansi.fg(Ansi.Color.CYAN); for (int i = 1; i < location.getLineNumber(); i++) { ansi.a(lines.get(i - 1)).newline(); } ansi.a(good); ansi.fg(Ansi.Color.RED); ansi.a(bad).newline(); for (int i = location.getLineNumber(); i < lines.size(); i++) { ansi.a(lines.get(i)).newline(); } ansi.reset(); out.print(ansi); } else { String prefix = format("LINE %s: ", location.getLineNumber()); String padding = Strings.repeat(" ", prefix.length() + (location.getColumnNumber() - 1)); out.println(prefix + errorLine); out.println(padding + "^"); } }
From source file:com.gnapse.metric.NumberFormatter.java
private DecimalFormat createExponentFormat() { final DecimalFormatSymbols symbols = DecimalFormatSymbols.getInstance(this.locale); symbols.setExponentSeparator(DEFAULT_EXPONENT_SEPARATOR); final DecimalFormat format = (DecimalFormat) NumberFormat.getNumberInstance(this.locale); final String pattern = String.format("#.%sE0#", Strings.repeat("#", MAX_FRACTION_DIGITS)); format.setDecimalFormatSymbols(symbols); format.applyPattern(pattern);/*from ww w . jav a2s.c o m*/ return format; }
From source file:com.b2international.snowowl.server.console.MaintenanceCommandProvider.java
private void printSeparator(final CommandInterpreter interpreter, int length) { interpreter.println(Strings.repeat("-", length)); }
From source file:org.sosy_lab.cpachecker.cpa.smg.SMGExplicitPlotter.java
private String newLineWithOffset(String pLine) { return Strings.repeat(" ", offset) + pLine + "\n"; }
From source file:com.facebook.presto.sql.planner.planPrinter.TextRenderer.java
static String indentString(int indent) { return Strings.repeat(" ", indent); }
From source file:kn.uni.gis.ui.GameVectorLayer.java
private static Style createStyle(int color, int stroke) { Style vaadinColors = new Style(); String hexString = Integer.toHexString(color); String prefix = "#" + Strings.repeat("0", 6 - hexString.length()); vaadinColors.setStrokeColor(prefix + hexString); vaadinColors.setFillColor(prefix + hexString); vaadinColors.setFillOpacity(0.4);// ww w .j ava 2 s . c o m vaadinColors.setStrokeWidth(stroke); return vaadinColors; }
From source file:org.eclipse.xtext.formatting2.debug.TextRegionAccessToString.java
protected String indent(int indentation) { if (hideIndentation) return ""; return Strings.repeat(" ", indentation); }