/** * Assert that the given text does not contain the given substring. * <pre class="code">Assert.doesNotContain(name, "rod", "Name must not contain 'rod'");</pre> * @param textToSearch the text to search * @param substring the substring to find within the text * @param message the exception message to use if the assertion fails */ public static void doesNotContain(String textToSearch, String substring, String message) { if (StringUtils.hasLength(textToSearch) && StringUtils.hasLength(substring) && textToSearch.indexOf(substring) != -1) { throw new IllegalArgumentException(message); } }
/** * Assert that the given String is not empty; that is, * it must not be <code>null</code> and not the empty String. * <pre class="code">Assert.hasLength(name, "Name must not be empty");</pre> * @param text the String to check * @param message the exception message to use if the assertion fails * @see StringUtils#hasLength */ public static void hasLength(String text, String message) { if (!StringUtils.hasLength(text)) { throw new IllegalArgumentException(message); } }
/** * Check whether the given String has actual text. * More specifically, returns <code>true</code> if the string not <code>null</code>, * its length is greater than 0, and it contains at least one non-whitespace character. * <p/> * <code>StringUtils.hasText(null) == false<br/> * StringUtils.hasText("") == false<br/> * StringUtils.hasText(" ") == false<br/> * StringUtils.hasText("12345") == true<br/> * StringUtils.hasText(" 12345 ") == true</code> * <p/> * <p>Copied from the Spring Framework while retaining all license, copyright and author information. * * @param str the String to check (may be <code>null</code>) * @return <code>true</code> if the String is not <code>null</code>, its length is * greater than 0, and it does not contain whitespace only * @see java.lang.Character#isWhitespace */ public static boolean hasText(String str) { if (!hasLength(str)) { return false; } int strLen = str.length(); for (int i = 0; i < strLen; i++) { if (!Character.isWhitespace(str.charAt(i))) { return true; } } return false; }
/** * Creates a new {@code Ini} instance loaded with the INI-formatted data in the resource at the given path. The * resource path may be any value interpretable by the * {@link ResourceUtils#getInputStreamForPath(String) ResourceUtils.getInputStreamForPath} method. * * @param resourcePath the resource location of the INI data to load when creating the {@code Ini} instance. * @return a new {@code Ini} instance loaded with the INI-formatted data in the resource at the given path. * @throws ConfigurationException if the path cannot be loaded into an {@code Ini} instance. */ public static Ini fromResourcePath(String resourcePath) throws ConfigurationException { if (!StringUtils.hasLength(resourcePath)) { throw new IllegalArgumentException("Resource Path argument cannot be null or empty."); } Ini ini = new Ini(); ini.loadFromPath(resourcePath); return ini; }
ByteSource salt = null; if (StringUtils.hasLength(saltBase64)) { byte[] saltBytes = Base64.decode(saltBase64); salt = ByteSource.Util.bytes(saltBytes);
/** * Assert that the given String is not empty; that is, * it must not be <code>null</code> and not the empty String. * <pre class="code">Assert.hasLength(name, "Name must not be empty");</pre> * @param text the String to check * @param message the exception message to use if the assertion fails * @see StringUtils#hasLength */ public static void hasLength(String text, String message) { if (!StringUtils.hasLength(text)) { throw new IllegalArgumentException(message); } }
/** * Assert that the given text does not contain the given substring. * <pre class="code">Assert.doesNotContain(name, "rod", "Name must not contain 'rod'");</pre> * @param textToSearch the text to search * @param substring the substring to find within the text * @param message the exception message to use if the assertion fails */ public static void doesNotContain(String textToSearch, String substring, String message) { if (StringUtils.hasLength(textToSearch) && StringUtils.hasLength(substring) && textToSearch.indexOf(substring) != -1) { throw new IllegalArgumentException(message); } }
/** * Check whether the given String has actual text. * More specifically, returns <code>true</code> if the string not <code>null</code>, * its length is greater than 0, and it contains at least one non-whitespace character. * <p/> * <code>StringUtils.hasText(null) == false<br/> * StringUtils.hasText("") == false<br/> * StringUtils.hasText(" ") == false<br/> * StringUtils.hasText("12345") == true<br/> * StringUtils.hasText(" 12345 ") == true</code> * * <p>Copied from the Spring Framework while retaining all license, copyright and author information. * * @param str the String to check (may be <code>null</code>) * @return <code>true</code> if the String is not <code>null</code>, its length is * greater than 0, and it does not contain whitespace only * @see java.lang.Character#isWhitespace */ public static boolean hasText(String str) { if (!hasLength(str)) { return false; } int strLen = str.length(); for (int i = 0; i < strLen; i++) { if (!Character.isWhitespace(str.charAt(i))) { return true; } } return false; }
/** * Check whether the given String has actual text. * More specifically, returns <code>true</code> if the string not <code>null</code>, * its length is greater than 0, and it contains at least one non-whitespace character. * <p/> * <code>StringUtils.hasText(null) == false<br/> * StringUtils.hasText("") == false<br/> * StringUtils.hasText(" ") == false<br/> * StringUtils.hasText("12345") == true<br/> * StringUtils.hasText(" 12345 ") == true</code> * <p/> * <p>Copied from the Spring Framework while retaining all license, copyright and author information. * * @param str the String to check (may be <code>null</code>) * @return <code>true</code> if the String is not <code>null</code>, its length is * greater than 0, and it does not contain whitespace only * @see java.lang.Character#isWhitespace */ public static boolean hasText(String str) { if (!hasLength(str)) { return false; } int strLen = str.length(); for (int i = 0; i < strLen; i++) { if (!Character.isWhitespace(str.charAt(i))) { return true; } } return false; }
/** * Creates a new {@code Ini} instance loaded with the INI-formatted data in the resource at the given path. The * resource path may be any value interpretable by the * {@link ResourceUtils#getInputStreamForPath(String) ResourceUtils.getInputStreamForPath} method. * * @param resourcePath the resource location of the INI data to load when creating the {@code Ini} instance. * @return a new {@code Ini} instance loaded with the INI-formatted data in the resource at the given path. * @throws ConfigurationException if the path cannot be loaded into an {@code Ini} instance. */ public static Ini fromResourcePath(String resourcePath) throws ConfigurationException { if (!StringUtils.hasLength(resourcePath)) { throw new IllegalArgumentException("Resource Path argument cannot be null or empty."); } Ini ini = new Ini(); ini.loadFromPath(resourcePath); return ini; }
ByteSource salt = null; if (StringUtils.hasLength(saltBase64)) { byte[] saltBytes = Base64.decode(saltBase64); salt = ByteSource.Util.bytes(saltBytes);