List of usage examples for org.apache.commons.lang3 StringUtils isNotEmpty
public static boolean isNotEmpty(final CharSequence cs)
Checks if a CharSequence is not empty ("") and not null.
StringUtils.isNotEmpty(null) = false StringUtils.isNotEmpty("") = false StringUtils.isNotEmpty(" ") = true StringUtils.isNotEmpty("bob") = true StringUtils.isNotEmpty(" bob ") = true
From source file:com.mirth.connect.donkey.server.channel.MetaDataReplacer.java
public void setMetaDataMap(ConnectorMessage connectorMessage, List<MetaDataColumn> metaDataColumns) { for (MetaDataColumn column : metaDataColumns) { if (StringUtils.isNotEmpty(column.getMappingName())) { Object value = getMetaDataValue(connectorMessage, column); if (value != null) { try { connectorMessage.getMetaDataMap().put(column.getName(), column.getType().castValue(value)); } catch (MetaDataColumnException e) { // If there is an error casting the value, log a warning but continue with processing because // the metadata values are not essential for processing logger.warn("Could not cast value '" + value + "' to " + column.getType().toString(), e); }/*from w w w .ja va 2 s . c om*/ } } } }
From source file:com.github.htfv.utils.el.internal.StringFunctions.java
/** * Concatenates array of strings without a separator, ignoring any empty and * {@code null} strings./*w w w .j ava 2 s . c o m*/ * * @param strings * the array of strings to join. * * @return the joined string. */ public static String concat(final String... strings) { final StringBuilder joinedString = new StringBuilder(); for (int i = 0; i < strings.length; i += 1) { final String string = strings[i]; if (StringUtils.isNotEmpty(string)) { joinedString.append(string); } } return joinedString.toString(); }
From source file:com.glaf.activiti.tasklistener.factory.TaskListenerFactory.java
public static void notify(String key, DelegateTask delegateTask) { String taskListenerType = "spring"; if (StringUtils.isNotEmpty(SystemProperties.getString(EXECUTION_LISTENER_FACTORY_TYPE))) { taskListenerType = SystemProperties.getString(EXECUTION_LISTENER_FACTORY_TYPE); }/*from www .j ava2 s . co m*/ if (StringUtils.isNotEmpty(CustomProperties.getString(EXECUTION_LISTENER_FACTORY_TYPE))) { taskListenerType = CustomProperties.getString(EXECUTION_LISTENER_FACTORY_TYPE); } key = key.trim(); TaskListener taskListener = null; if (StringUtils.equals(taskListenerType, "spring")) { taskListener = (TaskListener) TaskListenerBeanFactory.getBean(key); if (taskListener != null) { try { taskListener.notify(delegateTask); } catch (Exception ex) { throw new RuntimeException(ex); } } } else { try { taskListener = (TaskListener) pool.borrowObject(key); if (taskListener != null) { taskListener.notify(delegateTask); } } catch (Exception ex) { throw new RuntimeException(ex); } finally { if (taskListener != null) { try { pool.returnObject(key, taskListener); } catch (Exception ex) { ex.printStackTrace(); } } } } }
From source file:com.nridge.core.base.io.xml.IOXML.java
/** * Writes an XML tag attribute (name/value) while ensuring the characters * are properly escaped./*from w ww . j a va 2s .c o m*/ * * @param aPW Print writer output stream. * @param aName Attribute name. * @param aValue Attribute value. * * @throws IOException I/O related exception. */ public static void writeAttrNameValue(PrintWriter aPW, String aName, String aValue) throws IOException { if (StringUtils.isNotEmpty(aValue)) aPW.printf(" %s=\"%s\"", StringEscapeUtils.escapeXml10(aName), StringEscapeUtils.escapeXml10(aValue)); }
From source file:com.ec2box.manage.util.EncryptionUtil.java
/** * return hash value of string//from www. j a v a 2 s.c o m * * @param str unhashed string * @param salt salt for hash * @return hash value of string */ public static String hash(String str, String salt) { String hash = null; try { MessageDigest md = MessageDigest.getInstance("SHA-256"); if (StringUtils.isNotEmpty(salt)) { md.update(Base64.decodeBase64(salt.getBytes())); } md.update(str.getBytes("UTF-8")); hash = new String(Base64.encodeBase64(md.digest())); } catch (Exception e) { e.printStackTrace(); } return hash; }
From source file:com.keybox.manage.util.EncryptionUtil.java
/** * return hash value of string//from ww w . j av a 2 s . co m * * @param str unhashed string * @param salt salt for hash * @return hash value of string */ public static String hash(String str, String salt) { String hash = null; try { MessageDigest md = MessageDigest.getInstance("SHA-256"); if (StringUtils.isNotEmpty(salt)) { md.update(Base64.decodeBase64(salt.getBytes())); } md.update(str.getBytes("UTF-8")); hash = new String(Base64.encodeBase64(md.digest())); } catch (Exception e) { log.error(e.toString(), e); } return hash; }
From source file:com.wedian.site.common.template.method.AbbreviateMethod.java
@SuppressWarnings("rawtypes") public Object exec(List arguments) throws TemplateModelException { if (arguments != null && !arguments.isEmpty() && arguments.get(0) != null && StringUtils.isNotEmpty(arguments.get(0).toString())) { Integer width = null;//w w w .j a v a2 s .c om String ellipsis = null; if (arguments.size() == 2) { if (arguments.get(1) != null) { width = Integer.valueOf(arguments.get(1).toString()); } } else if (arguments.size() > 2) { if (arguments.get(1) != null) { width = Integer.valueOf(arguments.get(1).toString()); } if (arguments.get(2) != null) { ellipsis = arguments.get(2).toString(); } } return new SimpleScalar(abbreviate(arguments.get(0).toString(), width, ellipsis)); } return null; }
From source file:com.oliveira.pedidovenda.converter.ClienteConverter.java
@Override public Object getAsObject(FacesContext context, UIComponent component, String value) { Cliente retorno = null;//from ww w . j av a 2 s.c om if (StringUtils.isNotEmpty(value)) { //retorno = this.clientes.porId(new Long(value)); Long id = new Long(value); retorno = clientes.porId(id); } return retorno; }
From source file:com.wedian.site.common.utils.WebUtils.java
/** * cookie//from w w w .j av a 2s . c o m * * @param request * HttpServletRequest * @param response * HttpServletResponse * @param name * cookie?? * @param value * cookie * @param maxAge * (??: ) * @param path * * @param domain * * @param secure * ?? */ public static void addCookie(HttpServletRequest request, HttpServletResponse response, String name, String value, Integer maxAge, String path, String domain, Boolean secure) { Assert.notNull(request); Assert.notNull(response); Assert.hasText(name); try { name = URLEncoder.encode(name, "UTF-8"); value = URLEncoder.encode(value, "UTF-8"); Cookie cookie = new Cookie(name, value); if (maxAge != null) { cookie.setMaxAge(maxAge); } if (StringUtils.isNotEmpty(path)) { cookie.setPath(path); } if (StringUtils.isNotEmpty(domain)) { cookie.setDomain(domain); } if (secure != null) { cookie.setSecure(secure); } response.addCookie(cookie); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } }
From source file:com.netflix.spinnaker.clouddriver.artifacts.config.BasicAuth.java
default Optional<String> getBasicAuthHeader() { String usernamePassword = null; if (StringUtils.isNotEmpty(getUsernamePasswordFile())) { usernamePassword = CredentialReader.credentialsFromFile(getUsernamePasswordFile()); } else if (StringUtils.isNotEmpty(getUsername()) && StringUtils.isNotEmpty(getPassword())) { usernamePassword = getUsername() + ":" + getPassword(); }/*from w w w.ja va 2 s.c o m*/ return Optional.ofNullable(usernamePassword).map(s -> "Basic " + Base64.encodeBase64String(s.getBytes())); }