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:com.esri.geoevent.test.performance.FileType.java
public static FileType fromValue(String valueStr) { if (StringUtils.isBlank(valueStr)) return UNKNOWN; if (TEXT.toString().equalsIgnoreCase(valueStr) || TEXT.name().equalsIgnoreCase(valueStr)) return TEXT; else if (JSON.toString().equalsIgnoreCase(valueStr) || JSON.name().equalsIgnoreCase(valueStr)) return JSON; else//from w w w. j a va 2 s . co m return UNKNOWN; }
From source file:com.norconex.collector.http.sitemap.SitemapChangeFrequency.java
/** * Gets the sitemap change frequency matching the supplied string. * Has the same effect as {@link #valueOf(String)} except that it will * return <code>null</code> when no matches are found. * @param frequency change frequency/* ww w. j a va2 s . c om*/ * @return the matching sitemap change frequency, or <code>null</code> */ public static SitemapChangeFrequency getChangeFrequency(String frequency) { if (StringUtils.isBlank(frequency)) { return null; } for (SitemapChangeFrequency v : SitemapChangeFrequency.values()) { if (v.toString().equalsIgnoreCase(frequency)) { return v; } } return null; }
From source file:mesclasses.util.validation.Validators.java
public static List<FError> validate(Trimestre t) { List<FError> err = Lists.newArrayList(); boolean datesNotNull = true; LOG.debug("validation du trimestre " + t.getName()); if (StringUtils.isBlank(t.getName())) { err.add(new FError(MANDATORY(t, "nom"), t)); }//from ww w . j a v a 2 s. co m if (t.getStartAsDate() == null) { err.add(new FError(MANDATORY(t, "dbut"), t)); datesNotNull = false; } if (t.getEndAsDate() == null) { err.add(new FError(MANDATORY(t, "fin"), t)); datesNotNull = false; } if (datesNotNull && !t.getStartAsDate().isEqual(t.getEndAsDate()) && !t.getStartAsDate().isBefore(t.getEndAsDate())) { err.add(new FError(INVALIDS(t, "dates"), t)); } return err; }
From source file:controllers.api.v1.ScriptFinder.java
public static Result getScripts() { ObjectNode result = Json.newObject(); int page = 1; String pageStr = request().getQueryString("page"); if (StringUtils.isBlank(pageStr)) { page = 1;/* w ww .j a v a 2 s .c om*/ } else { try { page = Integer.parseInt(pageStr); } catch (NumberFormatException e) { Logger.error("ScriptFinder Controller getPagedScripts wrong page parameter. Error message: " + e.getMessage()); page = 1; } } int size = 10; String sizeStr = request().getQueryString("size"); if (StringUtils.isBlank(sizeStr)) { size = 10; } else { try { size = Integer.parseInt(sizeStr); } catch (NumberFormatException e) { Logger.error("ScriptFinder Controller getPagedScripts wrong size parameter. Error message: " + e.getMessage()); size = 10; } } String filterOptStr = request().getQueryString("query"); JsonNode filterOpt = null; try { String filterOptStrDecode = URLDecoder.decode(filterOptStr, "UTF-8"); filterOpt = Json.parse(filterOptStrDecode); } catch (Exception e) { Logger.error("ScriptFinder Controller getScripts query filterOpt wrong JSON format. Error message: " + e.getMessage()); filterOpt = null; } result.put("status", "ok"); result.set("data", ScriptFinderDAO.getPagedScripts(filterOpt, page, size)); return ok(result); }
From source file:ext.sns.auth.OAuth2Client.java
/** * ??URI// w w w.j a v a 2 s.c o m * * @param providerName ????? * @param type ???nullempty * @param callbackParam ??null * @param specialParamKey ?Key?providerkey???????null * @return ?URI */ public static String getAuthRequestURI(String providerName, String type, Map<String, String> callbackParam, String specialParamKey) { if (StringUtils.isBlank(providerName)) { throw new IllegalArgumentException("??providerString=" + providerName); } List<String> providerList = ConfigManager.getProviderNameByTypes(type); if (!providerList.contains(providerName)) { throw new IllegalArgumentException("?providerNametypeproviderName = " + providerName + " ,type = " + type + "."); } callbackParam.put(ConfigManager.TYPE_KEY, type); ProviderConfig providerConfig = ConfigManager.getProviderConfigByName(providerName); String requestAuthFullURI = providerConfig.getRequestAuthFullURI(callbackParam, specialParamKey); LOGGER.debug("requestAuthFullURI:" + requestAuthFullURI); return requestAuthFullURI; }
From source file:com.netsteadfast.greenstep.sys.WsAuthenticateUtils.java
public static String getAuthKey(String currentId, String account) throws Exception { if (StringUtils.isBlank(currentId) || StringUtils.isBlank(account)) { throw new Exception("null key."); }/*from w ww .j av a 2 s . c o m*/ return EncryptorUtils.encrypt(Constants.getEncryptorKey1(), Constants.getEncryptorKey2(), currentId + ";" + account + ";" + System.currentTimeMillis()); }
From source file:ch.aonyx.broker.ib.api.order.OpenCloseInstitutional.java
public static final OpenCloseInstitutional fromInitial(final String initial) { if (StringUtils.isBlank(initial)) { return EMPTY; }/*from ww w . j a va2s . c o m*/ final String initialUpperCase = initial.toUpperCase(); if (MAP.containsKey(initialUpperCase)) { return MAP.get(initialUpperCase); } return UNKNOWN; }
From source file:com.esofthead.mycollab.common.UrlEncodeDecoder.java
/** * /*from ww w. ja va2 s . c o m*/ * @param str * @return */ public static String encode(String str) { try { if (StringUtils.isBlank(str)) { return ""; } return URLEncoder.encode(new String(Base64.encodeBase64URLSafe(str.getBytes("UTF-8")), "UTF-8"), "UTF-8"); } catch (UnsupportedEncodingException ex) { throw new MyCollabException(ex); } }
From source file:com.thinkbiganalytics.feedmgr.rest.support.SystemNamingService.java
public static String generateSystemName(String name) { //first trim it String systemName = StringUtils.trimToEmpty(name); if (StringUtils.isBlank(systemName)) { return systemName; }//from www. j a v a 2 s .c om systemName = systemName.replaceAll(" +", "_"); systemName = systemName.replaceAll("[^\\w_]", ""); int i = 0; StringBuilder s = new StringBuilder(); CharacterIterator itr = new StringCharacterIterator(systemName); for (char c = itr.first(); c != CharacterIterator.DONE; c = itr.next()) { if (Character.isUpperCase(c)) { //if it is upper, not at the start and not at the end check to see if i am surrounded by upper then lower it. if (i > 0 && i != systemName.length() - 1) { char prevChar = systemName.charAt(i - 1); char nextChar = systemName.charAt(i + 1); if (Character.isUpperCase(prevChar) && (Character.isUpperCase(nextChar) || CharUtils.isAsciiNumeric(nextChar) || '_' == nextChar || '-' == nextChar)) { char lowerChar = Character.toLowerCase(systemName.charAt(i)); s.append(lowerChar); } else { s.append(c); } } else if (i > 0 && i == systemName.length() - 1) { char prevChar = systemName.charAt(i - 1); if (Character.isUpperCase(prevChar) && !CharUtils.isAsciiNumeric(systemName.charAt(i))) { char lowerChar = Character.toLowerCase(systemName.charAt(i)); s.append(lowerChar); } else { s.append(c); } } else { s.append(c); } } else { s.append(c); } i++; } systemName = s.toString(); systemName = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, systemName); systemName = CaseFormat.LOWER_HYPHEN.to(CaseFormat.LOWER_UNDERSCORE, systemName); systemName = StringUtils.replace(systemName, "__", "_"); // Truncate length if exceeds Hive limit systemName = (systemName.length() > 128 ? systemName.substring(0, 127) : systemName); return systemName; }
From source file:com.thinkbiganalytics.nifi.rest.model.flow.NiFiFlowConnectionConverter.java
/** * Convert a Nifi Connection {@link ConnectionDTO} to a simplified {@link NifiFlowConnection} * * @param connectionDTO the Nifi connection * @return the converted simplified connection *///w w w. j a va 2s. co m public static NifiFlowConnection toNiFiFlowConnection(ConnectionDTO connectionDTO) { if (connectionDTO != null) { String name = connectionDTO.getName(); if (StringUtils.isBlank(name)) { Set<String> relationships = connectionDTO.getSelectedRelationships(); if (relationships != null) { name = relationships.stream().collect(Collectors.joining(",")); } } NifiFlowConnection connection = new NifiFlowConnection(connectionDTO.getId(), name, connectionDTO.getSource() != null ? connectionDTO.getSource().getId() : null, connectionDTO.getDestination() != null ? connectionDTO.getDestination().getId() : null); return connection; } return null; }