Example usage for org.apache.commons.lang StringUtils containsAny

List of usage examples for org.apache.commons.lang StringUtils containsAny

Introduction

In this page you can find the example usage for org.apache.commons.lang StringUtils containsAny.

Prototype

public static boolean containsAny(String str, String searchChars) 

Source Link

Document

Checks if the String contains any character in the given set of characters.

Usage

From source file:org.tonguetied.web.BundleValidator.java

/**
 * This validation method checks if the bundle resource name contains any
 * invalid characters./*from  w  w w.j a  v  a  2 s  . co m*/
 * 
 * @param bundle the {@link Bundle} object to validate
 * @param errors contextual state about the validation process (never null)
 * @see Character#isWhitespace(char)
 */
private void validateCharacterSet(final Bundle bundle, Errors errors) {
    //TODO: use a regular expression for this.
    if (StringUtils.containsAny(bundle.getResourceName(), WHITESPACE_CHARS)) {
        errors.rejectValue(FIELD_RESOURCE_NAME, "error.resource.name.contains.invalid.char",
                new String[] { bundle.getResourceName() }, "default");
    }
    //        if (bundle.getResourceName() != null)
    //        {
    //            final Matcher m = 
    //                resourceNamePattern.matcher(bundle.getResourceName());
    //            if (m.matches())
    //            {
    //                errors.rejectValue(FIELD_RESOURCE_NAME,
    //                        "error.resource.name.contains.invalid.char",
    //                        new String[] { bundle.getResourceName() }, "default");
    //            }
    //        }
}

From source file:piuk.blockchain.android.MyWallet.java

public boolean addTxNote(String hash, String note) throws Exception {
    //Disallow quotes and < >
    if (StringUtils.containsAny(note, "\"'<>")) {
        throw new Exception("Note contains invalid characters");
    }//from w  w  w . j a v a  2 s.  c  om

    getTxNotes().put(hash.toString(), note);

    return true;
}

From source file:piuk.blockchain.android.MyWallet.java

public boolean addTxNote(Hash hash, String note) throws Exception {
    //Disallow quotes and < >
    if (StringUtils.containsAny(note, "\"'<>")) {
        throw new Exception("Note contains invalid characters");
    }/*  w ww.ja va2 s .co  m*/

    getTxNotes().put(hash.toString(), note);

    return true;
}

From source file:raptor.connector.ics.chat.PartnerTellEventParser.java

/**
 * Returns null if text does not match the event this class produces.
 *///from  w w  w .jav a2  s.  c  om
@Override
public ChatEvent parse(String text) {
    if (text.length() < 600) {
        text = text.trim();
        RaptorStringTokenizer tok = new RaptorStringTokenizer(text, " \r\n", true);
        if (tok.hasMoreTokens()) {
            String source = tok.nextToken();
            if (StringUtils.containsAny(source, "1234567890")) {
                return null;
            }

            if (source.endsWith("%")) {
                source = tok.nextToken();
            }
            if (tok.hasMoreTokens()) {
                String s2 = tok.nextToken();
                if (s2.equals("(your")) {
                    return new ChatEvent(IcsUtils.stripTitles(source).trim(), ChatType.PARTNER_TELL,
                            text.trim());

                }
            }
        }
        return null;
    }
    return null;
}