List of usage examples for org.apache.commons.lang3 StringUtils isNotBlank
public static boolean isNotBlank(final CharSequence cs)
Checks if a CharSequence is not empty (""), not null and not whitespace only.
StringUtils.isNotBlank(null) = false StringUtils.isNotBlank("") = false StringUtils.isNotBlank(" ") = false StringUtils.isNotBlank("bob") = true StringUtils.isNotBlank(" bob ") = true
From source file:com.efficio.fieldbook.service.CropOntologyServiceImpl.java
@Override public List<CropTerm> searchTerms(String query) { if (StringUtils.isNotBlank(query)) { String url = SEARCH_TERMS_URL + query; return (List<CropTerm>) getList(url, CropTerm.class); }//from ww w. ja v a 2 s. c om return null; }
From source file:edu.usu.sdl.openstorefront.web.rest.TraceInterceptor.java
@Override public void aroundWriteTo(WriterInterceptorContext context) throws IOException, WebApplicationException { if (log.isLoggable(Level.FINEST)) { StringBuilder message = new StringBuilder(); message.append(request.getMethod()).append(" "); if (StringUtils.isNotBlank(request.getQueryString())) { message.append(request.getRequestURL()).append("?").append(request.getQueryString()); } else {//www. j a v a 2 s.co m message.append(request.getRequestURL()); } log.finest(message.toString()); } context.proceed(); }
From source file:com.mowitnow.lawnmower.service.LogService.java
public void log(final String msg) { if (StringUtils.isNotBlank(msg)) { this.setCode(ERR); this.setMsg(msg); } else {//from w w w .java2 s . c o m this.setCode(null); this.setMsg(null); } }
From source file:jease.cms.service.Users.java
/** * Returns true if given login and given email is unique within database for * given user./*from ww w .j av a2s . c o m*/ */ public static boolean isIdentityUnique(final User user, final String login, final String email) { return Database.isUnique(user, $user -> (StringUtils.isNotBlank(login) && login.equals($user.getLogin())) || (StringUtils.isNotBlank(email) && email.equals($user.getEmail()))); }
From source file:de.blizzy.documentr.markdown.macro.impl.IfMacro.java
@Override public String getHtml(IMacroContext macroContext) { String code = macroContext.getParameters(); if (StringUtils.isNotBlank(code)) { try {/*from w w w .j a v a 2 s . co m*/ GroovyShell shell = getGroovyShell(macroContext); log.debug("evaluating expression: {}", code); //$NON-NLS-1$ Object result = shell.evaluate(code); if ((result instanceof Boolean) && ((Boolean) result).booleanValue()) { return macroContext.getBody(); } } catch (RuntimeException e) { log.error("error evaluating {{if}} expression", e); //$NON-NLS-1$ } } return null; }
From source file:ch.cyberduck.core.spectra.SpectraExceptionMappingService.java
@Override public BackgroundException map(final FailedRequestException e) { final StringBuilder buffer = new StringBuilder(); if (null != e.getError()) { this.append(buffer, e.getError().getMessage()); }//from ww w . j a v a 2 s .c om switch (e.getStatusCode()) { case HttpStatus.SC_FORBIDDEN: if (null != e.getError()) { if (StringUtils.isNotBlank(e.getError().getCode())) { switch (e.getError().getCode()) { case "SignatureDoesNotMatch": return new LoginFailureException(buffer.toString(), e); case "InvalidAccessKeyId": return new LoginFailureException(buffer.toString(), e); case "InvalidClientTokenId": return new LoginFailureException(buffer.toString(), e); case "InvalidSecurity": return new LoginFailureException(buffer.toString(), e); case "MissingClientTokenId": return new LoginFailureException(buffer.toString(), e); case "MissingAuthenticationToken": return new LoginFailureException(buffer.toString(), e); } } } } if (e.getCause() instanceof IOException) { return new DefaultIOExceptionMappingService().map((IOException) e.getCause()); } return new HttpResponseExceptionMappingService() .map(new HttpResponseException(e.getStatusCode(), buffer.toString())); }
From source file:com.fengduo.bee.commons.core.lang.Argument.java
public static boolean isNotBlank(String argument) { return StringUtils.isNotBlank(argument); }
From source file:com.mirth.connect.util.CodeTemplateUtil.java
public static String updateCode(String code) { if (StringUtils.isNotBlank(code)) { code = StringUtils.trim(code);//w w w . java 2s. co m int endIndex = 0; Matcher matcher = COMMENT_PATTERN.matcher(code); if (matcher.find()) { endIndex = matcher.end(); } CodeTemplateDocumentation documentation = getDocumentation(code); String description = documentation.getDescription(); CodeTemplateFunctionDefinition functionDefinition = documentation.getFunctionDefinition(); if (StringUtils.isBlank(description)) { description = "Modify the description here. Modify the function name and parameters as needed. One function per template is recommended; create a new code template for each new function."; } StringBuilder builder = new StringBuilder("/**"); for (String descriptionLine : description.split("\r\n|\r|\n")) { builder.append("\n\t").append(WordUtils.wrap(descriptionLine, 100, "\n\t", false)); } if (functionDefinition != null) { builder.append('\n'); if (CollectionUtils.isNotEmpty(functionDefinition.getParameters())) { for (Parameter parameter : functionDefinition.getParameters()) { StringBuilder parameterBuilder = new StringBuilder("\n\t@param {"); parameterBuilder.append(StringUtils.defaultString(parameter.getType(), "Any")); parameterBuilder.append("} ").append(parameter.getName()).append(" - ") .append(StringUtils.trimToEmpty(parameter.getDescription())); builder.append(WordUtils.wrap(parameterBuilder.toString(), 100, "\n\t\t", false)); } } StringBuilder returnBuilder = new StringBuilder("\n\t@return {") .append(StringUtils.defaultString(functionDefinition.getReturnType(), "Any")).append("} ") .append(StringUtils.trimToEmpty(functionDefinition.getReturnDescription())); builder.append(WordUtils.wrap(returnBuilder.toString(), 100, "\n\t\t", false)); } builder.append("\n*/\n"); return builder.toString() + code.substring(endIndex); } return code; }
From source file:com.eryansky.common.web.servlet.ValidateCodeServlet.java
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String validateCode = request.getParameter(SysConstants.SESSION_VALIDATE_CODE); // AJAX??true if (StringUtils.isNotBlank(validateCode)) { response.getOutputStream().print(validate(request, validateCode) ? "true" : "false"); } else {//w w w . j a va 2 s .co m this.doPost(request, response); } }
From source file:de.micromata.genome.gwiki.model.GWikiSettingsPropsArtefakt.java
@Override public void getPreview(GWikiContext ctx, AppendableI sb) { // StringBuilder sb = new StringBuilder(); Map<String, String> m = getStorageData(); String title = m.get(GWikiPropKeys.TITLE); if (StringUtils.isNotBlank(title) == true) { title = ctx.getTranslatedProp(title); sb.append("<h1 class=\"gwikititle\">").append(WebUtils.escapeHtml(title)).append("</h1>"); }//from w w w. jav a2s . co m List<String> keywords = new GWikiProps(m).getStringList(GWikiPropKeys.KEYWORDS); if (keywords != null && keywords.isEmpty() == false) { sb.append("<ul>"); for (String kw : keywords) { sb.append("<li class=\"gwikikeyword\">").append(WebUtils.escapeHtml(kw)).append("</li>\n"); } sb.append("</ul>"); } }