/** * Check that the given String is neither <code>null</code> nor of length 0. * Note: Will return <code>true</code> for a String that purely consists of * whitespace. * * @param str * the String to check (may be <code>null</code>) * @return <code>true</code> if the String is not null and has length * @see #hasLength(CharSequence) */ private static boolean hasLength(final String str) { return hasLength((CharSequence) str); } }
/** * Check that the given String is neither <code>null</code> nor of length 0. * Note: Will return <code>true</code> for a String that purely consists of * whitespace. * * @param str * the String to check (may be <code>null</code>) * @return <code>true</code> if the String is not null and has length * @see #hasLength(CharSequence) */ private static boolean hasLength(final String str) { return hasLength((CharSequence) str); } }
/** * Delete any character in a given String. * * @param inString * the original String * @param charsToDelete * a set of characters to delete. E.g. "az\n" will delete 'a's, 'z's * and new lines. * @return the resulting String */ private static String deleteAny(final String inString, final String charsToDelete) { if (!hasLength(inString) || !hasLength(charsToDelete)) { return inString; } final StringBuffer out = new StringBuffer(); for (int i = 0; i < inString.length(); i++) { final char c = inString.charAt(i); if (charsToDelete.indexOf(c) == -1) { out.append(c); } } return out.toString(); }
/** * Delete any character in a given String. * * @param inString * the original String * @param charsToDelete * a set of characters to delete. E.g. "az\n" will delete 'a's, 'z's * and new lines. * @return the resulting String */ private static String deleteAny(final String inString, final String charsToDelete) { if (!hasLength(inString) || !hasLength(charsToDelete)) { return inString; } final StringBuffer out = new StringBuffer(); for (int i = 0; i < inString.length(); i++) { final char c = inString.charAt(i); if (charsToDelete.indexOf(c) == -1) { out.append(c); } } return out.toString(); }