List of usage examples for org.apache.commons.lang StringUtils trim
public static String trim(String str)
Removes control characters (char <= 32) from both ends of this String, handling null
by returning null
.
From source file:StringUtilsTrial.java
public static void main(String[] args) { // No NullPointer Exception even if null! System.out.println("10) Trim String. No NullPointerException >>>" + StringUtils.trim(null)); }
From source file:com.intuit.tank.report.JobReport.java
public static void main(String[] args) { StringUtils.trim(null); System.out.println(NumberUtils.isDigits(StringUtils.trim("123 "))); System.out.println(NumberUtils.toInt(StringUtils.trim("123 "))); }
From source file:com.github.slugify.Slugify.java
public static String slugify(String input) { String ret = StringUtils.trim(input); if (StringUtils.isBlank(input)) { return ""; }/*from ww w .j a v a 2s .c o m*/ ret = normalize(ret); ret = removeDuplicateWhiteSpaces(ret); return ret.replace(" ", "-").toLowerCase(); }
From source file:io.logspace.hq.rest.AbstractLogspaceResourcesBase.java
protected static int getQueryParam(Request request, String name, int defaultValue, int minValue, int maxValue) { String value = StringUtils.trim(request.queryParams(name)); if (StringUtils.isBlank(value)) { return defaultValue; }//from w ww.j a v a 2 s .co m int result; try { result = Integer.parseInt(value); } catch (NumberFormatException e) { throw ParameterValueException.unparsableValue(name, value, e); } if (result < minValue) { throw ParameterValueException.valueTooSmall(name, result, minValue); } if (result > maxValue) { throw ParameterValueException.valueTooLarge(name, result, maxValue); } return result; }
From source file:com.baifendian.swordfish.execserver.parameter.placeholder.CalculateUtil.java
/** * ?/*from w w w.j a va 2 s . c o m*/ * * @param expression * @return */ public static Integer calc(String expression) { expression = StringUtils.trim(expression); expression = transform(expression); List<String> result = getStringList(expression); // String?List result = getPostOrder(result); // ?? return calculate(result); // }
From source file:com.github.slugify.Slugify.java
private static String normalize(String input) { String ret = StringUtils.trim(input); if (StringUtils.isBlank(ret)) { return ""; }// w ww . j a v a2 s . com ret = ret.replace("", "ss"); return Normalizer.normalize(ret, Normalizer.Form.NFD).replaceAll("[^\\p{ASCII}]", "") .replaceAll("[^a-zA-Z0-9 ]", ""); }
From source file:ei.ne.ke.cassandra.cql3.template.Comparator.java
/** * * * @param literal// www.j a v a 2 s . co m * @return */ public static Comparator getEnum(String literal) { String trimmedLiteral = StringUtils.trim(literal); if (!STR_LOOKUP.containsKey(trimmedLiteral)) { throw new IllegalArgumentException("Unknown comparator: " + trimmedLiteral); } return STR_LOOKUP.get(trimmedLiteral); }
From source file:net.sf.commons.ssh.directory.Description.java
static Description loadDescription(Element element) { Description description = new Description(); description.className = StringUtils.trim(getFromElement(element, "class-name", true)); //$NON-NLS-1$ description.name = getFromElement(element, "name", true); //$NON-NLS-1$ description.license = getFromElement(element, "license", false); //$NON-NLS-1$ description.url = getFromElement(element, "url", true); //$NON-NLS-1$ try {/* ww w . ja va 2s. c o m*/ description.priority = Integer.valueOf(getFromElement(element, "priority", false)); } catch (NumberFormatException e) { description.priority = 100; } return description; }
From source file:com.smartitengineering.util.opensearch.impl.Utils.java
public static void checkMaxLength(String name, int maxLength, String testString, boolean trim) { final String finalTestString; if (trim) {// w w w.jav a2s .c o m finalTestString = StringUtils.trim(testString); } else { finalTestString = testString; } if (StringUtils.length(finalTestString) > maxLength) { throw new IllegalArgumentException(new StringBuilder(name).append(" must be fewer or equal to ") .append(maxLength).append(" characters").toString()); } }
From source file:com.shending.support.enums.PaymentGatewayTypeEnum.java
public static PaymentGatewayTypeEnum getEnum(String mean) { switch (StringUtils.trim(mean)) { case "": return MIN_SHENG; case "?": return ALIPAY; case "?": return POST_CARD; case "": return WECHAT_PAY; case "": return ICBC; case "": return ABC; case "": return CCBC; case "": return CASH; case "?": return ALIPAY_BANK; case "": return BANK_TRANSFER; case "?": return UNIONPAY; default:// w w w. j a v a2 s . c o m return null; } }