public static String normalizeTextValue(final String theString) {
        if (null != theString && theString.length() > 0) {
            return theString.replaceAll("[\\s\\n]+", " ").trim();
        }
        return theString;
    }
public static String normalizeTextValue ( final String theString ) { if ( null != theString && theString . length ( ) > 0 ) { return theString . replaceAll ( "[\\s\\n]+" , " " ) . trim ( ) ; } return theString ; }
Method equals to the normalize-space xslt function

@param theString string to normalize
@return normalized string