List of usage examples for org.apache.commons.lang StringUtils stripToEmpty
public static String stripToEmpty(String str)
Strips whitespace from the start and end of a String returning an empty String if null
input.
From source file:com.adobe.acs.tools.tag_maker.tagdataconverters.impl.LocalizedTitleAndNodeNameConverterImpl.java
@Override public final TagData convert(String data) { data = StringUtils.stripToEmpty(data); Map<String, String> localizedTitles = new TreeMap<String, String>(); String name;//from w ww.ja v a2 s . co m String title = ""; final Matcher matcher = NODE_NAME_PATTERN.matcher(data); if (matcher.find() && matcher.groupCount() == 1) { name = StringUtils.stripToEmpty(matcher.group(1)); } else { return TagData.EMPTY; } final String rawLocalizedTitles = StringUtils.stripToEmpty(NODE_NAME_PATTERN.matcher(data).replaceAll("")); final Matcher localeMatch = LOCALIZED_TITLES_PATTERN.matcher(rawLocalizedTitles); String firstLocale = null; while (localeMatch.find()) { final String locale = StringUtils.stripToEmpty(localeMatch.group(1)); final String localeTitle = StringUtils.stripToEmpty(localeMatch.group(2)); if (firstLocale == null) { firstLocale = locale; } if (DEFAULT_LOCALE_KEY.equals(locale)) { title = localeTitle; } else { localizedTitles.put(locale, localeTitle); } } // It no default title was found, fall back to the first locale listed if (StringUtils.isEmpty(title) && firstLocale != null) { title = localizedTitles.get(firstLocale); } if (StringUtils.isEmpty(title)) { return TagData.EMPTY; } final TagData tagData = new TagData(name); tagData.setTitle(title); tagData.setLocalizedTitles(localizedTitles); return tagData; }
From source file:gov.nih.nci.calims2.ui.report.query.QueryForm.java
/** * Gets the clause rows from the request. * //from ww w. jav a 2 s. co m * @return The list of clause rows */ public List<ClauseRow> getClauseRows() { List<ClauseRow> rows = new ArrayList<ClauseRow>(); if (property != null) { for (int i = 0; i < property.size(); i++) { String propertyName = StringUtils.trimToEmpty(property.get(i)); if (StringUtils.isNotEmpty(propertyName)) { ClauseRow row = new ClauseRow(); row.setPropertyName(propertyName); row.setPropertyType(StringUtils.stripToEmpty(propertyType.get(i))); row.setOperator(Operator.valueOf(operator.get(i))); row.setValue(StringUtils.stripToEmpty(value.get(i))); if (connector != null && i < connector.size()) { String connectorName = StringUtils.stripToNull(connector.get(i)); if (connectorName != null) { row.setConnector(LogicalConnector.valueOf(connectorName)); } } row.setClauseIndex(i); rows.add(row); } } } return rows; }
From source file:com.adobe.acs.commons.contentfinder.querybuilder.impl.ContentFinderHitBuilder.java
/** * Derives and adds Page related information to the map representing the hit. * * @param hit//from ww w.j ava 2 s . com * @param map * @return * @throws javax.jcr.RepositoryException */ private static Map<String, Object> addPageData(final Page page, final Hit hit, Map<String, Object> map) throws RepositoryException { // Title String title = page.getName(); if (StringUtils.isNotBlank(page.getTitle())) { title = page.getTitle(); } else if (StringUtils.isNotBlank(page.getPageTitle())) { title = page.getPageTitle(); } else if (StringUtils.isNotBlank(page.getNavigationTitle())) { title = page.getNavigationTitle(); } // Excerpt String excerpt = hit.getExcerpt(); if (StringUtils.isBlank(hit.getExcerpt())) { excerpt = StringUtils.stripToEmpty(page.getDescription()); if (excerpt.length() > MAX_EXCERPT_LENGTH) { excerpt = StringUtils.substring(excerpt, 0, (MAX_EXCERPT_LENGTH - ELLIPSE_LENGTH)) + "..."; } } map.put(CF_PATH, page.getPath()); map.put(CF_NAME, page.getName()); map.put(CF_TITLE, title); map.put(CF_EXCERPT, excerpt); map.put(CF_DD_GROUPS, "page"); map.put(CF_TYPE, "Page"); map.put(CF_LAST_MODIFIED, getLastModified(page)); return map; }
From source file:com.adobe.acs.commons.forms.impl.FormImpl.java
@Override public String get(final String key) { final String val = this.data.get(key); return StringUtils.stripToEmpty(val); }
From source file:com.googlesource.gerrit.plugins.rabbitmq.Properties.java
public String getGerritFrontUrl() { return StringUtils .stripToEmpty(config.getString(Keys.GERRIT_FRONT_URL.section, null, Keys.GERRIT_FRONT_URL.name)); }
From source file:com.ansorgit.plugins.bash.editor.usages.BashFindUsagesProvider.java
@NotNull public String getDescriptiveName(@NotNull PsiElement element) { if (!canFindUsagesFor(element)) { return ""; }// ww w. j a v a 2 s. co m if (element instanceof BashCommand) { return StringUtils.stripToEmpty(((BashCommand) element).getReferencedCommandName()); } return StringUtils.stripToEmpty(((PsiNamedElement) element).getName()); }
From source file:com.adobe.acs.commons.forms.impl.FormImpl.java
@Override public String getError(final String key) { final String val = this.errors.get(key); return StringUtils.stripToEmpty(val); }
From source file:com.activecq.api.helpers.DesignHelper.java
/** * Returns an img tag for the image path supplied in the path parameter. * * @param path/* w w w .j a va 2 s. c o m*/ * @param page * @param attrs * @return */ public static String imgTag(String path, Page page, Map<String, String> attrs) { String src = imgSrc(path, page); if (StringUtils.isBlank(src)) { return "<!-- Missing Image : " + path + " -->"; } if (attrs == null) { attrs = new HashMap<String, String>(); } // Image alt if (!attrs.containsKey("alt")) { attrs.put("alt", ""); } // Begin writing img tag String html = "<img src=\"" + StringEscapeUtils.escapeHtml(src) + "\""; for (String key : attrs.keySet()) { final String attr = StringEscapeUtils.escapeHtml(StringUtils.stripToEmpty(attrs.get(key))); html += " " + key + "=\"" + attr + "\""; } html += "/>"; return html; }
From source file:com.googlesource.gerrit.plugins.rabbitmq.Properties.java
public String getGerritVersion() { return StringUtils.stripToEmpty(Version.getVersion()); }
From source file:com.adobe.acs.commons.forms.Form.java
/** * Gets the data associated with a Form data key * * @param key//from w ww .j a v a2 s . co m * @return */ public String get(final String key) { final String val = this.data.get(key); return StringUtils.stripToEmpty(val); }