List of usage examples for org.apache.commons.lang StringUtils defaultIfBlank
public static String defaultIfBlank(String str, String defaultStr)
Returns either the passed in String, or if the String is whitespace, empty ("") or null
, the value of defaultStr
.
From source file:com.acc.populator.AbstractHttpRequestDataPopulator.java
protected String updateStringValueFromRequest(final HttpServletRequest request, final String paramName, final String defaultValue) { final String requestParameterValue = getRequestParameterValue(request, paramName); if ("".equals(requestParameterValue)) { return null; }/* ww w .ja v a 2 s . c o m*/ return StringUtils.defaultIfBlank(requestParameterValue, defaultValue); }
From source file:com.backelite.sonarqube.commons.surefire.SurefireStaxHandler.java
private static String getClassname(SMInputCursor testCaseCursor, String defaultClassname) throws XMLStreamException { String testClassName = testCaseCursor.getAttrValue("classname"); if (StringUtils.isNotBlank(testClassName) && testClassName.endsWith(")")) { testClassName = testClassName.substring(0, testClassName.indexOf("(")); }// w w w .ja v a2s. co m return StringUtils.defaultIfBlank(testClassName, defaultClassname); }
From source file:com.adaptris.core.services.metadata.xpath.XpathQueryHelper.java
static String resolveMultipleTextItems(Document doc, XPath xp, String expr, boolean allowEmptyResults, String sep) throws CoreException { String queryResult = null;/* ww w. j av a2s. c o m*/ try { String[] nodes = xp.selectMultipleTextItems(doc, expr); if (isEmpty(nodes) && !allowEmptyResults) { throw new CoreException(expr + " returned [" + nodes.length + "] nodes"); } StringBuilder result = new StringBuilder(); for (int i = 0; i < nodes.length; i++) { result.append(StringUtils.defaultIfBlank(nodes[i], "")); if (i < nodes.length - 1) { result.append(sep); } } queryResult = result.toString(); } catch (Exception e) { throw ExceptionHelper.wrapCoreException(e); } return queryResult; }
From source file:com.haulmont.cuba.core.global.UserFormatToolsImpl.java
@Override public String formatOfficial(User user) { return StringUtils.defaultIfBlank(user.getName(), user.getLogin()); }
From source file:com.openshift.restclient.OpenShiftException.java
public OpenShiftException(Throwable cause, IStatus status, String message, Object... arguments) { super(String.format(StringUtils.defaultIfBlank(message, ""), arguments), cause); this.status = status; }
From source file:io.kahu.hawaii.domain.BooleanProperty.java
public BooleanProperty(String value) { super(StringUtils.defaultIfBlank(value, EMPTY), POSSIBLE_VALUES); }
From source file:com.adaptris.core.services.metadata.UseKeyAsServiceIdValueMatcher.java
public String getNextServiceId(String serviceKey, KeyValuePairBag mappings) { return StringUtils.defaultIfBlank(serviceKey, null); }
From source file:ips1ap101.lib.base.bundle.BundleWebui.java
public static String defaultIfBlank(String key, String defaultString) { if (StringUtils.isNotBlank(key)) { try {//w w w . j a va2s . c om String string = getTrimmedToNullString(key); return StringUtils.defaultIfBlank(string, defaultString); } catch (MissingResourceException e) { } } return defaultString; }
From source file:meta.proyecto.base.ProyectoMaven.java
/** * @return the group id */ public String getGroupId() { return StringUtils.defaultIfBlank(_groupId, getDefaultGroupId()); }
From source file:com.predic8.membrane.core.http.xml.Response.java
@Override protected void parseChildren(XMLStreamReader token, String child) throws Exception { if (Headers.ELEMENT_NAME.equals(child)) { headers = (Headers) new Headers().parse(token); } else if ("status".equals(child)) { statusCode = Integer// w w w. java 2 s .co m .parseInt(StringUtils.defaultIfBlank(token.getAttributeValue("", "status-code"), "0")); statusMessage = ""; while (token.hasNext()) { token.next(); if (token.isStartElement()) { parseChildren(token, token.getName().getLocalPart()); } else if (token.isCharacters()) { statusMessage += token.getText(); } else if (token.isEndElement()) { break; } } } }