List of usage examples for org.apache.commons.lang3 StringUtils rightPad
public static String rightPad(final String str, final int size, String padStr)
Right pad a String with a specified String.
The String is padded to the size of size .
StringUtils.rightPad(null, *, *) = null StringUtils.rightPad("", 3, "z") = "zzz" StringUtils.rightPad("bat", 3, "yz") = "bat" StringUtils.rightPad("bat", 5, "yz") = "batyz" StringUtils.rightPad("bat", 8, "yz") = "batyzyzy" StringUtils.rightPad("bat", 1, "yz") = "bat" StringUtils.rightPad("bat", -1, "yz") = "bat" StringUtils.rightPad("bat", 5, null) = "bat " StringUtils.rightPad("bat", 5, "") = "bat "
From source file:com.daraf.projectdarafprotocol.clienteapp.seguridades.AutenticacionEmpresaRS.java
@Override public void build(String input) { if (validate(input)) { if (input.length() < 401) { input = StringUtils.rightPad(input, 401, " "); }//from ww w .ja v a2 s . c o m try { String values[] = MyStringUtil.splitByFixedLengths(input, new int[] { 1, 400 }); this.resultado = values[0]; if (resultado.equals("1")) { String empresaValues[] = StringUtils.splitPreserveAllTokens(values[1], Cuerpo.FIELD_SEPARATOR_CHAR); this.empresa = new Empresa(); this.empresa.setRuc(empresaValues[0]); this.empresa.setNombre(empresaValues[1]); this.empresa.setTelefono(empresaValues[2]); this.empresa.setDireccion(empresaValues[3]); this.empresa.setUsuario(empresaValues[4]); this.empresa.setPassword(empresaValues[5]); } } catch (Exception ex) { Logger.getLogger(AutenticacionEmpresaRS.class.getName()).log(Level.SEVERE, null, ex); } } }
From source file:ec.edu.distri.clientejava.protocolo.model.Cliente.java
public void setTelefono(String telefono) { this.telefono = StringUtils.rightPad(telefono, 10, " "); }
From source file:com.daraf.projectdarafprotocol.appdb.consultas.ConsultaClienteRS.java
@Override public void build(String input) { if (validate(input)) { if (input.length() < 201) { input = StringUtils.rightPad(input, 201, " "); }/*from ww w . j a va 2 s .co m*/ try { String values[] = MyStringUtil.splitByFixedLengths(input, new int[] { 1, 200 }); this.resultado = values[0]; if (resultado.equals("1")) { String CliValues[] = StringUtils.splitPreserveAllTokens(values[1], Cuerpo.FIELD_SEPARATOR_CHAR); this.cliente = new Cliente(); this.cliente.setIdentificacion(CliValues[0]); this.cliente.setNombre(CliValues[1]); this.cliente.setTelefono(CliValues[2]); this.cliente.setDireccion(CliValues[3]); } } catch (Exception ex) { Logger.getLogger(ConsultaClienteRS.class.getName()).log(Level.SEVERE, null, ex); } } }
From source file:com.daraf.projectdarafprotocol.clienteapp.seguridades.AutenticacionEmpresaRQ.java
public void setPassword(String password) { this.password = StringUtils.rightPad(password, 20, " "); }
From source file:com.daraf.projectdarafprotocol.appdb.consultas.ConsultaProductoRS.java
@Override public void build(String input) { if (validate(input)) { if (input.length() < 401) { input = StringUtils.rightPad(input, 73, " "); }// w w w. ja va 2 s . c om try { String values[] = MyStringUtil.splitByFixedLengths(input, new int[] { 1, 72 }); this.resultado = values[0]; if (this.resultado.equals("1")) { String productoValues[] = StringUtils.splitPreserveAllTokens(values[1], Cuerpo.FIELD_SEPARATOR_CHAR); this.producto = new Producto(); this.producto.setId(productoValues[0]); this.producto.setNombre(productoValues[1]); this.producto.setPrecio(productoValues[2]); this.producto.setCantidad(productoValues[3]); } } catch (Exception ex) { Logger.getLogger(ConsultaProductoRS.class.getName()).log(Level.SEVERE, null, ex); } } }
From source file:com.francetelecom.clara.cloud.coremodel.ConfigRoleTest.java
@Test public void too_long_comments_are_left_truncated_to_avoid_breaking_db_schema() { ConfigRole configRole = new ConfigRole("myapp"); String long300CharsComment = StringUtils.rightPad("comment", 300, 'X'); assertThat(long300CharsComment.length()).isEqualTo(300); configRole.setLastModificationComment(long300CharsComment); assertThat(configRole.getLastModificationComment().length()).isEqualTo(ConfigRole.MAX_COMMENT_SIZE); assertThat(configRole.getLastModificationComment()).startsWith("comment"); }
From source file:ec.edu.distri.clientejava.protocolo.model.Cliente.java
public void setDireccion(String direccion) { this.direccion = StringUtils.rightPad(direccion, 50, " "); }
From source file:com.daraf.projectdarafprotocol.clienteapp.consultas.ConsultaProductoRS.java
@Override public void build(String input) { if (validate(input)) { if (input.length() < 73) { input = StringUtils.rightPad(input, 73, " "); }/*from w w w. j a v a 2 s. co m*/ try { String values[] = MyStringUtil.splitByFixedLengths(input, new int[] { 1, 72 }); this.resultado = values[0]; if (this.resultado.equals("1")) { String productoValues[] = StringUtils.splitPreserveAllTokens(values[1], Cuerpo.FIELD_SEPARATOR_CHAR); this.producto = new Producto(); this.producto.setId(productoValues[0]); this.producto.setNombre(productoValues[1]); this.producto.setPrecio(productoValues[2]); this.producto.setCantidad(productoValues[3]); } } catch (Exception ex) { Logger.getLogger(ConsultaProductoRS.class.getName()).log(Level.SEVERE, null, ex); } } }
From source file:com.github.devnied.emvnfccard.model.Service.java
/** * Constructor with service bytes array parameter * /*from w ww . j a v a 2 s . co m*/ * @param pData * service as byte array */ public Service(final String pData) { if (pData != null && pData.length() == 3) { BitUtils bit = new BitUtils(BytesUtils.fromString(StringUtils.rightPad(pData, 4, "0"))); serviceCode1 = EnumUtils.getValue(bit.getNextInteger(4), ServiceCode1Enum.class); serviceCode2 = EnumUtils.getValue(bit.getNextInteger(4), ServiceCode2Enum.class); serviceCode3 = EnumUtils.getValue(bit.getNextInteger(4), ServiceCode3Enum.class); } }
From source file:com.embedler.moon.jtxt2img.CoreHelper.java
public static Color hex2Rgb(String colorStr) { Validate.notBlank(colorStr, "Color string must not be null"); String _color = StringUtils.rightPad(StringUtils.removeStart(colorStr, "#"), 6, colorStr.charAt(colorStr.length() - 1)); return new Color(Integer.valueOf(_color.substring(0, 2), 16), Integer.valueOf(_color.substring(2, 4), 16), Integer.valueOf(_color.substring(4, 6), 16)); }