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:org.eclipse.gyrex.boot.internal.app.ServerApplication.java
private static void printError(final String message, final Throwable cause) { System.err.println();// w w w. j av a2s. c o m System.err.println(); System.err.println(StringUtils.leftPad("", 72, '*')); System.err.println(StringUtils.center(" Server Startup Error ", 72)); System.err.println(StringUtils.leftPad("", 72, '*')); System.err.println(); System.err.println(WordUtils.wrap(message, 72)); System.err.println(); if (cause != null) { System.err.println("Reported error:"); System.err.print(" "); System.err.println(WordUtils.wrap(cause.getMessage(), 70, String.format("%n "), false)); final List throwables = ExceptionUtils.getThrowableList(cause); if (throwables.size() > 1) { System.err.println(); System.err.println("Caused by:"); for (int i = 1; i < throwables.size(); i++) { System.err.print(" "); System.err.println(WordUtils.wrap(ExceptionUtils.getMessage((Throwable) throwables.get(i)), 70, String.format("%n "), false)); } } System.err.println(); } System.err.println(StringUtils.leftPad("", 72, '*')); System.err.println(); System.err.println(); }
From source file:org.eclipse.skalli.core.rest.JSONRestWriter.java
@SuppressWarnings("nls") private RestWriter escaped(String s) throws IOException { int len = s.length(); for (int i = 0; i < len; ++i) { char c = s.charAt(i); switch (c) { case '"': writer.append("\\\""); break; case '\\': writer.append("\\\\"); break; case '<': writer.append('\u0047'); break; case '\n': writer.append("\\n"); break; case '\r': writer.append("\\r"); break; case '\t': writer.append("\\t"); break; case '\b': writer.append("\\b"); break; case '\f': writer.append("\\f"); break; default:/*from w ww . ja v a 2 s . co m*/ if (c < 0x20 || c >= 0x80 && c <= 0xa0 || c >= '\u2000' && c < '\u2100') { writer.append("\\u"); writer.append(StringUtils.leftPad(Integer.toHexString(c), 4, '0')); } else { writer.append(c); } } } return this; }
From source file:org.eclipse.uomo.util.impl.Iso8601Date.java
private void render(StringBuffer str, boolean checkValues, boolean render, int len, int value, String format, String desc, String prefix) throws UOMoException { if (render) { if (value != -1) { if (prefix != null) str.append(prefix);/*from w ww.j a v a 2 s.c om*/ str.append(StringUtils.leftPad(Integer.toString(value), len, Messages.Iso8601Date_ZERO)); } else if (checkValues) throw new UOMoException(Messages.Iso8601Date_NO_SUCH_VALUE_PROVIDED + format + "' specifies " + desc + " but no such value has been provided"); //$NON-NLS-1$ //$NON-NLS-3$ } }
From source file:org.eclipse.uomo.util.impl.Iso8601Date.java
private String prepTimezone() { return (tzNegative.booleanValue() ? Messages.Iso8601Date_MINUS : Messages.Iso8601Date_PLUS) + StringUtils.leftPad(Integer.toString(tzHour), 2, '0') + StringUtils.leftPad(Integer.toString(tzMinute), 2, '0'); }
From source file:org.egov.egf.web.actions.masters.ChartOfAccountsAction.java
void populateGlcode(final Long classification) { model.setGlcode(StringUtils.leftPad("", glCodeLengths.get(classification), '0')); }
From source file:org.examproject.blog.util.GeneralUtils.java
public static String createCode() { int intCode = random.nextInt(999999999); String strCode = String.valueOf(intCode); String code = StringUtils.leftPad(strCode, 9, "0"); return code;/*from w w w . j av a 2 s. c o m*/ }
From source file:org.exoplatform.social.webui.profile.UIContactSection.java
/** * Resets id and name of components that belong to group components are being modified. * // ww w . j a va 2 s . c om * @param componentType Type of components that are being modified. */ private void resetComponentId(String componentType) { List<UIComponent> componentByTypes = null; int componentCount = 0; if (IM.equals(componentType)) { componentByTypes = getImsChilds(); componentCount = getImsCount(); } else if (URL.equals(componentType)) { componentByTypes = getUrlChilds(); componentCount = getUrlCount(); } else if (PHONE.equals(componentType)) { componentByTypes = getPhoneChilds(); componentCount = getPhoneCount(); } for (int i = 0; i < componentCount; i += 2) { UIFormInputBase comp1 = (UIFormInputBase) componentByTypes.get(i); UIFormInputBase comp2 = (UIFormInputBase) componentByTypes.get(i + 1); String newComponentId1 = componentType + StringUtils.leftPad(String.valueOf(i), 3, '0'); String newComponentId2 = componentType + StringUtils.leftPad(String.valueOf(i + 1), 3, '0'); comp1.setId(newComponentId1); comp1.setName(newComponentId1); comp2.setId(newComponentId2); comp2.setName(newComponentId2); } }
From source file:org.exoplatform.social.webui.profile.UIContactSection.java
/** * Adds component with the input type.<br> * * @param type Type of component is added (email, phone, ...). * * @throws Exception/*from w w w . ja v a2 s .com*/ */ private void addUIFormInput(final String type) throws Exception { WebuiRequestContext requestContext = WebuiRequestContext.getCurrentInstance(); ResourceBundle resourceBundle = requestContext.getApplicationResourceBundle(); if (PHONE.equals(type)) { int phoneIdx = phoneCount; createUISelectBox(PHONE_TYPES, PHONE + StringUtils.leftPad(String.valueOf(phoneIdx++), 3, '0')); UIFormStringInput phone = new UIFormStringInput( PHONE + StringUtils.leftPad(String.valueOf(phoneIdx++), 3, '0'), null, null); phone.setHTMLAttribute(HTML_ATTRIBUTE_TITLE, resourceBundle.getString("UIContactSection.label.phones")); addUIFormInput(phone.addValidator(ExpressionValidator.class, PHONE_REGEX_EXPRESSION, INVALID_PHONE)); phoneCount += 2; } else if (IM.equals(type)) { int imIdx = imCount; createUISelectBox(IM_TYPES, IM + StringUtils.leftPad(String.valueOf(imIdx++), 3, '0')); UIFormStringInput im = new UIFormStringInput(IM + StringUtils.leftPad(String.valueOf(imIdx++), 3, '0'), null, null); im.setHTMLAttribute(HTML_ATTRIBUTE_TITLE, resourceBundle.getString("UIContactSection.label.ims")); addUIFormInput( im.addValidator(ExpressionValidator.class, IM_STRINGLENGTH_REGEX_EXPRESSION, INVALID_IM)); imCount += 2; } else if (URL.equals(type)) { int urlIdx = urlCount; UIFormStringInput websiteTitle = new UIFormStringInput( URL + StringUtils.leftPad(String.valueOf(urlIdx++), 3, '0'), null, WEBSITE_TITLE); websiteTitle.setHTMLAttribute(HTML_ATTRIBUTE_TITLE, resourceBundle.getString("UIContactSection.label.websiteTitle")); addUIFormInput(websiteTitle); UIFormStringInput sampleUrlForm = new UIFormStringInput( URL + StringUtils.leftPad(String.valueOf(urlIdx++), 3, '0'), null, null); sampleUrlForm.setHTMLAttribute(HTML_ATTRIBUTE_TITLE, resourceBundle.getString("UIContactSection.label.urls")); sampleUrlForm.setHTMLAttribute(HTML_ATTRIBUTE_PLACEHOLDER, getSampleURL()); addUIFormInput( sampleUrlForm.addValidator(ExpressionValidator.class, URL_REGEX_EXPRESSION, INVALID_URL)); urlCount += 2; } }
From source file:org.fenixedu.academic.domain.accounting.util.PersonPaymentCodeGenerator.java
private String getPersonCodeDigits(Person person) { if (person.getUsername().length() > 9) { throw new RuntimeException( "SIBS Payment Code: " + person.getUsername() + " exceeded maximun size accepted"); }//from w ww. j ava 2 s. c o m return StringUtils.leftPad(person.getUsername().replace("ist", ""), PERSON_CODE_LENGTH, CODE_FILLER); }
From source file:org.fenixedu.academic.domain.accounting.util.PersonRotationPaymentCodeGenerator.java
private static String getPersonCodeDigits(Person person) { if (person.getUsername().length() > 9) { throw new RuntimeException( "SIBS Payment Code: " + person.getUsername() + " exceeded maximun size accepted"); }//from w w w . j a v a 2s . c om return StringUtils.leftPad(person.getUsername().replace("ist", ""), PERSON_CODE_LENGTH, CODE_FILLER); }