View Javadoc

1   /*
2    * WebFlow Navigation Manager: webflow definiton, server side navigation history and automatic session cleaning.
3    * Distributed under LGPL license at web site http://wfnm.sourceforge.net .
4    */
5   package net.sf.wfnm;
6   
7   /***
8    * Utilities for Strings
9    *
10   * @author <a href="mailto:malbari@users.sourceforge.net">Maurizio Albari</a>
11   * @version 1.0.6
12   */
13  public class StringUtils {
14      /***
15       * Find a string into an array of strings (case insensitive)
16       *
17       * @param toSearch the string to be searched
18       * @param whereToSearch the array where the string is searched
19       *
20       * @return the index where the string has been found (-1=string not found)
21       */
22      public static int findIgnoreCase(String toSearch, String[] whereToSearch) {
23          int result = -1;
24  
25          if ((toSearch != null) && (whereToSearch != null)) {
26              for (int i = 0; (i < whereToSearch.length) && (result < 0); i++) {
27                  if (toSearch.equalsIgnoreCase(whereToSearch[i])) {
28                      result = i;
29                  }
30              }
31          }
32  
33          return result;
34      }
35  }