List of usage examples for org.apache.commons.lang3 StringUtils defaultString
public static String defaultString(final String str)
Returns either the passed in String, or if the String is null , an empty String ("").
StringUtils.defaultString(null) = "" StringUtils.defaultString("") = "" StringUtils.defaultString("bat") = "bat"
From source file:com.cognifide.qa.bb.aem.dialog.classic.field.tags.NamespaceAndPathSplitter.java
/** * Parses namespace and path string separated by ':' into NamespaceAndPath object. * * @return NamespaceAndPath instance created out of textual description of a tag. *///from ww w . jav a 2s .com NamespaceAndPath getNamespaceAndPath(String namespaceAndPathText) { String nonEmptyText = StringUtils.defaultString(namespaceAndPathText); NamespaceAndPathBuilder result = new NamespaceAndPathBuilder(); String[] parts = nonEmptyText.split(AemTags.NAMESPACE_SEPARATOR); if (parts.length > 2) { throw new IllegalArgumentException("Invalid tag"); } else if (parts.length == 2) { result.setNamespace(trimWhiteSpaces(parts[0])); result.setPath(trimWhiteSpaces(parts[1])); } else if (parts.length == 1) { result.setPath(trimWhiteSpaces(parts[0])); } return result.build(); }
From source file:ca.uhn.fhir.rest.server.IncomingRequestAddressStrategy.java
@Override public String determineServerBase(ServletContext theServletContext, HttpServletRequest theRequest) { String requestFullPath = StringUtils.defaultString(theRequest.getRequestURI()); String servletPath;/*w ww . j a va2s . c o m*/ if (myServletPath != null) { servletPath = myServletPath; } else { servletPath = StringUtils.defaultString(theRequest.getServletPath()); } StringBuffer requestUrl = theRequest.getRequestURL(); String servletContextPath = StringUtils.defaultString(theRequest.getContextPath()); String requestPath = requestFullPath.substring(servletContextPath.length() + servletPath.length()); if (requestPath.length() > 0 && requestPath.charAt(0) == '/') { requestPath = requestPath.substring(1); } int startOfPath = requestUrl.indexOf("//"); int requestUrlLength = requestUrl.length(); if (startOfPath != -1 && (startOfPath + 2) < requestUrlLength) { startOfPath = requestUrl.indexOf("/", startOfPath + 2); } if (startOfPath == -1) { startOfPath = 0; } int contextIndex; if (servletPath.length() == 0 || servletPath.equals("/")) { if (requestPath.length() == 0) { contextIndex = requestUrlLength; } else { contextIndex = requestUrl.indexOf(requestPath, startOfPath); } } else { //servletContextPath can start with servletPath contextIndex = requestUrl.indexOf(servletPath + "/", startOfPath); if (contextIndex == -1) { contextIndex = requestUrl.indexOf(servletPath, startOfPath); } } String fhirServerBase; int length = contextIndex + servletPath.length(); if (length > requestUrlLength) { length = requestUrlLength; } fhirServerBase = requestUrl.substring(0, length); return fhirServerBase; }
From source file:com.netsteadfast.greenstep.util.IconUtils.java
public static String getUrl(String basePath, String iconId) throws ServiceException, Exception { String url = ""; if (StringUtils.isBlank(iconId)) { return url; }//from ww w .j a va 2s .c o m TbSysIcon sysIcon = new TbSysIcon(); sysIcon.setIconId(iconId); sysIcon = sysIconService.findByEntityUK(sysIcon); if (sysIcon != null && StringUtils.defaultString(sysIcon.getFileName()).trim().length() > 0) { url = basePath + "/" + ICON_FOLDER + StringUtils.defaultString(sysIcon.getFileName()); } return url; }
From source file:io.github.robwin.swagger2markup.utils.PropertyUtils.java
public static String getType(Property property, MarkupLanguage markupLanguage) { Validate.notNull(property, "property must not be null!"); String type;/*from w w w . j a v a 2s .co m*/ if (property instanceof RefProperty) { RefProperty refProperty = (RefProperty) property; switch (markupLanguage) { case ASCIIDOC: return "<<" + refProperty.getSimpleRef() + ">>"; default: return refProperty.getSimpleRef(); } } else if (property instanceof ArrayProperty) { ArrayProperty arrayProperty = (ArrayProperty) property; Property items = arrayProperty.getItems(); type = getType(items, markupLanguage) + " " + arrayProperty.getType(); } else if (property instanceof StringProperty) { StringProperty stringProperty = (StringProperty) property; List<String> enums = stringProperty.getEnum(); if (CollectionUtils.isNotEmpty(enums)) { type = "enum" + " (" + StringUtils.join(enums, ", ") + ")"; } else { type = property.getType(); } } else { if (StringUtils.isNotBlank(property.getFormat())) { type = StringUtils.defaultString(property.getType()) + " (" + property.getFormat() + ")"; } else { type = property.getType(); } } return StringUtils.defaultString(type); }
From source file:io.wcm.maven.plugins.contentpackage.unpacker.OneAttributePerLineXmlProcessor.java
@Override protected void printAttribute(Writer out, FormatStack fstack, Attribute attribute) throws IOException { if (!attribute.isSpecified() && fstack.isSpecifiedAttributesOnly()) { return;//from w w w . java 2 s . c o m } write(out, StringUtils.defaultString(fstack.getLineSeparator())); write(out, StringUtils.defaultString(fstack.getLevelIndent())); write(out, StringUtils.defaultString(fstack.getIndent())); write(out, StringUtils.defaultString(fstack.getIndent())); write(out, attribute.getQualifiedName()); write(out, "="); write(out, "\""); attributeEscapedEntitiesFilter(out, fstack, attribute.getValue()); write(out, "\""); }
From source file:com.cognifide.qa.bb.expectedconditions.CommonExpectedConditions.java
/** * Check if element has attribute with provided value * * @param attributeName name of the attribute * @param attributeValue value of the attribute * @param element WebElement to check//from w ww .j a va 2 s.c o m * @return true if element has attribute with provided value */ public static ExpectedCondition<Boolean> elementHasAttributeWithValue(final WebElement element, final String attributeName, final String attributeValue) { return driver -> StringUtils.defaultString(element.getAttribute(attributeName)).equals(attributeValue); }
From source file:com.netsteadfast.greenstep.aspect.AspectConstants.java
public static boolean isLogicService(String serviceId) { if (StringUtils.defaultString(serviceId).indexOf(".service.logic.") > -1) { return true; }/*from w w w.j av a 2 s .c o m*/ return false; }
From source file:com.salesforce.ide.ui.handlers.OpenBrowserToExternalSiteHandler.java
@Override public Object execute(final ExecutionEvent event) throws ExecutionException { final IWorkbench workbench = HandlerUtil.getActiveWorkbenchWindowChecked(event).getWorkbench(); final String urlText = StringUtils.defaultString(event.getParameter(PARAM_ID_URL)); try {//from w ww . j av a 2 s . co m URL url = new URL(urlText); if (logger.isDebugEnabled()) { logger.debug("Opening browser to '" + url + "'"); } workbench.getBrowserSupport().getExternalBrowser().openURL(url); } catch (Exception e) { logger.error("Unable to open default browser to " + urlText, e); Utils.openError(e, "Unable to open default browser to " + urlText + ":\n\n" + e.getMessage(), null); } return null; }
From source file:com.netsteadfast.greenstep.bsc.util.BscReportPropertyUtils.java
private static String getParameterValue(String code) { List<TbSysCode> sysCodeList = sysCodeThreadLocal.get(); if (sysCodeList == null) { return code; }//from w w w. j a v a2s . c om String value = ""; for (TbSysCode sysCode : sysCodeList) { if (sysCode.getCode().equals(code)) { value = StringUtils.defaultString(sysCode.getParam1()); } } if (StringUtils.isBlank(value)) { return code; } return value; }
From source file:com.thoughtworks.go.server.service.SystemService.java
public boolean isAbsolutePath(String artifactsDir) { return new File(StringUtils.defaultString(artifactsDir)).isAbsolute(); }