List of usage examples for org.apache.commons.lang3 StringUtils rightPad
public static String rightPad(final String str, final int size)
Right pad a String with spaces (' ').
The String is padded to the size of size .
StringUtils.rightPad(null, *) = null StringUtils.rightPad("", 3) = " " StringUtils.rightPad("bat", 3) = "bat" StringUtils.rightPad("bat", 5) = "bat " StringUtils.rightPad("bat", 1) = "bat" StringUtils.rightPad("bat", -1) = "bat"
From source file:org.languagetool.dev.eval.SimpleCorpusEvaluator.java
public static void main(String[] args) throws IOException { if (args.length != 2) { System.out.println(/*from w w w . j a v a 2s. c om*/ "Usage: " + SimpleCorpusEvaluator.class.getSimpleName() + " <corpusFile> <languageModelDir>"); System.out.println( " <languageModelDir> is a Lucene index directory with ngram frequency information (use comma but not space to specify more than one)"); System.exit(1); } File inputFile = new File(args[0]); List<File> indexDirs = Arrays.stream(args[1].split(",")).map(File::new).collect(Collectors.toList()); System.out.println("Running with language model from " + indexDirs); SimpleCorpusEvaluator evaluator = new SimpleCorpusEvaluator(indexDirs.toArray(new File[] {})); List<String> results = new ArrayList<>(); System.out.println("Output explanation:"); System.out.println(" [ ] = this is not an expected error"); System.out.println(" [+ ] = this is an expected error"); System.out.println(" [++] = this is an expected error and the first suggestion is correct"); System.out.println(" [//] = not counted because already matches by a different rule"); double threshold = START_THRESHOLD; while (threshold >= END_THRESHOLD) { System.out.println("=====================================================" + "===================================================== " + threshold); PrecisionRecall res = evaluator.run(inputFile, threshold); //String thresholdStr = String.format(Locale.ENGLISH, "%.20f", threshold); String thresholdStr = StringUtils.rightPad(String.valueOf(threshold), 22); double fMeasure = FMeasure.getFMeasure(res.getPrecision(), res.getRecall(), 1.0f); String fMeasureStr = String.format(Locale.ENGLISH, "%.3f", fMeasure); String precision = String.format(Locale.ENGLISH, "%.3f", res.getPrecision()); String recall = String.format(Locale.ENGLISH, "%.3f", res.getRecall()); results.add(thresholdStr + ": f=" + fMeasureStr + ", precision=" + precision + ", recall=" + recall); threshold = threshold * STEP_FACTOR; } System.out.println("=== Results: =================================="); for (String result : results) { System.out.println(result); } evaluator.close(); }
From source file:org.mrgeo.cmd.MrGeo.java
/** * Print generic usage to std out./*from www.j av a2 s. com*/ */ private static void usage() { System.out.println("Usage: mrgeo COMMAND"); System.out.println(" where command is one of:"); int maxLen = 0; for (String name : commands.keySet()) { maxLen = Math.max(maxLen, name.length()); } for (Map.Entry<String, CommandSpi> cmd : commands.entrySet()) { String name = cmd.getKey(); System.out.println(" " + StringUtils.rightPad(name, maxLen + 2) + cmd.getValue().getDescription()); } System.out.println("Generic options supported are:"); new HelpFormatter().printHelp("command <options>", createOptions()); }
From source file:org.nchadoop.ui.listbox.Displayable.java
public String formatDisplayText(final int width, final long maximumSize) { final String readableSize = StringUtils.leftPad(Utils.readableFileSize(this.size), 10); final String guage = createGuage(this.size, maximumSize); return StringUtils.rightPad(MessageFormat.format("{0} {1} {2}", readableSize, guage, this.name), width); }
From source file:org.nchadoop.ui.listbox.Displayable.java
private String createGuage(final long size, final long largest) { if (size < 0) return " "; final int length = (int) Math.round(((double) size) / largest * 10); return "[" + StringUtils.rightPad("##########".substring(0, length), 10) + "]"; }
From source file:org.openbaton.cli.util.PrintFormat.java
public static String printer() { StringBuilder buf = new StringBuilder(); int[] colWidths = colWidths(); for (String[] row : rows) { for (int colNum = 0; colNum < row.length; colNum++) { buf.append(StringUtils.rightPad(StringUtils.defaultString(row[colNum]), colWidths[colNum])); buf.append(' '); }//from w w w . j a v a2s .co m buf.append('\n'); } return buf.toString(); }
From source file:org.opencb.opencga.app.cli.analysis.executors.VariantCommandExecutor.java
private void samples() throws Exception { VariantCommandOptions.VariantSamplesFilterCommandOptions cliOptions = variantCommandOptions.samplesFilterCommandOptions; // Map<Long, String> studyIds = getStudyIds(sessionId); Query query = VariantQueryCommandUtils.parseBasicVariantQuery(cliOptions.variantQueryOptions, new Query()); VariantStorageManager variantManager = new VariantStorageManager(catalogManager, storageEngineFactory); VariantSampleFilter variantSampleFilter = new VariantSampleFilter(variantManager.iterable(sessionId)); if (StringUtils.isNotEmpty(cliOptions.samples)) { query.append(VariantDBAdaptor.VariantQueryParams.RETURNED_SAMPLES.key(), Arrays.asList(cliOptions.samples.split(","))); }//from w w w . ja va 2 s .com if (StringUtils.isNotEmpty(cliOptions.study)) { query.append(VariantDBAdaptor.VariantQueryParams.STUDIES.key(), cliOptions.study); } List<String> genotypes = Arrays.asList(cliOptions.genotypes.split(",")); if (cliOptions.all) { Collection<String> samplesInAllVariants = variantSampleFilter.getSamplesInAllVariants(query, genotypes); System.out.println("##Samples in ALL variants with genotypes " + genotypes); for (String sample : samplesInAllVariants) { System.out.println(sample); } } else { Map<String, Set<Variant>> samplesInAnyVariants = variantSampleFilter.getSamplesInAnyVariants(query, genotypes); System.out.println("##Samples in ANY variants with genotypes " + genotypes); Set<Variant> variants = new TreeSet<>((v1, o2) -> v1.getStart().compareTo(o2.getStart())); samplesInAnyVariants.forEach((sample, v) -> variants.addAll(v)); System.out.print(StringUtils.rightPad("#SAMPLE", 10)); // System.out.print("|"); for (Variant variant : variants) { System.out.print(StringUtils.center(variant.toString(), 15)); // System.out.print("|"); } System.out.println(); samplesInAnyVariants.forEach((sample, v) -> { System.out.print(StringUtils.rightPad(sample, 10)); // System.out.print("|"); for (Variant variant : variants) { if (v.contains(variant)) { System.out.print(StringUtils.center("X", 15)); } else { System.out.print(StringUtils.center("-", 15)); } // System.out.print("|"); } System.out.println(); }); } }
From source file:org.paxml.selenium.rc.FormattingUtils.java
/** * Concatenates strings./* w ww . j a va2s. com*/ * * @param size * Size to pad * @param strings * Strings. * @return String */ public static String concatDescription(int size, String... strings) { StringBuilder builder = new StringBuilder(); for (String string : strings) { if (string != null) { builder.append(StringUtils.rightPad(string, size)); } } return builder.toString(); }
From source file:org.pepstock.jem.node.JobLogManager.java
/** * Prints steps information after the end of execution of each step. * /* www .j a va 2 s . co m*/ * @param job job instance * @param step step ended */ public static void printStepResult(Job job, Step step) { // JOBNAME STEPNAME RC CPU (ms) I/O (counts) MEMORY (mb) " // 1234567890123456 1234567890123456 1234 1234567890 1234567890123456 // 1234567890123456 // Sigar sigar = new Sigar(); SigarProxy proxy = SigarProxyCache.newInstance(sigar, 0); StringBuilder sb = new StringBuilder(); if (step == null) { sb.append(StringUtils.rightPad("[init]", 24)); sb.append(' ').append(StringUtils.rightPad("-", 4)); } else { // if name of step more than 24 chars // cut the name adding "..." as to be continued if (step.getName().length() > 24) { sb.append(StringUtils.rightPad(StringUtils.left(step.getName(), 21), 24, ".")); } else { sb.append(StringUtils.rightPad(step.getName(), 24)); } sb.append(' ').append(StringUtils.rightPad(String.valueOf(step.getReturnCode()), 4)); } // parse process id because the form is pid@hostname String pid = job.getProcessId(); String id = pid.substring(0, pid.indexOf('@')); // extract, using SIGAR, CPU consumed by step, N/A otherwise try { // calculate cpu used on the step. // Sigar gives total amount of cpu of process so a difference with // previous one is mandatory long cpu = proxy.getProcCpu(id).getTotal() - PREVIOUS_CPU; sb.append(' ').append(StringUtils.rightPad(String.valueOf(cpu), 10)); // saved for next step PREVIOUS_CPU = cpu; } catch (SigarException e) { // debug LogAppl.getInstance().debug(e.getMessage(), e); sb.append(' ').append(StringUtils.rightPad("N/A", 10)); } // extract, using SIGAR, memory currently used by step, N/A otherwise try { sb.append(' ') .append(StringUtils.rightPad(String.valueOf(proxy.getProcMem(id).getResident() / 1024), 10)); } catch (SigarException e) { // debug LogAppl.getInstance().debug(e.getMessage(), e); sb.append(' ').append(StringUtils.rightPad("N/A", 10)); } Main.getOutputSystem().writeJobLog(job, sb.toString()); sigar.close(); SigarProxyCache.clear(proxy); }
From source file:org.structr.common.CaseHelper.java
/** * Test method./*from w ww.j a v a2 s. co m*/ */ public static void main(String[] args) { String[] input = { "check_ins", "CheckIns", "blog_entry", "BlogEntry", "blog_entries", "BlogEntries", "blogentry", "blogentries" }; for (int i = 0; i < input.length; i++) { System.out.println( StringUtils.rightPad(input[i], 20) + StringUtils.leftPad(toUpperCamelCase(input[i]), 20) + StringUtils.leftPad(toUnderscore(input[i], true), 20) + StringUtils.leftPad(toUnderscore(input[i], false), 20)); } }
From source file:org.structr.console.rest.HelpRestCommand.java
@Override public void run(final Console console, final Writable writable) throws FrameworkException, IOException { if (subCommand != null) { final RestCommand cmd = RestCommand.getCommand(subCommand); if (subCommand != null) { cmd.detailHelp(writable);//from w w w . j a v a 2 s.c o m } else { writable.println("Unknown command '" + subCommand + "'."); } } else { for (final String key : RestCommand.commandNames()) { final RestCommand cmd = RestCommand.getCommand(key); writable.print(StringUtils.rightPad(key, 10)); writable.print(" - "); cmd.commandHelp(writable); } } }