List of usage examples for com.google.common.base Strings repeat
public static String repeat(String string, int count)
From source file:com.brq.wallet.TrezorPinDialog.java
@Override protected void updatePinDisplay() { pinDisp.setText(Strings.repeat("\u25CF ", enteredPin.length())); // Unicode Character 'BLACK CIRCLE' checkPin();/*from www. ja va 2 s.c om*/ }
From source file:com.google.vb2js.VbaJsConverter.java
/** * Generates a single line of output, with comment (if any) at proper * indentation level.// w w w. j a va 2 s.c o m */ private void generateOneLine(String... linePieces) { String jsLine = Joiner.on("").join(linePieces); String comment = ""; if (unit.getCurrentLine().hasComment()) { comment = " // " + unit.getCurrentLine().getComment().trim(); } if (jsLine.isEmpty()) { comment = comment.trim(); } String blanks = Strings.repeat(INDENT_SPACES, unit.getDepth()); generatedOutput.append(blanks); generatedOutput.append(jsLine); generatedOutput.append(comment); generatedOutput.append(ConverterUtil.LINE_SEPARATOR); }
From source file:org.shaf.shell.action.ActionBase.java
/** * This method waits until the process execution is completed. * /*from w w w . ja v a 2s. c o m*/ * <p> * This method performs the following steps: * * <ol> * <li>requests the outcome for initialized job (the job is identified by * its ID);</li> * <li>if the returned outcome represents the execution progress, the * monitor puts itself to sleep and performs the same request again;</li> * <li>if the returned outcome represents the execution result, the monitor * is terminated and result displayed in the terminal;</li> * <li>if the monitor is terminated via shutdown hook, information about * executing job is displayed in the terminal for future references.</li> * </ol> * * @param context * the action context. * @param id * the job ID. * @param wait * if {@code true} then this method will be waiting until the * monitoring job is completed, {@code false} indicates just one * off check. * @return the process execution outcome. * @throws Exception * if an error occurs. */ public OutcomeContent watch(final ActionContext context, final String id, final boolean wait) throws Exception { OutcomeContent outcome = null; StringBuilder info = new StringBuilder(); int lastLength = info.length(); do { outcome = context.getController().getOutcome(id); if (outcome == null) { throw new IllegalArgumentException("no outcome for specified job ID."); } else { if (outcome instanceof ProgressContent) { if (wait) { info = new StringBuilder(); info.append("Job #"); info.append(id); info.append(" - "); info.append(TimeUtils.formatTimeInterval(outcome.getTime())); info.append(' '); info.append(ViewUtils.bar(((ProgressContent) outcome).getProgress())); info.append((info.length() < lastLength) ? Strings.repeat(" ", lastLength - info.length()) : ""); info.append('\r'); lastLength = info.toString().trim().length(); context.show(info); Thread.sleep(context.getConfig().getLong(PROGRESS_CHECK_INTERVAL, 1000L)); } } } } while ((outcome instanceof ProgressContent) && wait); context.show(Strings.repeat(" ", lastLength) + "\r"); return outcome; }
From source file:com.technophobia.substeps.execution.node.ExecutionNode.java
@Override public String toDebugString() { String debugString = Strings.repeat("\t", getDepth()); debugString += "id: " + getId() + ", type: " + getClass().getSimpleName() + ":" + getResult().getResult() + ", description: " + getDescription(); return debugString; }
From source file:com.planet57.gshell.util.cli2.HelpPrinter.java
private static void indent(final PrintWriter out, int i) { out.print(Strings.repeat(" ", i)); }
From source file:com.google.devtools.build.lib.rules.cpp.CppModuleMapAction.java
@Override public DeterministicWriter newDeterministicWriter(ActionExecutionContext ctx) { final ArtifactExpander artifactExpander = ctx.getArtifactExpander(); return new DeterministicWriter() { @Override/*from w w w . j a v a 2 s . com*/ public void writeOutputFile(OutputStream out) throws IOException { StringBuilder content = new StringBuilder(); PathFragment fragment = cppModuleMap.getArtifact().getExecPath(); int segmentsToExecPath = fragment.segmentCount() - 1; // For details about the different header types, see: // http://clang.llvm.org/docs/Modules.html#header-declaration String leadingPeriods = moduleMapHomeIsCwd ? "" : Strings.repeat("../", segmentsToExecPath); content.append("module \"").append(cppModuleMap.getName()).append("\" {\n"); content.append(" export *\n"); HashSet<PathFragment> deduper = new HashSet<>(); for (Artifact artifact : expandedHeaders(artifactExpander, publicHeaders)) { appendHeader(content, "", artifact.getExecPath(), leadingPeriods, /*canCompile=*/ true, deduper); } for (Artifact artifact : expandedHeaders(artifactExpander, privateHeaders)) { appendHeader(content, "private", artifact.getExecPath(), leadingPeriods, /*canCompile=*/ true, deduper); } for (PathFragment additionalExportedHeader : additionalExportedHeaders) { appendHeader(content, "", additionalExportedHeader, leadingPeriods, /*canCompile*/ false, deduper); } for (CppModuleMap dep : dependencies) { content.append(" use \"").append(dep.getName()).append("\"\n"); } content.append("}"); if (externDependencies) { for (CppModuleMap dep : dependencies) { content.append("\nextern module \"").append(dep.getName()).append("\" \"") .append(leadingPeriods).append(dep.getArtifact().getExecPath()).append("\""); } } out.write(content.toString().getBytes(StandardCharsets.ISO_8859_1)); } }; }
From source file:org.onosproject.cli.net.AllocationsCommand.java
private void printAllocation(DeviceId did, PortNumber num, int level) { if (level == 0) { // print DeviceId when Port was directly specified. print("%s", did); }/* ww w.j a v a 2 s.c om*/ DiscreteResourceId resourceId = Resources.discrete(did, num).id(); List<String> portConsumers = resourceService.getResourceAllocations(resourceId).stream() .filter(this::isSubjectToPrint).map(ResourceAllocation::consumerId) .map(AllocationsCommand::asVerboseString).collect(Collectors.toList()); if (portConsumers.isEmpty()) { print("%s%s", Strings.repeat(" ", level), asVerboseString(num)); } else { print("%s%s allocated by %s", Strings.repeat(" ", level), asVerboseString(num), portConsumers); } // FIXME: This workaround induces a lot of distributed store access. // ResourceService should have an API to get all allocations under a parent resource. Set<Class<?>> subResourceTypes = ImmutableSet.<Class<?>>builder().add(OchSignal.class).add(VlanId.class) .add(MplsLabel.class).add(Bandwidth.class).add(TributarySlot.class).build(); for (Class<?> t : subResourceTypes) { resourceService.getResourceAllocations(resourceId, t).stream().filter(a -> isSubjectToPrint(a)) .forEach(a -> print("%s%s allocated by %s", Strings.repeat(" ", level + 1), a.resource().valueAs(Object.class).orElse(""), asVerboseString(a.consumerId()))); } }
From source file:de.brands4friends.daleq.core.internal.formatting.MarkdownTableFormatter.java
private void appendHorizontalHeaderLine(final Appendable appendable, final List<Column> columns) throws IOException { appendSeparator(appendable);//from www .j a va 2 s. co m for (Column column : columns) { if (column.alignment == Alignment.LEFT) { appendAlignmentOperator(appendable); } appendable.append(Strings.repeat("-", column.width + 1)); if (column.alignment == Alignment.RIGHT) { appendAlignmentOperator(appendable); } appendSeparator(appendable); } appendNewline(appendable); }
From source file:com.google.api.explorer.client.parameter.schema.ArraySchemaEditor.java
@Override public void prettyPrint(StringBuilder resultSoFar, int indentation) { resultSoFar.append("\n").append(Strings.repeat(INDENTATION, indentation)).append("["); boolean first = true; for (SchemaEditor editor : editors) { if (!first) { resultSoFar.append(","); }//from w w w . j a va 2 s. c om first = false; editor.prettyPrint(resultSoFar, indentation + 1); } resultSoFar.append("\n").append(Strings.repeat(INDENTATION, indentation)).append("]"); }
From source file:org.kalypso.zml.ui.table.nat.tooltip.ZmlTableTooltip.java
@Override protected String getText(final Event event) { try {//from w w w . j a v a2 s .c om final IZmlModelValueCell cell = findCell(event); if (Objects.isNull(cell)) return null; final IZmlModelColumn column = cell.getColumn(); final AbstractColumnType type = column.getDataColumn().getType(); if (!type.isTooltip()) return null; if (type instanceof DataColumnType) { final String tip1 = getSourceTooltip(cell); final String tip2 = getRuleTooltip(cell); final String tip3 = getModelTooltip(cell); return StringUtilities.concat(tip1, Strings.repeat("\n", 2), tip2, Strings.repeat("\n", 2), tip3); //$NON-NLS-1$ //$NON-NLS-2$ } } catch (final SensorException e) { e.printStackTrace(); } return null; }