List of usage examples for org.apache.commons.lang3 StringUtils isBlank
public static boolean isBlank(final CharSequence cs)
Checks if a CharSequence is whitespace, empty ("") or null.
StringUtils.isBlank(null) = true StringUtils.isBlank("") = true StringUtils.isBlank(" ") = true StringUtils.isBlank("bob") = false StringUtils.isBlank(" bob ") = false
From source file:cz.lbenda.dataman.db.sql.SQLSExecutor.java
public static String[] splitSQLS(String sqls) { if (StringUtils.isBlank(sqls)) { return new String[0]; }/*from ww w. j av a 2 s. co m*/ String[] lines = sqls.split("\n"); StringBuilder sb = new StringBuilder(); for (String line : lines) { sb.append(line.trim()).append("\n"); } return sb.toString().split(";\n"); }
From source file:com.netsteadfast.greenstep.util.ManualDataSourceFactory.java
public static DataSource getDataSource(Class<?> dataSourceClass, String url, String user, String password) throws Exception { if (!checkDataSourceClass(dataSourceClass)) { throw new Exception("DataSource Class is not implements DataSource. error!"); }/*from ww w . j a v a2 s .co m*/ if (StringUtils.isBlank(url) || StringUtils.isBlank(user)) { throw new Exception("url or user is required!"); } DataSource ds = (DataSource) dataSourceClass.newInstance(); Ognl.setValue("url", ds, url); Ognl.setValue("user", ds, user); Ognl.setValue("password", ds, (null == password ? "" : password)); return ds; }
From source file:net.lmxm.ute.utils.PathUtils.java
/** * Builds the full path./*from ww w. j av a2s . c o m*/ * * @param rootPath the root path * @param relativePath the relative path * @return the string */ public static String buildFullPath(final String rootPath, final String relativePath) { final String prefix = "buildFullPath() :"; LOGGER.debug("{} entered, root={}, relativepath=" + relativePath, prefix, rootPath); final String root = StringUtils.removeEnd(StringUtils.trimToEmpty(rootPath), "/"); final String relative = StringUtils.removeStart(StringUtils.trimToEmpty(relativePath), "/"); String fullPath; if (StringUtils.isBlank(relative)) { fullPath = root; } else { fullPath = StringUtils.join(new Object[] { root, "/", relative }); } LOGGER.debug("{} returning {}", prefix, fullPath); return fullPath; }
From source file:controllers.api.v1.Search.java
public static Result searchByKeyword() { ObjectNode result = Json.newObject(); int page = 1; int size = 10; String keyword = request().getQueryString("keyword"); String category = request().getQueryString("category"); String source = request().getQueryString("source"); String pageStr = request().getQueryString("page"); if (StringUtils.isBlank(pageStr)) { page = 1;/*from w w w. j av a2 s . c om*/ } else { try { page = Integer.parseInt(pageStr); } catch (NumberFormatException e) { Logger.error("Dataset Controller searchByKeyword wrong page parameter. Error message: " + e.getMessage()); page = 1; } } String sizeStr = request().getQueryString("size"); if (StringUtils.isBlank(sizeStr)) { size = 10; } else { try { size = Integer.parseInt(sizeStr); } catch (NumberFormatException e) { Logger.error("Dataset Controller searchByKeyword wrong page parameter. Error message: " + e.getMessage()); size = 10; } } result.put("status", "ok"); Boolean isDefault = false; if (StringUtils.isBlank(category)) { category = "datasets"; } if (StringUtils.isBlank(source) || source.equalsIgnoreCase("all") || source.equalsIgnoreCase("default")) { source = null; } String searchEngine = Play.application().configuration().getString(SearchDAO.WHEREHOWS_SEARCH_ENGINE__KEY); if (category.toLowerCase().equalsIgnoreCase("metric")) { if (StringUtils.isNotBlank(searchEngine) && searchEngine.equalsIgnoreCase("elasticsearch")) { result.set("result", SearchDAO.elasticSearchMetricByKeyword(category, keyword, page, size)); } else { result.set("result", SearchDAO.getPagedMetricByKeyword(category, keyword, page, size)); } } else if (category.toLowerCase().equalsIgnoreCase("flows")) { if (StringUtils.isNotBlank(searchEngine) && searchEngine.equalsIgnoreCase("elasticsearch")) { result.set("result", SearchDAO.elasticSearchFlowByKeyword(category, keyword, page, size)); } else { result.set("result", SearchDAO.getPagedFlowByKeyword(category, keyword, page, size)); } } else if (category.toLowerCase().equalsIgnoreCase("jobs")) { if (StringUtils.isNotBlank(searchEngine) && searchEngine.equalsIgnoreCase("elasticsearch")) { result.set("result", SearchDAO.elasticSearchFlowByKeyword(category, keyword, page, size)); } else { result.set("result", SearchDAO.getPagedJobByKeyword(category, keyword, page, size)); } } else if (category.toLowerCase().equalsIgnoreCase("comments")) { if (StringUtils.isNotBlank(searchEngine) && searchEngine.equalsIgnoreCase("elasticsearch")) { result.set("result", SearchDAO.elasticSearchDatasetByKeyword(category, keyword, null, page, size)); } else { result.set("result", SearchDAO.getPagedCommentsByKeyword(category, keyword, page, size)); } } else { if (StringUtils.isNotBlank(searchEngine) && searchEngine.equalsIgnoreCase("elasticsearch")) { result.set("result", SearchDAO.elasticSearchDatasetByKeyword(category, keyword, source, page, size)); } else { result.set("result", SearchDAO.getPagedDatasetByKeyword(category, keyword, source, page, size)); } } return ok(result); }
From source file:ch.aonyx.broker.ib.api.contract.OptionRight.java
public static final OptionRight fromInitialOrName(final String value) { if (StringUtils.isBlank(value)) { return EMPTY; }/*from w w w .ja v a 2 s. c om*/ final String valueUpperCase = value.toUpperCase(); if (INITIAL_MAP.containsKey(valueUpperCase)) { return INITIAL_MAP.get(valueUpperCase); } if (NAME_MAP.containsKey(valueUpperCase)) { return NAME_MAP.get(valueUpperCase); } return UNKNOWN; }
From source file:ch.citux.td.util.Log.java
public static void e(String tag, String message) { if (!StringUtils.isBlank(tag) && !StringUtils.isBlank(message)) { android.util.Log.e(tag, message); }/*from ww w. ja v a 2s . co m*/ }
From source file:com.qcadoo.mes.masterOrders.constants.MasterOrderType.java
public static MasterOrderType parseString(final String rawMasterOrderType) { if (StringUtils.isBlank(rawMasterOrderType)) { return UNDEFINED; }//from w w w .j av a 2 s . c o m String masterOrderType = StringUtils.trim(rawMasterOrderType); for (MasterOrderType type : values()) { if (StringUtils.equalsIgnoreCase(type.getStringValue(), masterOrderType)) { return type; } } throw new IllegalStateException("Unsupported masterOrderType: " + masterOrderType); }
From source file:com.nesscomputing.syslog4j.util.OSDetectUtility.java
private static boolean isMatch(String[] platforms) { boolean match = false; String osName = System.getProperty("os.name"); if (!StringUtils.isBlank(osName)) { osName = osName.toLowerCase();/* w w w .ja v a 2 s.c om*/ for (int i = 0; i < platforms.length; i++) { String platform = platforms[i].toLowerCase(); if (osName.indexOf(platform) > -1) { match = true; break; } } } return match; }
From source file:com.alacoder.lion.common.utils.StringTools.java
public static String urlDecode(String value) { if (StringUtils.isBlank(value)) { return ""; }/*from w w w . j av a 2 s. c om*/ try { return URLDecoder.decode(value, LionConstants.DEFAULT_CHARACTER); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e.getMessage(), e); } }
From source file:com.norconex.collector.http.pipeline.importer.HttpImporterPipelineUtil.java
public static void enhanceHTTPHeaders(HttpMetadata metadata) { if (StringUtils.isNotBlank(metadata.getString(HttpMetadata.COLLECTOR_CONTENT_TYPE))) { return;//from w w w .j av a2 s . c o m } String contentType = metadata.getString(HttpMetadata.HTTP_CONTENT_TYPE); if (StringUtils.isBlank(contentType)) { for (String key : metadata.keySet()) { if (StringUtils.endsWith(key, HttpMetadata.HTTP_CONTENT_TYPE)) { contentType = metadata.getString(key); } } } if (StringUtils.isNotBlank(contentType)) { String mimeType = contentType.replaceFirst("(.*?)(;.*)", "$1"); String charset = contentType.replaceFirst("(.*?)(; )(.*)", "$3"); charset = charset.replaceFirst("(charset=)(.*)", "$2"); metadata.addString(HttpMetadata.COLLECTOR_CONTENT_TYPE, mimeType); metadata.addString(HttpMetadata.COLLECTOR_CONTENT_ENCODING, charset); } }