List of usage examples for com.google.common.base CharMatcher apply
@Deprecated @Override public boolean apply(Character character)
From source file:com.google.security.zynamics.zylib.general.Convert.java
/** * Tests whether a given string is a valid decimal string. * //from ww w . j a v a2s. co m * @param string The string to check. * * @return True, if the string is a valid decimal string. False, otherwise. */ public static boolean isDecString(final String string) { Preconditions.checkNotNull(string); final CharMatcher cm = CharMatcher.inRange('0', '9'); for (int i = 0; i < string.length(); i++) { if (!cm.apply(string.charAt(i))) { return false; } } return string.length() != 0; }
From source file:com.google.security.zynamics.zylib.general.Convert.java
/** * Tests whether a given string is a valid hexadecimal string. * /*from www. j a v a2 s . com*/ * @param string The string to check. * * @return True, if the string is a valid hexadecimal string. False, otherwise. */ public static boolean isHexString(final String string) { Preconditions.checkNotNull(string, "Error: String argument can't be null"); final CharMatcher cm = CharMatcher.inRange('0', '9').or(CharMatcher.inRange('a', 'z')) .or(CharMatcher.inRange('A', 'F')); for (int i = 0; i < string.length(); i++) { if (!cm.apply(string.charAt(i))) { return false; } } return string.length() != 0; }