/** * <p>Checks that the String does not contain certain characters.</p> * * <p>A <code>null</code> String will return <code>true</code>. * A <code>null</code> invalid character array will return <code>true</code>. * An empty String ("") always returns true.</p> * * <pre> * StringUtils.containsNone(null, *) = true * StringUtils.containsNone(*, null) = true * StringUtils.containsNone("", *) = true * StringUtils.containsNone("ab", "") = true * StringUtils.containsNone("abab", "xyz") = true * StringUtils.containsNone("ab1", "xyz") = true * StringUtils.containsNone("abz", "xyz") = false * </pre> * * @param str the String to check, may be null * @param invalidChars a String of invalid chars, may be null * @return true if it contains none of the invalid chars, or is null * @since 2.0 */ public static boolean containsNone(String str, String invalidChars) { if (str == null || invalidChars == null) { return true; } return containsNone(str, invalidChars.toCharArray()); }
if (StringUtils.containsNone(str, CSV_SEARCH_CHARS)) { if (str != null) { out.write(str);
if (StringUtils.containsNone(str, CSV_SEARCH_CHARS)) { return str;
protected int countRowsOfTable(String tableName, ConnectionSupplier connectionSupplier) { checkArgument(StringUtils.containsNone(tableName, " "), "Parameter must be the name of a table. Got " + tableName); return countSql("select count(1) from " + tableName.toLowerCase(Locale.ENGLISH), connectionSupplier); }
/** * @return */ private boolean containsValidCharacters(String name, char[] invalidCharacters) { return org.apache.commons.lang.StringUtils.containsNone(name, invalidCharacters); }
/** * Checks that a string does not contain special characters (only * alphanumeric ones). * * @param string * the string to check * @return <code>true</code> if the strings contains a special character */ protected static boolean containsNoneSpecialChars(String string) { return StringUtils.containsNone(string, specialChars); }
protected String excelCSVFormat(String str) { if (!StringUtils.containsNone(str, "\n;")) { return "\"" + StringUtils.replace(str, "\"", "\"\"") + "\""; } return str; }
static boolean validValue(String value) { return StringUtils.isNotEmpty(value) && StringUtils.containsNone(value, "\n\r"); }
static boolean validValue(String value) { return StringUtils.isNotEmpty(value) && StringUtils.containsNone(value, "\n\r"); }
private static void quoteUnixShellArg(StringBuilder sb, String arg) { if (StringUtils.containsNone(arg, UNIX_SHELL_CHARS) && StringUtils.containsNone(arg, WS_CHARS) && StringUtils.containsNone(arg, " ")) { if (arg != null) { sb.append(arg); } return; } sb.append("'"); sb.append(arg.replace("'", "'\"'\"'")); sb.append("'"); }
/** * <p>Checks that the String does not contain certain characters.</p> * * <p>A <code>null</code> String will return <code>true</code>. * A <code>null</code> invalid character array will return <code>true</code>. * An empty String ("") always returns true.</p> * * <pre> * StringUtils.containsNone(null, *) = true * StringUtils.containsNone(*, null) = true * StringUtils.containsNone("", *) = true * StringUtils.containsNone("ab", "") = true * StringUtils.containsNone("abab", "xyz") = true * StringUtils.containsNone("ab1", "xyz") = true * StringUtils.containsNone("abz", "xyz") = false * </pre> * * @param str the String to check, may be null * @param invalidChars a String of invalid chars, may be null * @return true if it contains none of the invalid chars, or is null * @since 2.0 */ public static boolean containsNone(String str, String invalidChars) { if (str == null || invalidChars == null) { return true; } return containsNone(str, invalidChars.toCharArray()); }
/** * <p>Checks that the String does not contain certain characters.</p> * * <p>A <code>null</code> String will return <code>true</code>. * A <code>null</code> invalid character array will return <code>true</code>. * An empty String ("") always returns true.</p> * * <pre> * StringUtils.containsNone(null, *) = true * StringUtils.containsNone(*, null) = true * StringUtils.containsNone("", *) = true * StringUtils.containsNone("ab", "") = true * StringUtils.containsNone("abab", "xyz") = true * StringUtils.containsNone("ab1", "xyz") = true * StringUtils.containsNone("abz", "xyz") = false * </pre> * * @param str the String to check, may be null * @param invalidChars a String of invalid chars, may be null * @return true if it contains none of the invalid chars, or is null * @since 2.0 */ public static boolean containsNone(String str, String invalidChars) { if (str == null || invalidChars == null) { return true; } return containsNone(str, invalidChars.toCharArray()); }
/** * <p>Checks that the String does not contain certain characters.</p> * * <p>A <code>null</code> String will return <code>true</code>. * A <code>null</code> invalid character array will return <code>true</code>. * An empty String ("") always returns true.</p> * * <pre> * StringUtils.containsNone(null, *) = true * StringUtils.containsNone(*, null) = true * StringUtils.containsNone("", *) = true * StringUtils.containsNone("ab", "") = true * StringUtils.containsNone("abab", "xyz") = true * StringUtils.containsNone("ab1", "xyz") = true * StringUtils.containsNone("abz", "xyz") = false * </pre> * * @param str the String to check, may be null * @param invalidChars a String of invalid chars, may be null * @return true if it contains none of the invalid chars, or is null * @since 2.0 */ public static boolean containsNone(String str, String invalidChars) { if (str == null || invalidChars == null) { return true; } return containsNone(str, invalidChars.toCharArray()); }
/** * <p>Checks that the String does not contain certain characters.</p> * * <p>A <code>null</code> String will return <code>true</code>. * A <code>null</code> invalid character array will return <code>true</code>. * An empty String ("") always returns true.</p> * * <pre> * StringUtils.containsNone(null, *) = true * StringUtils.containsNone(*, null) = true * StringUtils.containsNone("", *) = true * StringUtils.containsNone("ab", "") = true * StringUtils.containsNone("abab", "xyz") = true * StringUtils.containsNone("ab1", "xyz") = true * StringUtils.containsNone("abz", "xyz") = false * </pre> * * @param str the String to check, may be null * @param invalidChars a String of invalid chars, may be null * @return true if it contains none of the invalid chars, or is null * @since 2.0 */ public static boolean containsNone(String str, String invalidChars) { if (str == null || invalidChars == null) { return true; } return containsNone(str, invalidChars.toCharArray()); }
/** * Escaping for csv format. * <ul> * <li>Quotes inside quoted strings are escaped with a /</li> * <li>Fields containings newlines or , are surrounded by "</li> * </ul> * Note this is the standard CVS format and it's not handled well by excel. * @see org.displaytag.export.BaseExportView#escapeColumnValue(java.lang.Object) */ protected String escapeColumnValue(Object value) { String stringValue = StringUtils.trim(value.toString()); if (!StringUtils.containsNone(stringValue, new char[]{'\n', ','})) { return "\"" + //$NON-NLS-1$ StringUtils.replace(stringValue, "\"", "\\\"") + "\""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } return stringValue; }
public static String escapeCsv(String str) { if (StringUtils.containsNone(str, CSV_SEARCH_CHARS)) { if (str != null) { return str; } return null; } StringBuilder _out = new StringBuilder(); _out.append(CSV_QUOTE); for (int i = 0; i < str.length(); i++) { char c = str.charAt(i); if (c == CSV_QUOTE) { _out.append(CSV_QUOTE); } _out.append(c); } return _out.append(CSV_QUOTE).toString(); }
public static void escapeChars(StringBuilder out, String str) { if (StringUtils.containsNone(str, CSV_SEARCH_CHARS) && !"".equals(str)) { if (str != null) { out.append(str); } return; } out.append(DBL_QUOTE); for (int i = 0; i < str.length(); i++) { char c = str.charAt(i); if (c == DBL_QUOTE) { out.append(DBL_QUOTE); // escape double quote } out.append(c); } out.append(DBL_QUOTE); }
public static void escapeUnixShellChars(StringBuilder out, String str, final String unixShellChars) { if (StringUtils.containsNone(str, unixShellChars)) { if (str != null) { out.append(str); } return; } for (int i = 0; i < str.length(); i++) { char c = str.charAt(i); if (unixShellChars.indexOf(c) >= 0) { out.append('\\'); }else if(WS_CHARS.indexOf(c)>=0){ out.append('\\'); if(c==CharUtils.CR){ out.append('r'); }else if(c==CharUtils.LF){ out.append('n'); }else if(c=='\t'){ out.append('t'); } continue; } out.append(c); } } }
if (StringUtils.containsNone(str, CSV_SEARCH_CHARS)) { return str;
public void validate() { CheckConditions.checkCondition(!RESERVED_FIELD_NAME.contains(getName()), new IllegalMetaClassException(String.format("Reserved meta field name %s!", getName()))); CheckConditions.checkCondition(!StringUtils.isNullOrEmpty(getName()), new IllegalMetaClassException("meta field name can not be empty")); CheckConditions.checkCondition(!StringUtils.isNullOrEmpty(getName().trim()), new IllegalMetaClassException("meta field name can not be empty")); CheckConditions.checkCondition(org.apache.commons.lang.StringUtils.containsNone(getName(),CMSConsts.INVALID_META_FIELD_NAME_CHARACTERS), new IllegalMetaClassException("meta field " + name + " cannot contains invalid characters: " + Arrays.toString(CMSConsts.INVALID_META_FIELD_NAME_CHARACTERS))); if(!isInternal()) { CheckConditions.checkCondition(!INVALID_PATTERN.matcher(getName()).matches(), new IllegalMetaClassException("meta field name can not start with regex _[A-Za-z0-9]: " + getName())); } }