summaryrefslogtreecommitdiffstats
path: root/common-app-api/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'common-app-api/src/main/java')
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/common/util/ValidationUtils.java30
1 files changed, 29 insertions, 1 deletions
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/util/ValidationUtils.java b/common-app-api/src/main/java/org/openecomp/sdc/common/util/ValidationUtils.java
index 0ee097b979..adfa457166 100644
--- a/common-app-api/src/main/java/org/openecomp/sdc/common/util/ValidationUtils.java
+++ b/common-app-api/src/main/java/org/openecomp/sdc/common/util/ValidationUtils.java
@@ -259,7 +259,35 @@ public class ValidationUtils {
}
public static String normaliseWhitespace(String str) {
- return StringUtil.normaliseWhitespace(str);
+ StringBuilder sb = new StringBuilder(str.length());
+ appendNormalisedWhitespace(sb, str, false);
+ return sb.toString();
+ }
+
+ private static void appendNormalisedWhitespace(StringBuilder accum, String string, boolean stripLeading) {
+ boolean lastWasWhite = false;
+ boolean reachedNonWhite = false;
+
+ int len = string.length();
+ int c;
+ for (int i = 0; i < len; i+= Character.charCount(c)) {
+ c = string.codePointAt(i);
+ if (isWhitespace(c)) {
+ if ((stripLeading && !reachedNonWhite) || lastWasWhite)
+ continue;
+ accum.append(' ');
+ lastWasWhite = true;
+ }
+ else {
+ accum.appendCodePoint(c);
+ lastWasWhite = false;
+ reachedNonWhite = true;
+ }
+ }
+ }
+
+ private static boolean isWhitespace(int c){
+ return c == ' ';
}
public static String stripOctets(String str) {