List of usage examples for org.apache.commons.lang StringUtils stripToEmpty
public static String stripToEmpty(String str)
Strips whitespace from the start and end of a String returning an empty String if null
input.
From source file:MainClass.java
public static void main(String[] args) { //Strip whitespace from start and end of the string. //If null returns empty string System.out.println("13) Strip whitespace >>>" + StringUtils.stripToEmpty(" ABCD ")); }
From source file:StringUtilsTrial.java
public static void main(String[] args) { // Strip whitespace from start and end of the string. // If null returns empty string System.out.println("13) Strip whitespace >>>" + StringUtils.stripToEmpty(" ABCD ")); }
From source file:com.opendesign.utils.ControllerUtil.java
/** * Request ? ? ? Map ? ?. ?? ? java.util.Array ?. * //from w w w. j a v a2 s . c o m * @param request * @return */ public static Map<String, Object> createParamMap(HttpServletRequest request) { Map<String, Object> paramMap = new HashMap<String, Object>(); // 2015.09.13 joldo // String updateID = SessionManager.getAdminId(request.getSession()); // String token = request.getParameter("token"); // paramMap.put("updateID", StringUtils.isEmpty(updateID) ? // "${anonymous}" : updateID ); // paramMap.put("token", StringUtils.isEmpty(token) ? "${anonymous}" : // token ); @SuppressWarnings("rawtypes") Enumeration enums = request.getParameterNames(); while (enums.hasMoreElements()) { String paramName = (String) enums.nextElement(); String[] parameters = request.getParameterValues(paramName); // Parameter ? if (parameters.length > 1) { for (int i = 0; i < parameters.length; i++) { String param = StringUtils.stripToEmpty(parameters[i]); parameters[i] = param; } paramMap.put(paramName, parameters); // Parameter ? } else { paramMap.put(paramName, StringUtils.stripToEmpty(parameters[0])); } } request.setAttribute("param_map", paramMap); return paramMap; }
From source file:com.activecq.tools.errorpagehandler.impl.StringLengthComparator.java
@Override public int compare(String s1, String s2) { s1 = StringUtils.stripToEmpty(s1); s2 = StringUtils.stripToEmpty(s2);// ww w . ja v a2 s .c o m if (s1.length() > s2.length()) { return -1; } else if (s1.length() < s2.length()) { return 1; } else { // Compare alphabeticaly if the same length return s1.compareTo(s2); } }
From source file:com.opendesign.vo.OrderVO.java
/** */ public String getOrderAddress() { String deliInfo = StringUtils.stripToEmpty(deliveryInfo); if (StringUtils.isEmpty(deliInfo)) { return ""; }/*from w w w. j a v a 2 s. co m*/ String result = ""; Matcher matcher = Pattern.compile(DELIVERYINFO_REGEX).matcher(deliInfo); if (matcher.find()) { result = matcher.group(3); } return StringUtils.stripToEmpty(result); }
From source file:com.adobe.acs.commons.quickly.Command.java
public Command(final String raw) { this.raw = StringUtils.stripToEmpty(raw); String opWithPunctuation = StringUtils .stripToEmpty(StringUtils.lowerCase(StringUtils.substringBefore(this.raw, " "))); int punctuationIndex = StringUtils.indexOfAny(opWithPunctuation, PUNCTUATIONS); if (punctuationIndex > 0) { this.punctuation = StringUtils.substring(opWithPunctuation, punctuationIndex).split("(?!^)"); this.operation = StringUtils.substring(opWithPunctuation, 0, punctuationIndex); } else {/*from www .j av a 2 s .co m*/ this.punctuation = new String[] {}; this.operation = opWithPunctuation; } this.param = StringUtils.stripToEmpty(StringUtils.removeStart(this.raw, opWithPunctuation)); this.params = StringUtils.split(this.param); if (log.isTraceEnabled()) { log.trace("Raw: {}", this.raw); log.trace("Operation: {}", this.operation); log.trace("Punctuation: {}", Arrays.toString(this.punctuation)); log.trace("Param: {}", this.param); log.trace("Params: {}", Arrays.toString(this.params)); } }
From source file:com.adobe.acs.tools.tag_maker.tagdataconverters.impl.LowercaseWithDashesConverterImpl.java
@Override public final TagData convert(final String data) { String title = data;/*from www .j av a 2 s . c o m*/ String name = data; name = StringUtils.stripToEmpty(name); name = StringUtils.lowerCase(name); name = StringUtils.replace(name, "&", " and "); name = StringUtils.replace(name, "/", " or "); name = StringUtils.replace(name, "%", " percent "); name = name.replaceAll("[^a-z0-9-]+", "-"); name = StringUtils.stripEnd(name, "-"); name = StringUtils.stripStart(name, "-"); final TagData tagData = new TagData(name); tagData.setTitle(title); return tagData; }
From source file:com.adobe.acs.tools.tag_maker.tagdataconverters.impl.TitleAndNodeNameConverterImpl.java
@Override public final TagData convert(String data) { data = StringUtils.stripToEmpty(data); String name;//from w w w .j a v a 2 s . c om final Matcher matcher = PATTERN.matcher(data); if (matcher.find() && matcher.groupCount() == 1) { name = matcher.group(1); name = StringUtils.stripToEmpty(name); } else { return TagData.EMPTY; } String title = PATTERN.matcher(data).replaceAll(""); title = StringUtils.stripToEmpty(title); final TagData tagData = new TagData(name); tagData.setTitle(title); return tagData; }
From source file:com.adobe.acs.tools.csv_asset_importer.impl.Column.java
public Column(final String raw, final int index) { this.index = index; this.raw = StringUtils.trim(raw); String paramsStr = StringUtils.substringBetween(raw, "{{", "}}"); String[] params = StringUtils.split(paramsStr, ":"); if (StringUtils.isBlank(paramsStr)) { this.relPropertyPath = this.getRaw(); } else {//from w ww . jav a 2s . c o m this.relPropertyPath = StringUtils.trim(StringUtils.substringBefore(this.getRaw(), "{{")); if (params.length == 2) { this.dataType = nameToClass(StringUtils.stripToEmpty(params[0])); this.multi = StringUtils.equalsIgnoreCase(StringUtils.stripToEmpty(params[1]), MULTI); } if (params.length == 1) { if (StringUtils.equalsIgnoreCase(MULTI, StringUtils.stripToEmpty(params[0]))) { this.multi = true; } else { this.dataType = nameToClass(StringUtils.stripToEmpty(params[0])); } } } if (StringUtils.contains(this.relPropertyPath, "/")) { this.propertyName = StringUtils.trim(StringUtils.substringAfterLast(this.relPropertyPath, "/")); } else { this.propertyName = StringUtils.trim(this.relPropertyPath); } }
From source file:com.adobe.acs.tools.csv.impl.Column.java
public Column(final String raw, final int index) { this.index = index; this.raw = StringUtils.trim(raw); String paramsStr = StringUtils.substringBetween(raw, "{{", "}}"); String[] params = StringUtils.split(paramsStr, ":"); if (StringUtils.isBlank(paramsStr)) { this.propertyName = this.getRaw(); } else {//w ww . ja v a2 s . c om this.propertyName = StringUtils.trim(StringUtils.substringBefore(this.getRaw(), "{{")); if (params.length == 2) { this.dataType = nameToClass(StringUtils.stripToEmpty(params[0])); this.multi = StringUtils.equalsIgnoreCase(StringUtils.stripToEmpty(params[1]), MULTI); } if (params.length == 1) { if (StringUtils.equalsIgnoreCase(MULTI, StringUtils.stripToEmpty(params[0]))) { this.multi = true; } else { this.dataType = nameToClass(StringUtils.stripToEmpty(params[0])); } } } }