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:com.github.slugify.Slugify.java
private static String removeDuplicateWhiteSpaces(String input) { String ret = StringUtils.trim(input); if (StringUtils.isBlank(ret)) { return ""; }/* w w w. java 2s . co m*/ return ret.replaceAll("\\s+", " "); }
From source file:jp.ikedam.jenkins.plugins.scoringloadbalancer.util.ValidationUtil.java
public static FormValidation doCheckInteger(String value) { if (StringUtils.isBlank(value)) { return FormValidation.error(Messages.ValidationUtil_integer_requied()); }//from w w w .j ava 2 s.c om try { Integer.parseInt(StringUtils.trim(value)); } catch (NumberFormatException e) { return FormValidation.error(e, Messages.ValidationUtil_integer_invalid()); } return FormValidation.ok(); }
From source file:com.hangum.tadpole.commons.util.JSONUtil.java
/** * json normal string to pretty string/* www. ja v a 2 s. c om*/ * * @param jsonString * @return */ public static String getPretty(String jsonString) { if (jsonString == null) return ""; // if(logger.isDebugEnabled()) { // logger.debug("======================================================"); // logger.debug("==> ["+ jsonString + "]"); // logger.debug("======================================================"); // } try { JsonParser jp = new JsonParser(); JsonElement je = jp.parse(StringUtils.trim(jsonString)); Gson gson = new GsonBuilder().setPrettyPrinting().create(); String strGson = gson.toJson(je); System.out.println(StringUtils.trimToEmpty(strGson)); if (strGson == null || "null".equals(strGson)) strGson = ""; return strGson; } catch (Exception e) { // logger.error("pretty json", e); } return jsonString; }
From source file:com.intel.cosbench.config.common.KVConfigParser.java
private static void addConfigEntry(String entry, Configuration config) { int pos = StringUtils.indexOf(entry, '='); if (pos < 0) logger.warn("cannot parse config entry {}", entry); String key = StringUtils.trim(StringUtils.left(entry, pos)); String value = StringUtils.trim(StringUtils.right(entry, entry.length() - pos - 1)); logger.debug("key=" + key + ";value=" + value); config.setProperty(key, value);//from www. j av a2 s . co m }
From source file:io.logspace.hq.rest.AbstractLogspaceResourcesBase.java
protected static String getQueryParam(Request req, String name, String defaultValue) { String value = StringUtils.trim(req.queryParams(name)); if (StringUtils.isBlank(value)) { return defaultValue; }// w w w. j a v a2 s . com return value; }
From source file:com.hangum.tadpole.rdb.core.util.DialogUtil.java
/** * dialog util/*from w w w .j a va 2 s . c o m*/ * @param userDB * @param strObject */ public static void popupDMLDialog(UserDBDAO userDB, String strObject) { try { TableDAO tableDao = null; List<TableDAO> listTable = userDB.getListTable(); if (listTable.isEmpty()) { if (DBDefine.POSTGRE_DEFAULT != userDB.getDBDefine()) { tableDao = TadpoleObjectQuery.getTable(userDB, StringUtils.trim(strObject)); } else { tableDao = new TableDAO(strObject, ""); } } else { for (TableDAO tmpTableDAO : listTable) { if (strObject.equalsIgnoreCase(tmpTableDAO.getName())) { tableDao = tmpTableDAO; break; } } } if (tableDao != null) { GenerateStatmentDMLDialog dialog = new GenerateStatmentDMLDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), false, userDB, tableDao); dialog.open(); } } catch (Exception e) { logger.error("f4 function", e); } }
From source file:com.cognifide.cq.cqsm.core.scripts.ScriptUtils.java
public static boolean isComment(final String line) { return StringUtils.trim(line).charAt(0) == '#'; }
From source file:io.apiman.common.config.options.AbstractOptions.java
protected static String[] split(String str, char splitter) { if (str == null) return null; String[] splitStr = StringUtils.split(str, splitter); String[] out = new String[splitStr.length]; for (int i = 0; i < splitStr.length; i++) { out[i] = StringUtils.trim(splitStr[i]); }//from w w w. j a v a 2 s . c o m return out; }
From source file:com.intuit.tank.harness.data.ResponseData.java
/** * @return the key */ public String getKey() { return StringUtils.trim(key); }
From source file:com.taobao.tdhs.jdbc.sqlparser.OperationStruct.java
public void setOper(String oper) { oper = StringUtils.trim(oper); if ("is".equalsIgnoreCase(oper)) { this.oper = "="; } else {//w ww . j a v a 2s. c o m this.oper = oper; } }