Java Utililty Methods String Normalize

List of utility methods to do String Normalize

Description

The list of methods to do String Normalize are organized into topic(s).

Method

Stringnormalize(String text)
normalize
StringBuilder builder = new StringBuilder();
int index = 0;
int quote = 0;
text = text.trim();
while (index < text.length()) {
    char c = text.charAt(index);
    if (Character.isWhitespace(c) || Character.isSpaceChar(c))
        c = ' ';
...
Stringnormalize(String text)
Removes diacritics from UTF-8
String result = text;
try {
    while (result.length() > 1 && !Character.isAlphabetic(result.charAt(0))) {
        if (result.length() > 1) {
            result = result.substring(1, result.length());
    result = Normalizer.normalize(result.toLowerCase(), Normalizer.Form.NFD);
...
Stringnormalize(String uri)
Normalize a uri containing ../ and ./ paths.
if ("".equals(uri)) {
    return uri;
int leadingSlashes;
for (leadingSlashes = 0; leadingSlashes < uri.length()
        && uri.charAt(leadingSlashes) == '/'; ++leadingSlashes) {
boolean isDir = (uri.charAt(uri.length() - 1) == '/');
...
Stringnormalize(String value)
normalize
String temp = Normalizer.normalize(value, Normalizer.Form.NFD);
Pattern pattern = Pattern.compile("\\p{InCombiningDiacriticalMarks}+");
return pattern.matcher(temp).replaceAll("");
Stringnormalize(String value, Locale locale)
normalize
if (value == null) {
    return null;
final DecimalFormatSymbols symbols = getDecimalFormatSymbols(locale);
final char groupingSep = symbols.getGroupingSeparator();
final char decimalSep = symbols.getDecimalSeparator();
final StringBuilder sb = new StringBuilder(20);
for (int i = 0; i < value.length(); ++i) {
...
StringnormalizeCutter(String cutter, int numDigits)
normalize the cutter string for shelf list sorting - make number into decimal of the number of digits indicated by param
String result = null;
if (cutter != null && cutter.length() > 0) {
    String cutLets = getLCstartLetters(cutter);
    String cutDigs = cutter.substring(cutLets.length());
    String norm = null;
    if (cutDigs != null && cutDigs.length() > 0) {
        try {
            Integer.parseInt(cutDigs);
...
StringnormalizeDose(String dose)
Normalize dose
if (dose.trim().equals(""))
    return "";
dose = dose.replace("milligrams", "mg").replace("milligram", "mg");
dose = dose.replaceAll("[ ]*\\,[ ]*", "");
java.text.DecimalFormat df = new java.text.DecimalFormat("##.######");
Pattern p = Pattern.compile("\\d*\\.?\\d*mcg");
Matcher m = p.matcher(dose);
if (m.find()) {
...
StringnormalizeEnglishIdentifier(String id)
Remove anything that is not English letters or digits from the string and convert what wasn't removed to lower case.
return Normalizer.normalize(id, Normalizer.Form.NFD).replaceAll("[^a-zA-Z0-9]", "")
        .toLowerCase();
StringnormalizeFieldNameOrPath(final String nameOrPath)
Normalize field name or path.
assertNotNull(nameOrPath, "Name of path must not be null");
return nameOrPath.trim().toLowerCase(Locale.ENGLISH);
StringnormalizeIndex(String input, String[] indexList)
normalize Index
String normalizedStr = Normalizer.normalize(input, Form.NFKD).toUpperCase();
normalizedStr = normalizedStr.substring(0, 1);
if (Arrays.asList(indexList).contains(normalizedStr)) {
    return normalizedStr;
} else {
    return "Char";