List of usage examples for org.apache.commons.lang StringUtils isEmpty
public static boolean isEmpty(String str)
Checks if a String is empty ("") or null.
From source file:de.dominikschadow.myths.CSRFTokenHandler.java
public static String getToken(HttpSession session) throws ServletException, NoSuchAlgorithmException, NoSuchProviderException { if (session == null) { throw new ServletException(MISSING_SESSION); }/*www . j ava 2 s . co m*/ String token = (String) session.getAttribute(CSRF_TOKEN); if (StringUtils.isEmpty(token)) { token = getToken(); session.setAttribute(CSRF_TOKEN, token); } return token; }
From source file:com.clican.pluto.common.resource.FilePathResource.java
public FilePathResource(String filePath) { if (StringUtils.isEmpty(filePath)) { throw new IllegalArgumentException("filePath cannot be null"); }//from w w w .j a v a 2 s.c o m if (!filePath.startsWith(FILE_PATH_RESOURCE_PREFIX)) { this.filePath = filePath; } else { this.filePath = filePath.substring(FILE_PATH_RESOURCE_PREFIX.length()); } resource = new File(this.filePath); }
From source file:de.hybris.platform.chinesetaxinvoiceaddon.forms.validation.TaxInvoiceValidator.java
protected static void validateInvoiceName(TaxInvoiceForm invoiceForm, final int maxFieldLength, final Errors errors) { if (StringUtils.isNotBlank(invoiceForm.getRecipientType()) && invoiceForm.getRecipientType().equals(InvoiceRecipientType.UNIT.getCode())) { String recipient = invoiceForm.getRecipient(); if (recipient == null || StringUtils.isEmpty(recipient) || (StringUtils.length(recipient) > maxFieldLength)) { errors.rejectValue(InvoiceField.RECIPIENT.getFieldKey(), InvoiceField.RECIPIENT.getErrorKey()); }//from w ww . ja v a 2 s . c om } }
From source file:hudson.plugins.jetty.security.Password.java
@SuppressFBWarnings({ "SF_SWITCH_FALLTHROUGH", "SF_SWITCH_NO_DEFAULT" }) public static String obfuscate(String s) { if (StringUtils.isEmpty(s)) { return ""; }// ww w. j a v a 2 s. co m StringBuffer buf = new StringBuffer(); byte[] b = new byte[0]; try { b = (s == null) ? "".getBytes("UTF-8") : s.getBytes("UTF-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } synchronized (buf) { buf.append(__OBFUSCATE); for (int i = 0; i < b.length; i++) { byte b1 = b[i]; byte b2 = b[s.length() - (i + 1)]; int i1 = 127 + b1 + b2; int i2 = 127 + b1 - b2; int i0 = i1 * 256 + i2; String x = Integer.toString(i0, 36); switch (x.length()) { case 1: buf.append('0'); case 2: buf.append('0'); case 3: buf.append('0'); default: buf.append(x); } } return buf.toString(); } }
From source file:cz.strmik.cmmitool.web.controller.propertyeditor.RatingScaleEditor.java
@Override public void setAsText(String text) { if (StringUtils.isEmpty(text)) { setValue(null);/*from www . ja v a 2 s .c o m*/ } else { setValue(ratingScaleDao.read(Long.parseLong(text))); } }
From source file:au.org.ala.delta.rtf.RTFUtils.java
private static String filter(String rtf, boolean newLinesToSpace, String... allowedKeywords) { if (StringUtils.isEmpty(rtf)) { return rtf; }//from ww w . j a v a 2s . c om FilteringRTFHandler handler = new FilteringRTFHandler(newLinesToSpace, allowedKeywords); RTFReader reader = new RTFReader(rtf, handler); try { reader.parse(); } catch (Exception ex) { // throw new RuntimeException(ex); // Ignore, and return the original text return rtf; } return handler.getFilteredText(); }
From source file:com.comcast.viper.flume2storm.zookeeper.ZkUtilies.java
/** * Builds a valid (guaranteed) ZNode path made of the components passed in * parameter. This method handles the path separator between component, so it * can be called with or without them./*from www .ja v a 2 s . c o m*/ * * @param components * A bunch of ZNode path elements. Some may be null. * @return The concatenated path of all the elements * @throws IllegalArgumentException * if the path is invalid (empty for example) */ public static String buildZkPath(final String... components) { Preconditions.checkArgument(components != null, "No path element specified"); boolean isFirst = true; final StringBuilder result = new StringBuilder(); for (int i = 0; i < components.length; i++) { if (StringUtils.isEmpty(components[i])) { continue; } assert components[i] != null; // Checking path separator if (isFirst) { // First element must start with / if (!components[i].startsWith(SEPARATOR)) { result.append(SEPARATOR); } result.append(components[i]); } else { if (!SEPARATOR_CHAR.equals(result.charAt(result.length() - 1)) && !components[i].startsWith(SEPARATOR)) { result.append(SEPARATOR); result.append(components[i]); } else if (SEPARATOR_CHAR.equals(result.charAt(result.length() - 1)) && components[i].startsWith(SEPARATOR)) { result.append(components[i].substring(1)); } else { result.append(components[i]); } } isFirst = false; } final String path = result.toString(); PathUtils.validatePath(path); return path; }
From source file:com.github.ipaas.ifw.front.directive.DirectiveUtils.java
static String getRequiredParam(Map params, String key) throws TemplateException { Object value = params.get(key); if (value == null || StringUtils.isEmpty(value.toString())) { throw new TemplateModelException("not found required parameter:" + key + " for directive"); }/*ww w . j av a 2 s . c o m*/ return value.toString(); }
From source file:com.bstek.dorado.web.WebExpressionUtilsObject.java
public String getContextPath() { try {/*w w w .j a v a2 s . co m*/ String contextPath = Configure.getString("web.contextPath"); if (StringUtils.isEmpty(contextPath)) { contextPath = DoradoContext.getAttachedRequest().getContextPath(); } return contextPath; } catch (Exception e) { return "/"; } }
From source file:net.servicefixture.context.GlobalContext.java
@SuppressWarnings("unchecked") public static void putVar(String key, Object object) { if (!StringUtils.isEmpty(key)) { jexlContext.getVars().put(key, object); }//from ww w. java 2 s . com }