List of usage examples for org.apache.commons.lang StringUtils rightPad
public static String rightPad(String str, int size)
Right pad a String with spaces (' ').
From source file:org.projectforge.business.fibu.kost.BusinessAssessmentRow.java
@Override public String toString() { return StringUtils.leftPad(getNo(), 4) + " " + StringUtils.rightPad(getTitle(), 20) + " " + StringUtils.leftPad(CurrencyFormatter.format(getAmount()), 18); /*// w ww .j ava 2s .c om * StringBuffer buf = new StringBuffer(); buf.append(row); for (KontoUmsatz umsatz : kontoUmsaetze) { buf.append("\n "); * buf.append(umsatz.toString()); } return buf.toString(); */ }
From source file:org.projectforge.fibu.kost.BusinessAssessment.java
private void asLine(final StringBuffer buf, final String no, final String title, final BigDecimal amount, final int indent, final int scale, final String unit, final boolean html) { if (html == true) { buf.append(" <tr><td>").append(no).append("</td><td class=\"indent-").append(indent).append("\">"); } else {//from w w w. j a va 2s .com buf.append(StringUtils.leftPad(no, 4)); } int length = 25; for (int i = 0; i < indent; i++) { if (html == false) { buf.append(" "); } length--; // One space lost. } if (html == true) { buf.append(HtmlHelper.escapeHtml(StringUtils.defaultString(title), false)).append("</td>"); } else { buf.append(" ").append(StringUtils.rightPad(StringUtils.defaultString(title), length)).append(" "); } if (html == true) { buf.append("<td style=\"text-align: right;\">"); } if (amount != null && amount.compareTo(BigDecimal.ZERO) != 0) { String value; if ("".equals(unit) == true) { value = CurrencyFormatter.format(amount); } else { final NumberFormat format = NumberHelper.getNumberFractionFormat(PFUserContext.getLocale(), scale); value = format.format(amount) + " " + unit; } buf.append(StringUtils.leftPad(value, 18)); } if (html == true) { buf.append("</td></tr>\n"); } else { buf.append("\n"); } }
From source file:org.ralasafe.userType.UserTypeManagerImpl.java
private void preModify(UserType userType) { String xml = getUserMetadataXML(userType); if (xml.length() >= 1000 && xml.length() <= 2000) { xml = StringUtils.rightPad(xml, 4000 - xml.length()); }//from w w w . j a v a2 s. com userType.setUserMetadataXML(xml); }
From source file:org.schimpf.util.Logger.java
/** * Almacena un mensaje de log//w w w . ja v a 2s .c o m * * @author <FONT style='color:#55A; font-size:12px; font-weight:bold;'>Hermann D. Schimpf</FONT> * @author <B>SCHIMPF</B> - <FONT style="font-style:italic;">Sistemas de Información y Gestión</FONT> * @author <B>Schimpf.NET</B> * @version Aug 1, 2012 5:11:07 PM * @param level Nivel del mensaje * @param message Mensaje a mostrar */ public synchronized void log(final Level level, final String message) { // verificamos si alguno esta habilitado if (!level.isEnabled(this.consoleLevel) && !level.isEnabled(this.fileLevel)) // salimos return; // generamos el mensaje final String log = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS") .format(new Date(System.currentTimeMillis())) + " " + StringUtils.rightPad("[" + level.name() + "]", 9) + this.name + " " + message; // verificamos si mostramos en consola if (level.isEnabled(this.consoleLevel)) // verificamos si es >= ERROR if (level.isEnabled(Level.ERROR)) // mostrar el mensaje en consola de error System.err.println(log); else // mostrar el mensaje en consola de error System.out.println(log); // verificamos si mostramos en el fichero if (level.isEnabled(this.fileLevel) && this.logToFile) // escribimos la linea en el fichero this.writeToFile(log); // recorremos los listeners for (final LoggerListener listener : Logger.listeners) // enviamos el mensaje listener.log(this, log.toString(), level, false); }
From source file:org.schimpf.util.Logger.java
/** * Almacena el mensaje de una excepcion en el log * /* www.java 2s . c om*/ * @author <FONT style='color:#55A; font-size:12px; font-weight:bold;'>Hermann D. Schimpf</FONT> * @author <B>HDS Solutions</B> - <FONT style="font-style:italic;">Soluciónes Informáticas</FONT> * @version Oct 1, 2012 12:55:33 PM * @param level Nivel del mensaje * @param exception Excepcion a mostrar */ public synchronized void log(final Level level, final Throwable exception) { // verificamos si alguno esta habilitado if (!level.isEnabled(this.consoleLevel) && !level.isEnabled(this.fileLevel)) // salimos return; // generamos el inicio del mensaje final String logStart = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS") .format(new Date(System.currentTimeMillis())) + " " + StringUtils.rightPad("[" + level.name() + "]", 9) + this.name + " "; // iniciamos el mensaje final StringBuffer log = new StringBuffer(logStart); // agregamos el mensaje de la excepcion log.append(exception.getClass().getName() + (exception.getMessage() != null ? ": " + exception.getMessage() : "")); // recorremos los pasos for (final StackTraceElement stackTrace : exception.getStackTrace()) // agregamos el elemento log.append("\n" + logStart + "\t" + stackTrace.getClassName() + "." + stackTrace.getMethodName() + "(" + stackTrace.getFileName() + ":" + stackTrace.getLineNumber() + ")"); // verificamos si mostramos en consola if (level.isEnabled(this.consoleLevel)) // verificamos si es >= ERROR if (level.isEnabled(Level.ERROR)) // mostrar el mensaje en consola de error System.err.println(log); else // mostrar el mensaje en consola de error System.out.println(log); // verificamos si mostramos en el fichero if (level.isEnabled(this.fileLevel) && this.logToFile) // escribimos la linea en el fichero this.writeToFile(log.toString()); // recorremos los listeners for (final LoggerListener listener : Logger.listeners) // enviamos el mensaje listener.log(this, log.toString(), level, true); }
From source file:org.sonar.batch.profiling.PhasesSumUpTimeProfiler.java
static void println(String text, @Nullable Double percent, AbstractTimeProfiling phaseProfiling) { StringBuilder sb = new StringBuilder(); sb.append(StringUtils.rightPad(text, TEXT_RIGHT_PAD)) .append(StringUtils.leftPad(phaseProfiling.totalTimeAsString(), TIME_LEFT_PAD)); if (percent != null) { sb.append(" (").append((int) (phaseProfiling.totalTime() / percent)).append("%)"); }/*from ww w . ja v a 2 s. c o m*/ println(sb.toString()); }
From source file:org.sonar.plugins.android.lint.AndroidLintRulesDefinitionTest.java
private String getErrorMessage(RulesDefinition.Rule rule, Issue issue) { return StringUtils.rightPad("" + issue.getPriority(), 4) + StringUtils.rightPad(issue.getCategory().getFullName(), 22) + StringUtils.rightPad(SQALE_BY_LINT_CATEGORY.get(issue.getCategory()), 30) + StringUtils.rightPad(rule.key(), 30) + issue.getDescription(Issue.OutputFormat.TEXT); }
From source file:org.springframework.xd.dirt.server.util.BannerUtils.java
/** * Retrieves the ASCII resource "banner.txt" from the classpath. Will also use the version number from * "MANIFEST.MF"./* w w w . ja v a 2 s .co m*/ * * Similar to {@link org.springframework.shell.plugin.support.DefaultBannerProvider}. * * @return String representing the Banner. */ private static String getBanner() { final String banner = readBanner(); final String version = StringUtils.rightPad(BannerUtils.getVersion(), 33); final StringBuilder sb = new StringBuilder(); sb.append(String.format(banner, version)); sb.append(LINE_SEPARATOR); return sb.toString(); }
From source file:org.structr.schema.compiler.NodeExtender.java
public void addClass(final String className, final String content) throws ClassNotFoundException { if (className != null && content != null) { final String packageName = JarConfigurationProvider.DYNAMIC_TYPES_PACKAGE; jfiles.add(new CharSequenceJavaFileObject(className, content)); fqcns.add(packageName.concat(".".concat(className))); if (Settings.LogSchemaOutput.getValue()) { System.out.println(//from w w w . j ava2 s . c o m "########################################################################################################################################################"); int count = 0; for (final String line : content.split("[\\n\\r]{1}")) { System.out.println(StringUtils.rightPad(++count + ": ", 6) + line); } } } }
From source file:org.wildfly.swarm.proc.FailFastComparator.java
@Override public void compare(List<CSVRecord> previous, List<CSVRecord> current) throws ThresholdExceeded { List<ComparisonResult> comparisonResults = new ArrayList<>(); int maxChars = 0; for (CSVRecord prevRecord : previous) { String fileName = prevRecord.get(CSVCollector.SHORT_FILE_NAME_COLUMN); if (fileName.length() > maxChars) maxChars = fileName.length(); CSVRecord matching = findMatching(fileName, current); if (matching != null) { for (Measure measure : criteria) { double prevVal = Double.valueOf(prevRecord.get(measure.column75Percentile())); double currVal = Double.valueOf(matching.get(measure.column75Percentile())); if (currVal > prevVal) { double increasePercentage = currVal * 100 / prevVal; boolean failed = increasePercentage - threshold > 100; String message = StringUtils.rightPad(measure.getShortName(), 10) + " +" + Math.floor(increasePercentage - 100) + "% (" + prevVal + " -> " + currVal + ")"; comparisonResults.add(new ComparisonResult(measure, fileName, failed, message)); } else { double decreasePercentage = prevVal * 100 / currVal; String message = StringUtils.rightPad(measure.getShortName(), 10) + " -" + Math.floor(decreasePercentage - 100) + "% (" + prevVal + " -> " + currVal + ")"; comparisonResults.add(new ComparisonResult(measure, fileName, message)); }/*from w w w. j a v a2 s. c om*/ } } else { System.err.println("No matching record for test " + fileName + ". Skipping ..."); } } // dump results final int pad = maxChars + 2; Collections.sort(comparisonResults, Comparator.comparing(ComparisonResult::getMeasure)); comparisonResults .forEach(r -> System.out.println(StringUtils.rightPad(r.getFile(), pad) + ": " + r.getMessage())); // decide if ThresholdExceeded List<ComparisonResult> failedTests = comparisonResults.stream().filter(r -> !r.isFailure()) .collect(Collectors.toList()); if (failedTests.size() > 0) { System.err.println("There have been test errors. See previous logs for details ..."); throw new ThresholdExceeded( failedTests.size() + " test(s) did exceed the " + this.threshold + "% tolerance."); } }