Here you can find the source of arrayContainsOnlyIgnoreCase(String[] array, String... strs)
Parameter | Description |
---|---|
array | The String array to search with |
strs | The Strings to search for |
public static boolean arrayContainsOnlyIgnoreCase(String[] array, String... strs)
//package com.java2s; /******************************************************************************* * Copyright (c) 2015 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors://w ww .j av a 2 s. co m * IBM Corporation - initial API and implementation *******************************************************************************/ public class Main { /** * Returns true if and only if the String array contains only the given strings, case insensitive. * @param array The String array to search with * @param strs The Strings to search for * @return true if the String array contains only the given Strings, case insensitive; false otherwise. */ public static boolean arrayContainsOnlyIgnoreCase(String[] array, String... strs) { if (array.length == 0) { return false; } for (int i = 0; i < array.length; i++) { if (arrayContainsIgnoreCase(strs, array[i])) continue; else return false; } return true; } /** * Returns true if and only if the String array contains the given string, case insensitive. * @param array The String array to search with * @param str The String to search for * @return true if the String array contains the given String, case insensitive; false otherwise. */ public static boolean arrayContainsIgnoreCase(String[] array, String str) { if (array.length == 0) { return false; } for (int i = 0; i < array.length; i++) { if (array[i].equalsIgnoreCase(str)) return true; } return false; } /** * Tests whether two string are equal with ignoring the case. The difference to * String.equalsIgnoreCase is that in case s1 or s2 is null then this method returns * false. * * @param s1 first string to compare * @param s2 second string to comapre * @return true in case they are equal with ignore case */ public static boolean equalsIgnoreCase(String s1, String s2) { if (s1 == null || s2 == null) { return false; } return s1.equalsIgnoreCase(s2); } }