List of usage examples for org.apache.commons.lang StringUtils leftPad
public static String leftPad(String str, int size, String padStr)
Left pad a String with a specified String.
From source file:br.com.nordestefomento.jrimum.utilix.Filler.java
/** * <p>/*from w ww . j a v a2 s .co m*/ * Preenche a String a esquerda com valor do atributo <tt>"fillWith".</tt> * </p> * * @param toFill * Valor a ser preenchido * @param length * tamanho mximo que o valor deve ter depois de preenchido * @return Nova String preenchida de acordo com o preenchedor do objeto at * o tamanho especificado * @since 0.2 */ private String fillLeft(String toFill, int length) { return StringUtils.leftPad(toFill, length, fillWith.toString()); }
From source file:com.enioka.jqm.tools.MiscTest.java
@Test public void testMultiLog() throws Exception { PrintStream out_ini = System.out; PrintStream err_ini = System.err; Helpers.setSingleParam("logFilePerLaunch", "true", em); CreationTools.createJobDef(null, true, "App", null, "jqm-tests/jqm-test-datetimemaven/target/test.jar", TestHelpers.qVip, 42, "MarsuApplication", null, "Franquin", "ModuleMachin", "other", "other", true, em);/*from w w w . j ava 2 s . co m*/ int i = JobRequest.create("MarsuApplication", "TestUser").submit(); addAndStartEngine(); TestHelpers.waitFor(1, 20000, em); String fileName = StringUtils.leftPad("" + i, 10, "0") + ".stdout.log"; File f = new File(FilenameUtils.concat(((MultiplexPrintStream) System.out).rootLogDir, fileName)); Assert.assertEquals(1, TestHelpers.getOkCount(em)); Assert.assertEquals(0, TestHelpers.getNonOkCount(em)); Assert.assertTrue(f.exists()); System.setErr(err_ini); System.setOut(out_ini); }
From source file:de.cismet.cids.custom.objecteditors.utils.VermessungUmleitungPanel.java
/** * DOCUMENT ME!//from w ww .j a va2 s . c o m * * @param link DOCUMENT ME! * * @return DOCUMENT ME! */ private String[] parsePropertiesFromLink(final String link) { final String[] splittedInput = link.split("-"); if (splittedInput.length != 4) { return null; } final String[] res = new String[4]; res[0] = splittedInput[0]; res[1] = splittedInput[1]; res[2] = StringUtils.leftPad(splittedInput[2], 3, '0'); res[3] = StringUtils.leftPad(splittedInput[3], 8, '0'); return res; }
From source file:com.worthsoln.test.web.TestResultTest.java
private void checkGlucoseValues() { // Glucose Values clickLinkWithText("Glucose Values"); assertTextPresent("Enter My Glucose"); assertTextPresent("these results will not be automatically sent to anyone"); Calendar calendar = Calendar.getInstance(); assertSelectOptionPresent("day", String.valueOf(calendar.get(Calendar.DAY_OF_MONTH))); assertSelectOptionPresent("year", String.valueOf(calendar.get(Calendar.YEAR))); assertSelectOptionPresent("hour", StringUtils.leftPad(String.valueOf(calendar.get(Calendar.HOUR_OF_DAY)), 2, "0")); assertSelectOptionPresent("minute", StringUtils.leftPad(String.valueOf(calendar.get(Calendar.MINUTE)), 2, "0")); assertFormElementPresent("patientResultValue1"); assertButtonPresentWithText("Add"); // add//ww w.j a v a 2 s .co m setTextField("patientResultValue1", "200"); submit(); assertTextPresent("you will add these glucose values to your record"); assertButtonPresentWithText("Submit All"); assertButtonPresentWithText("Delete"); // Submit All clickButtonWithText("Submit All"); assertButtonNotPresentWithText("Delete"); setTextField("patientResultValue1", "130"); submit(); assertButtonPresentWithText("Delete"); assertButtonPresentWithText("Submit All"); // Delete clickButtonWithText("Delete"); assertButtonNotPresentWithText("Submit All"); assertTextFieldEquals("patientResultValue1", ""); }
From source file:com.s3d.webapps.util.time.DurationFormatUtils.java
/** * <p>The internal method to do the formatting.</p> * //from w w w . j a va 2 s . com * @param tokens the tokens * @param years the number of years * @param months the number of months * @param days the number of days * @param hours the number of hours * @param minutes the number of minutes * @param seconds the number of seconds * @param milliseconds the number of millis * @param padWithZeros whether to pad * @return the formatted string */ static String format(Token[] tokens, int years, int months, int days, int hours, int minutes, int seconds, int milliseconds, boolean padWithZeros) { StringBuffer buffer = new StringBuffer(); boolean lastOutputSeconds = false; int sz = tokens.length; for (int i = 0; i < sz; i++) { Token token = tokens[i]; Object value = token.getValue(); int count = token.getCount(); if (value instanceof StringBuffer) { buffer.append(value.toString()); } else { if (value == y) { buffer.append(padWithZeros ? StringUtils.leftPad(Integer.toString(years), count, '0') : Integer.toString(years)); lastOutputSeconds = false; } else if (value == M) { buffer.append(padWithZeros ? StringUtils.leftPad(Integer.toString(months), count, '0') : Integer.toString(months)); lastOutputSeconds = false; } else if (value == d) { buffer.append(padWithZeros ? StringUtils.leftPad(Integer.toString(days), count, '0') : Integer.toString(days)); lastOutputSeconds = false; } else if (value == H) { buffer.append(padWithZeros ? StringUtils.leftPad(Integer.toString(hours), count, '0') : Integer.toString(hours)); lastOutputSeconds = false; } else if (value == m) { buffer.append(padWithZeros ? StringUtils.leftPad(Integer.toString(minutes), count, '0') : Integer.toString(minutes)); lastOutputSeconds = false; } else if (value == s) { buffer.append(padWithZeros ? StringUtils.leftPad(Integer.toString(seconds), count, '0') : Integer.toString(seconds)); lastOutputSeconds = true; } else if (value == S) { if (lastOutputSeconds) { milliseconds += 1000; String str = padWithZeros ? StringUtils.leftPad(Integer.toString(milliseconds), count, '0') : Integer.toString(milliseconds); buffer.append(str.substring(1)); } else { buffer.append(padWithZeros ? StringUtils.leftPad(Integer.toString(milliseconds), count, '0') : Integer.toString(milliseconds)); } lastOutputSeconds = false; } } } return buffer.toString(); }
From source file:com.conversantmedia.mapreduce.tool.ToolContext.java
protected void toRowString(StringBuffer sb, String left, String right, int lc, int rc) { sb.append(StringUtils.rightPad(left + ":", lc, '.')); sb.append(StringUtils.leftPad("[" + right + "]", rc, '.')); sb.append("\n"); }
From source file:com.worthsoln.test.web.TestResultTest.java
private void checkWeight() { // Weight/*from w w w . j av a 2 s. c o m*/ clickLinkWithText("Weight"); assertTextPresent("Enter My Weight"); assertTextPresent("If you need advice"); Calendar calendar = Calendar.getInstance(); assertSelectOptionPresent("day", String.valueOf(calendar.get(Calendar.DAY_OF_MONTH))); assertSelectOptionPresent("year", String.valueOf(calendar.get(Calendar.YEAR))); assertSelectOptionPresent("hour", StringUtils.leftPad(String.valueOf(calendar.get(Calendar.HOUR_OF_DAY)), 2, "0")); assertSelectOptionPresent("minute", StringUtils.leftPad(String.valueOf(calendar.get(Calendar.MINUTE)), 2, "0")); assertFormElementPresent("patientResultValue1"); assertButtonPresentWithText("Add"); // add setTextField("patientResultValue1", "180"); submit(); assertTextPresent("you will add these weight values to your record"); assertButtonPresentWithText("Submit All"); assertButtonPresentWithText("Delete"); // Submit All clickButtonWithText("Submit All"); assertButtonNotPresentWithText("Delete"); setTextField("patientResultValue1", "170"); submit(); assertButtonPresentWithText("Delete"); assertButtonPresentWithText("Submit All"); // Delete clickButtonWithText("Delete"); assertButtonNotPresentWithText("Submit All"); assertTextFieldEquals("patientResultValue1", ""); }
From source file:net.bible.service.format.osistohtml.OsisToHtmlSaxHandler.java
private List<String> getStrongsTags(String strongsLemma) { // there may occasionally be more than on ref so split them into a list // of single refs List<String> strongsTags = new ArrayList<String>(); if (commonHandlerData.getParameters().isShowStrongs()) { String[] refList = strongsLemma.split(" "); for (String ref : refList) { // ignore if string doesn't start with "strong;" if (ref.startsWith(OSISUtil.LEMMA_STRONGS) && ref.length() > OSISUtil.LEMMA_STRONGS.length() + 2) { // reduce ref like "strong:H0430" to "H0430" ref = ref.substring(OSISUtil.LEMMA_STRONGS.length()); // select Hebrew or Greek protocol String protocol = null; if (ref.startsWith("H")) { protocol = Constants.HEBREW_DEF_PROTOCOL; } else if (ref.startsWith("G")) { protocol = Constants.GREEK_DEF_PROTOCOL; }//from w w w. j a v a 2 s. co m if (protocol != null) { // remove initial G or H String noPadRef = ref.substring(1); // pad with leading zeros to 5 characters String paddedRef = StringUtils.leftPad(noPadRef, 5, "0"); StringBuilder tag = new StringBuilder(); // create opening tag for Strong's link tag.append("<a href='"); // calculate uri e.g. H:01234 tag.append(protocol).append(":").append(paddedRef); // set css class tag.append("' class='strongs'>"); // descriptive string tag.append(noPadRef); // link closing tag tag.append("</a>"); strongsTags.add(tag.toString()); } } } } return strongsTags; }
From source file:com.worthsoln.test.web.TestResultTest.java
private void checkComment() { // Comment/* www. j a v a 2 s.c om*/ clickLinkWithText("Comment"); assertTextPresent("Enter My Comments"); assertTextPresent("Currently comments are limited to 100 characters."); Calendar calendar = Calendar.getInstance(); assertSelectOptionPresent("day", String.valueOf(calendar.get(Calendar.DAY_OF_MONTH))); assertSelectOptionPresent("year", String.valueOf(calendar.get(Calendar.YEAR))); assertSelectOptionPresent("hour", StringUtils.leftPad(String.valueOf(calendar.get(Calendar.HOUR_OF_DAY)), 2, "0")); assertSelectOptionPresent("minute", StringUtils.leftPad(String.valueOf(calendar.get(Calendar.MINUTE)), 2, "0")); assertFormElementPresent("patientResultValue1"); assertButtonPresentWithText("Add"); // add setTextField("patientResultValue1", "this is test comment!"); submit(); assertTextPresent("this is test comment!"); assertTextPresent("you will add these comments to your record"); assertButtonPresentWithText("Submit All"); assertButtonPresentWithText("Delete"); // Submit All clickButtonWithText("Submit All"); assertButtonNotPresentWithText("Delete"); assertTextNotPresent("this is test comment!"); setTextField("patientResultValue1", "test comment"); submit(); assertButtonPresentWithText("Delete"); assertButtonPresentWithText("Submit All"); // Delete clickButtonWithText("Delete"); assertButtonNotPresentWithText("Submit All"); assertTextFieldEquals("patientResultValue1", ""); }
From source file:com.smartitengineering.event.hub.spi.hbase.HubPersistentStorerImpl.java
protected String leftPadNumberWithZero(long revPlacheholderId) { return StringUtils.leftPad(String.valueOf(revPlacheholderId), MAX_LENGTH, '0'); }