Android String Contain contains(String[] str, String searchStr)

Here you can find the source of contains(String[] str, String searchStr)

Description

contains

License

Apache License

Declaration

public static boolean contains(String[] str, String searchStr) 

Method Source Code

/**/*from  w  ww.ja  va 2 s  .c  o m*/
 * 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. checkContainSpace(final String x)
  2. containsCharRef(String s)
  3. contains(final CharSequence seq, final CharSequence searchSeq)
  4. containCount(String str, String searchStr)
  5. contains(String str, String searchStr)
  6. contains(String str, List keywords)
  7. cutWords(String src, String contains)
  8. cutWordsAll(String src, String contains)
  9. containsCharRef(String s)