Java Code Examples for org.apache.commons.lang.StringUtils#normalizeSpace()
The following examples show how to use
org.apache.commons.lang.StringUtils#normalizeSpace() .
These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: oxAuth File: RequestWrapper.java License: MIT License | 6 votes |
public String getContent() { try { if (this.parameterMap.isEmpty()) { if (ArrayUtils.isEmpty(content)) content = IOUtils.toByteArray(delegate.getInputStream()); else content = IOUtils.toByteArray(new LoggingServletInputStream(content)); } else { content = getContentFromParameterMap(this.parameterMap); } String requestEncoding = delegate.getCharacterEncoding(); String normalizedContent = StringUtils.normalizeSpace(new String(content, requestEncoding != null ? requestEncoding : StandardCharsets.UTF_8.name())); return StringUtils.isBlank(normalizedContent) ? null : normalizedContent; } catch (IOException e) { throw new IllegalStateException(); } }
Example 2
Source Project: Skript File: AliasesParser.java License: GNU General Public License v3.0 | 5 votes |
/** * Fixes an alias name by trimming it and removing all extraneous spaces * between the words. * @param name Name to be fixed. * @return Name fixed. */ protected String fixName(String name) { String result = StringUtils.normalizeSpace(name); int i = result.indexOf('¦'); if (i != -1 && Character.isWhitespace(result.codePointBefore(i))) result = result.substring(0, i - 1) + result.substring(i); return result; }
Example 3
Source Project: dkpro-jwpl File: TextPair.java License: Apache License 2.0 | 5 votes |
/** * Normalizes the Strings in the TextPair. * This mainly deals with whitespace-issues. * Other normalizations can be included. * * @param str * @return */ private String normalize(String str){ str = StringUtils.trimToEmpty(str); str = StringUtils.normalizeSpace(str); // remove whitespace before punctuation. not using \p{Punct}, // because it includes to many special characters. str = str.replaceAll("\\s+(?=[.!,\\?;:])", ""); return str; }