MCPcopy Create free account
hub / github.com/banq/jdonframework / isWhitespace

Method isWhitespace

src/main/java/com/jdon/util/UtilValidate.java:209–224  ·  view source on GitHub ↗

Returns true if string s is empty or whitespace characters only.

(String s)

Source from the content-addressed store, hash-verified

207
208 /** Returns true if string s is empty or whitespace characters only. */
209 public static boolean isWhitespace(String s) {
210 // Is s empty?
211 if (isEmpty(s)) return true;
212
213 // Search through string's characters one by one
214 // until we find a non-whitespace character.
215 // When we do, return false; if we don't, return true.
216 for (int i = 0; i < s.length(); i++) {
217 // Check that current character isn't whitespace.
218 char c = s.charAt(i);
219
220 if (whitespace.indexOf(c) == -1) return false;
221 }
222 // All characters are whitespace.
223 return true;
224 }
225
226 /** Removes all characters which appear in string bag from string s. */
227 public static String stripCharsInBag(String s, String bag) {

Callers 1

isEmailMethod · 0.95

Calls 1

isEmptyMethod · 0.95

Tested by

no test coverage detected