List of usage examples for org.apache.commons.lang3 StringUtils leftPad
public static String leftPad(final String str, final int size, String padStr)
Left pad a String with a specified String.
Pad to a size of size .
StringUtils.leftPad(null, *, *) = null StringUtils.leftPad("", 3, "z") = "zzz" StringUtils.leftPad("bat", 3, "yz") = "bat" StringUtils.leftPad("bat", 5, "yz") = "yzbat" StringUtils.leftPad("bat", 8, "yz") = "yzyzybat" StringUtils.leftPad("bat", 1, "yz") = "bat" StringUtils.leftPad("bat", -1, "yz") = "bat" StringUtils.leftPad("bat", 5, null) = " bat" StringUtils.leftPad("bat", 5, "") = " bat"
From source file:org.brickhouse.datatype.HTime.java
@Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(StringUtils.leftPad(Integer.toString(hour), 2, '0')); sb.append(':'); sb.append(StringUtils.leftPad(Integer.toString(minute), 2, '0')); sb.append(':'); sb.append(StringUtils.leftPad(Integer.toString(second), 2, '0')); if (ms != 0) { sb.append('.'); String millis = StringUtils.leftPad(Integer.toString(ms), 3, '0'); int len = 3; while (millis.charAt(len - 1) == '0') len--;/*from w ww . j a va2 s . c om*/ sb.append(millis.substring(0, len)); } return sb.toString(); }
From source file:org.broadleafcommerce.common.util.TableCreator.java
public TableCreator addSeparator() { sb.append(StringUtils.leftPad("", rowWidth, '-')).append("\r\n"); return this; }
From source file:org.cristalise.lookup.LookupPropertySearchTest.java
@Test public void searchByProperty_paged() throws Exception { List<DomainPath> expecteds = new ArrayList<>(); for (int i = 0; i < 35; i++) { ItemPath ip = new ItemPath(UUID.randomUUID()); DomainPath dp = new DomainPath("paged/item" + StringUtils.leftPad("" + i, 2, "0"), ip); lookup.add(ip);/*from ww w. ja va 2s . c om*/ lookup.add(dp); lookupPropertiesField.put(lookupContextField, ip.getUUID(), propType); expecteds.add(dp); } PagedResult actuals; for (int i = 0; i < 3; i++) { actuals = lookup.search(new DomainPath("paged"), Arrays.asList(propType), i * 10, 10); assertEquals(35, actuals.maxRows); assertReflectionEquals(expecteds.subList(i * 10, i * 10 + 10), actuals.rows, LENIENT_ORDER); } actuals = lookup.search(new DomainPath("paged"), Arrays.asList(propType), 0, 10); assertEquals(35, actuals.maxRows); assertReflectionEquals(expecteds.subList(0, 10), actuals.rows, LENIENT_ORDER); }
From source file:org.cristalise.lookup.LookupRoleTest.java
@Test public void getAgentsPaged() throws Exception { List<Path> expecteds = new ArrayList<>(); RolePath paged = new RolePath(new RolePath(), "paged"); lookup.add(paged);/*from w ww. j a v a 2 s. c o m*/ for (int i = 0; i < 35; i++) { AgentPath ap = new AgentPath(UUID.randomUUID(), "agent" + StringUtils.leftPad("" + i, 2, "0")); lookup.add(ap); lookup.addRole(ap, paged); expecteds.add(ap); } PagedResult actuals = null; for (int i = 0; i < 3; i++) { actuals = lookup.getAgents(paged, i * 10, 10); assertReflectionEquals(expecteds.subList(i * 10, i * 10 + 10), actuals.rows); assertEquals(expecteds.size(), actuals.maxRows); } actuals = lookup.getAgents(paged, 30, 10); assertReflectionEquals(expecteds.subList(30, 35), actuals.rows); assertEquals(expecteds.size(), actuals.maxRows); }
From source file:org.cristalise.lookup.LookupRoleTest.java
@Test public void addRolesOfAgentPaged() throws Exception { AgentPath paged = new AgentPath(new ItemPath(), "paged"); lookup.add(paged);/*from w ww. j a v a2s. c om*/ List<Path> expecteds = new ArrayList<>(); for (int i = 0; i < 35; i++) { RolePath rp = new RolePath(new RolePath(), "paged" + StringUtils.leftPad("" + i, 2, "0")); lookup.add(rp); lookup.addRole(paged, rp); expecteds.add(rp); } PagedResult actuals = null; for (int i = 0; i < 3; i++) { actuals = lookup.getRoles(paged, i * 10, 10); assertReflectionEquals(expecteds.subList(i * 10, i * 10 + 10), actuals.rows); assertEquals(expecteds.size(), actuals.maxRows); } actuals = lookup.getRoles(paged, 30, 10); assertReflectionEquals(expecteds.subList(30, 35), actuals.rows); assertEquals(expecteds.size(), actuals.maxRows); }
From source file:org.cristalise.lookup.LookupSearchTest.java
@Test public void getChildrenPaged_DomainPath() throws Exception { List<Path> expecteds = new ArrayList<>(); for (int i = 0; i < 35; i++) { DomainPath dp = new DomainPath("paged/child" + StringUtils.leftPad("" + i, 2, "0")); lookup.add(dp);// w ww .j a v a 2 s. co m expecteds.add(dp); } PagedResult actuals = null; for (int i = 0; i < 3; i++) { actuals = lookup.getChildren(new DomainPath("paged"), i * 10, 10); assertReflectionEquals(expecteds.subList(i * 10, i * 10 + 10), actuals.rows, LENIENT_ORDER); assertEquals(35, actuals.maxRows); } actuals = lookup.getChildren(new DomainPath("paged"), 30, 10); assertReflectionEquals(expecteds.subList(30, 35), actuals.rows, LENIENT_ORDER); assertEquals(35, actuals.maxRows); }
From source file:org.cristalise.lookup.LookupSearchTest.java
@Test public void getChildrenPaged_RolePath() throws Exception { List<Path> expecteds = new ArrayList<>(); RolePath paged = new RolePath(new RolePath(), "paged"); lookup.add(paged);/* w ww . j a va2 s . c o m*/ for (int i = 0; i < 35; i++) { RolePath rp = new RolePath(paged, "child" + StringUtils.leftPad("" + i, 2, "0")); lookup.add(rp); expecteds.add(rp); } PagedResult actuals = null; for (int i = 0; i < 3; i++) { actuals = lookup.getChildren(paged, i * 10, 10); assertReflectionEquals(expecteds.subList(i * 10, i * 10 + 10), actuals.rows, LENIENT_ORDER); assertEquals(35, actuals.maxRows); } actuals = lookup.getChildren(paged, 30, 10); assertReflectionEquals(expecteds.subList(30, 35), actuals.rows, LENIENT_ORDER); assertEquals(35, actuals.maxRows); }
From source file:org.cristalise.lookup.LookupSearchTest.java
@Test public void searchAliasesPaged() throws Exception { ItemPath ip = new ItemPath(UUID.randomUUID()); lookup.add(ip);/*from www. ja va 2s . c om*/ List<Path> expecteds = new ArrayList<>(); for (int i = 0; i < 35; i++) { DomainPath dp = new DomainPath("paged/child" + StringUtils.leftPad("" + i, 2, "0"), ip); lookup.add(dp); expecteds.add(dp); } PagedResult actuals = null; for (int i = 0; i < 3; i++) { actuals = lookup.searchAliases(ip, i * 10, 10); assertReflectionEquals(expecteds.subList(i * 10, i * 10 + 10), actuals.rows, LENIENT_ORDER); assertEquals(35, actuals.maxRows); } actuals = lookup.searchAliases(ip, 30, 10); assertReflectionEquals(expecteds.subList(30, 35), actuals.rows, LENIENT_ORDER); assertEquals(35, actuals.maxRows); }
From source file:org.estatio.dom.financial.utils.IBANValidator.java
public static String fixChecksum(final String ibanTemplate) { int remainder = checksum(ibanTemplate); String pp = StringUtils.leftPad(String.valueOf(1 + A_ASCII - remainder), 2, '0'); return ibanTemplate.substring(0, 2) + pp + ibanTemplate.substring(SUFFIX_OFFSET); }
From source file:org.ethereum.TestUtils.java
public static String padZeroesLeft(String s, int n) { return StringUtils.leftPad(s, n, '0'); }