Java Collection Contain containsIgnoreCase(String searchedWord, Collection words)

Here you can find the source of containsIgnoreCase(String searchedWord, Collection words)

Description

contains Ignore Case

License

Open Source License

Declaration

public static boolean containsIgnoreCase(String searchedWord, Collection<String> words) 

Method Source Code


//package com.java2s;
/*//from  ww  w.j av a  2 s  . c  o  m
 * (c) Copyright 2007-2012 by Volker Bergmann. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, is permitted under the terms of the
 * GNU General Public License.
 *
 * For redistributing this software or a derivative work under a license other
 * than the GPL-compatible Free Software License as defined by the Free
 * Software Foundation or approved by OSI, you must first obtain a commercial
 * license to this software product from Volker Bergmann.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * WITHOUT A WARRANTY OF ANY KIND. ALL EXPRESS OR IMPLIED CONDITIONS,
 * REPRESENTATIONS AND WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE
 * HEREBY EXCLUDED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */

import java.util.*;

public class Main {
    public static boolean containsIgnoreCase(String searchedWord, Collection<String> words) {
        for (String name : words)
            if (name.equalsIgnoreCase(searchedWord))
                return true;
        return false;
    }

    public static boolean containsIgnoreCase(String searchedWord, String[] words) {
        for (String name : words)
            if (name.equalsIgnoreCase(searchedWord))
                return true;
        return false;
    }

    public static boolean equalsIgnoreCase(String s1, String s2) {
        return (s1 != null ? s1.equalsIgnoreCase(s2) : s2 == null);
    }

    public static boolean equalsIgnoreCase(String[] a1, String[] a2) {
        if (a1.length != a2.length)
            return false;
        for (int i = 0; i < a1.length; i++)
            if (!equalsIgnoreCase(a1[i], a2[i]))
                return false;
        return true;
    }

    public static boolean equalsIgnoreCase(Set<String> set1, Set<String> set2) {
        if (set1.size() != set2.size())
            return false;
        for (String s1 : set1) {
            boolean found = false;
            for (String s2 : set2)
                if (equalsIgnoreCase(s1, s2))
                    found = true;
            if (!found)
                return false;
        }
        return true;
    }
}

Related

  1. containsIgnoreCase(Collection c, String s)
  2. containsIgnoreCase(Collection c, String str)
  3. containsIgnoreCase(Collection collection, String testString)
  4. containsIgnoreCase(Collection collection, String value)
  5. containsIgnoreCase(Collection l, String s)
  6. containsIgnoreCase4Collections(Collection c, String s)
  7. containsInstance(Collection collection, Object element)
  8. containsInstance(Collection collection, Object element)
  9. containsInstanceOf(Collection collection, Class c)