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.github.utils.mycollect.util.EmojiUtil.java
/** * ?emoji/*from w ww . j av a 2 s.c o m*/ * * @param source * @return true */ public static boolean containsEmoji(String source) { if (StringUtils.isBlank(source)) { return false; } for (int i = 0; i < source.length(); i++) { char codePoint = source.charAt(i); if (isEmojiCharacter(codePoint)) { return true; } } return false; }
From source file:controllers.api.v1.Tracking.java
public static Result addTrackingEvent() { ObjectNode result = Json.newObject(); String username = session("user"); ObjectNode json = Json.newObject();// w w w . j a v a 2 s . c o m ArrayNode res = json.arrayNode(); JsonNode requestNode = request().body().asJson(); if (StringUtils.isNotBlank(username)) { String message = TrackingDAO.addTrackingEvent(requestNode, username); if (StringUtils.isBlank(message)) { result.put("status", "success"); return ok(result); } else { result.put("status", "failed"); result.put("message", message); return badRequest(result); } } else { result.put("status", "failed"); result.put("message", "User is not authenticated"); return unauthorized(result); } }
From source file:com.omertron.subbabaapi.enumerations.SearchType.java
/** * Set the search type from a string./*from w w w .j a va 2s. c o m*/ * * @param type * @return */ public static SearchType fromString(String type) { if (StringUtils.isBlank(type)) { throw new IllegalArgumentException("SearchType is null"); } try { for (SearchType searchType : SearchType.values()) { if (type.equalsIgnoreCase(searchType.type)) { return searchType; } } } catch (IllegalArgumentException ex) { throw new IllegalArgumentException("SearchType '" + type + "' does not exist", ex); } // We did not find the search type throw new IllegalArgumentException("SearchType '" + type + "' does not exist"); }
From source file:de.micromata.genome.gwiki.scheduler_1_0.api.GWikiScheduler.java
public static void submitJob(String scheduler, String className, String triggerDefintion, Map<String, String> args) { if (StringUtils.isBlank(scheduler) == true) { scheduler = "standard"; }/*from w w w. j a va 2 s .co m*/ JobDefinition jobDefinition = new GWikiSchedClassJobDefinition(className, null); Trigger trigger = TriggerJobUtils.createTriggerDefinition(triggerDefintion); ChronosServiceManager.get().getSchedulerDAO().submit(scheduler, jobDefinition, PipeValueList.encode(args), trigger); }
From source file:com.omertron.subbabaapi.enumerations.SearchFunction.java
/** * Set the search type from a string.// w w w .ja v a2 s .co m * * @param function * @return */ public static SearchFunction fromString(String function) { if (StringUtils.isBlank(function)) { throw new IllegalArgumentException("SearchFunction is null"); } try { for (SearchFunction searchFunction : SearchFunction.values()) { if (function.equalsIgnoreCase(searchFunction.type)) { return searchFunction; } } } catch (IllegalArgumentException ex) { throw new IllegalArgumentException("SearchFunction '" + function + "' does not exist", ex); } throw new IllegalArgumentException("SearchFunction is null"); }
From source file:ch.aonyx.broker.ib.api.execution.Side.java
public static final Side fromAcronym(final String acronym) { if (StringUtils.isBlank(acronym)) { return EMPTY; }// w ww .j ava 2 s. c om final String acronymUpperCase = acronym.toUpperCase(); if (MAP.containsKey(acronymUpperCase)) { return MAP.get(acronymUpperCase); } return UNKNOWN; }
From source file:com.netsteadfast.greenstep.sys.SysLoginLogSupport.java
public static void log(String userId) { if (StringUtils.isBlank(userId)) { log.warn("null userId"); return;/* w w w . j a v a 2 s .c o m*/ } NamedParameterJdbcTemplate namedParameterJdbcTemplate = (NamedParameterJdbcTemplate) AppContext .getBean("namedParameterJdbcTemplate"); Map<String, Object> paramMap = new HashMap<String, Object>(); paramMap.put("oid", SimpleUtils.getUUIDStr()); paramMap.put("user", userId); paramMap.put("cuserid", "SYS"); paramMap.put("cdate", new Date()); try { namedParameterJdbcTemplate.update( "insert into tb_sys_login_log(OID, USER, CUSERID, CDATE) values(:oid, :user, :cuserid, :cdate)", paramMap); } catch (Exception e) { e.printStackTrace(); log.error(e.getMessage().toString()); } }
From source file:net.link.eu.vat.client.util.VATUtil.java
/** * Tries to guess the country from the given VAT number. * Defaults to the given country code when this methods cannot guess it. * * @param vatNumber the number./*w ww . j a va 2s .c om*/ * @param defaultCountry the default country. * * @return the countrycode if found, or the default one. */ @NotNull public static CountryCode guessCountryFromNumber(@NotNull String vatNumber, @NotNull CountryCode defaultCountry) { if (StringUtils.isBlank(vatNumber) || vatNumber.length() <= 2) { return defaultCountry; } try { String code = vatNumber.substring(0, 2).toUpperCase(); if (StringUtils.isAlpha(code)) { return CountryCode.valueOf(code); //throws error when not found } else { return defaultCountry; } } catch (Exception e) { return defaultCountry; } }
From source file:ch.citux.td.util.Log.java
public static void v(String tag, String message) { if (!StringUtils.isBlank(tag) && !StringUtils.isBlank(message)) { android.util.Log.v(tag, message); }//from w w w . j av a2 s . c om }
From source file:com.zuehlke.sbdfx.transport.ResponseWithError.java
private static String calcErrorMessage(Throwable error) { // String result = ""; final StringBuilder result = new StringBuilder(); String separator = ""; //$NON-NLS-1$ for (Throwable current = error; current != null; current = current.getCause()) { String message = current.getMessage(); if (StringUtils.isBlank(message)) { message = current.getClass().getName(); }/* ww w .java 2 s .c o m*/ // result = result + separator + message; result.append(separator).append(message); separator = "\n --> "; //$NON-NLS-1$ } return result.toString(); }