001 /*
002 * $Id: StringHelper.java,v 1.3 2010/12/30 17:33:23 oboehm Exp $
003 *
004 * Copyright (c) 2010 by Oliver Boehm
005 *
006 * Licensed under the Apache License, Version 2.0 (the "License");
007 * you may not use this file except in compliance with the License.
008 * You may obtain a copy of the License at
009 *
010 * http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express orimplied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 *
018 * (c)reated 02.04.2010 by oliver (ob@oasd.de)
019 */
020
021 package patterntesting.runtime.util;
022
023 /**
024 * This class contains some useful helper methods for Strings.
025 *
026 * @author oliver
027 * @since 1.0 (02.04.2010)
028 * @see org.apache.commons.lang.StringUtils
029 */
030 public final class StringHelper {
031
032 /** It's a utility class - no need to instantiate it */
033 private StringHelper() {}
034
035 /**
036 * This helper method look in the given array, if there is a string with
037 * the given name (not case sensitive).
038 * <br/>
039 * NOTE: commons.lang.ArrayUtils provides a contains(..) method but
040 * unfortunately no containsIgnoreCase(..) method.
041 *
042 * @param names array with names
043 * @param name the searched name
044 * @return true, if name is inside names.
045 * @see org.apache.commons.lang.ArrayUtils
046 */
047 public static boolean containsIgnoreCase(final String[] names, final String name) {
048 for (int i = 0; i < names.length; i++) {
049 if (name.equalsIgnoreCase(names[i])) {
050 return true;
051 }
052 }
053 return false;
054 }
055
056 }
057