01: /**********************************************************************************
02: * $URL: https://source.sakaiproject.org/svn/util/tags/sakai_2-4-1/util-util/util/src/java/org/sakaiproject/util/ArrayUtil.java $
03: * $Id: ArrayUtil.java 7914 2006-04-18 18:11:25Z ggolden@umich.edu $
04: ***********************************************************************************
05: *
06: * Copyright (c) 2006 The Sakai Foundation.
07: *
08: * Licensed under the Educational Community License, Version 1.0 (the "License");
09: * you may not use this file except in compliance with the License.
10: * You may obtain a copy of the License at
11: *
12: * http://www.opensource.org/licenses/ecl1.php
13: *
14: * Unless required by applicable law or agreed to in writing, software
15: * distributed under the License is distributed on an "AS IS" BASIS,
16: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17: * See the License for the specific language governing permissions and
18: * limitations under the License.
19: *
20: **********************************************************************************/package org.sakaiproject.util;
21:
22: /**
23: * <p>
24: * ArrayUtil collects together some Array utility methods.
25: * </p>
26: */
27: public class ArrayUtil {
28: /**
29: * Search for an object in an array.
30: *
31: * @param target
32: * The target array
33: * @param search
34: * The object to search for.
35: * @return true if search is "in" (equal to any object in) the target, false if not
36: */
37: public static boolean contains(Object[] target, Object search) {
38: if ((target == null) || (search == null))
39: return false;
40: if (target.length == 0)
41: return false;
42: try {
43: for (int i = 0; i < target.length; i++) {
44: if (search.equals(target[i]))
45: return true;
46: }
47: } catch (Throwable e) {
48: return false;
49: }
50:
51: return false;
52: }
53: }
|