GP-5475 changed composite field names so that any whitespace is converted to underscores

This commit is contained in:
ghidragon 2025-03-14 14:36:39 -04:00
parent 5a31ded2e0
commit 0ea4e754b9
10 changed files with 139 additions and 133 deletions

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -1207,4 +1207,17 @@ public class StringUtilities {
public static String wrapToWidth(String str, int width) {
return new LineWrapper(width).append(str).finish();
}
/**
* Removes any whitespace from start or end of string, then replaces any non-printable
* character (< 32) or spaces (32) with an underscore.
* @param s the string to adjust
* @return a new trimmed string with underscores replacing any non-printable characters.
*/
public static String whitespaceToUnderscores(String s) {
if (s == null) {
return null;
}
return s.trim().replaceAll("[\\x00-\\x20]", "_");
}
}