/*
 * Created on Dec 5, 2004
 * Copyright (C) Andrea Schweer, 2004
 *
 * This file is part of the Greenstone Alerting Service.
 * Refer to the COPYING file in the base directory of this package
 * for licensing information.
 */
package org.greenstone.gsdlas.util;

import java.util.Arrays;

/**
 * @author andrea
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class ArrayHelper {
    static public boolean contains(String[] array, String element) {
        if (array == null || element == null) {
            return false;
        }
        Arrays.sort(array);
        int index = Arrays.binarySearch(array, element);
        return index > -1 && index <= array.length;
    }

    static public String toString(String [] array) {
	StringBuffer buffer = new StringBuffer();
	buffer.append("[");
	for (int i=0; i<array.length; i++) {
	    buffer.append((String)array[i]);
	    buffer.append(",");
	}
	buffer.append("]");
	return buffer.toString();

    }
}
