Android String Contain contains(String str, List keywords)

Here you can find the source of contains(String str, List keywords)

Description

contains

License

Apache License

Declaration

public static boolean contains(String str, List<String> keywords) 

Method Source Code

/**/*  w  w w. ja  v a2 s.  com*/
 * Copyright 2013 ??????
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import java.net.MalformedURLException;
import java.net.URL;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main{
    public static final int INDEX_NOT_FOUND = -1;
    
    public static boolean contains(String str, String searchStr) {
        if (str == null || searchStr == null) {
            return false;
        }
        return str.indexOf(searchStr) > INDEX_NOT_FOUND;
    }
    
    public static boolean contains(String[] str, String searchStr) {
        boolean val = false;
        if (str == null || searchStr == null) {
            return val;
        }
        for (String s : str) {
            if (StringUtil.equals(s, searchStr)) {
                val = true;
                break;
            }
        }
        return val;
    }
    
    public static boolean contains(String str, List<String> keywords) {
        if (str == null || keywords == null) {
            return false;
        }

        for (String key : keywords) {
            if (contains(str, key)) {
                return true;
            }
        }

        return false;
    }
    
    public static boolean equals(String str1, String str2) {
        return str1 == null ? str2 == null : str1.equals(str2);
    }
}

Related

  1. containsCharRef(String s)
  2. contains(final CharSequence seq, final CharSequence searchSeq)
  3. containCount(String str, String searchStr)
  4. contains(String str, String searchStr)
  5. contains(String[] str, String searchStr)
  6. cutWords(String src, String contains)
  7. cutWordsAll(String src, String contains)
  8. containsCharRef(String s)
  9. containsIgnoreCase(String str, String query)