/*
 * Copyright (C) 1999-2006 <a href="mailto:paschke@in.tum.de">Adrian Paschke</a>
 * 
 * The Utils Library is part of the Rule Based Service Level Agreement (RBSLA)
 * framework, available at 
 * <a href=" http://ibis.in.tum.de/staff/paschke/rbsla/index.htm">RBSLA</a>
 * 
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
package rbsla.utils;

import java.io.IOException;
import java.net.URL;
import java.net.URLConnection;
import java.util.Calendar;

public class WebsiteAvailable 
{
	
	
	public static Boolean testWebserver(String u) 
	{
		try{
			u = u.replaceAll("\"","");
			URL url = new URL(u);
		    URLConnection connect = url.openConnection();
		    connect.connect();				
			return Boolean.TRUE;

		} catch (IOException e) {               // openConnection() failed
			
			return Boolean.FALSE;
		}
	}
	

	public static Calendar getDate() {
		return Calendar.getInstance();
	}
	
	public static Boolean waiter(Integer value) 
	{
		try{					
			Calendar currentTime = Calendar.getInstance();
			
			currentTime.add(Calendar.SECOND, value.intValue());
			//System.out.println("Start Waiter");
			while (currentTime.after(Calendar.getInstance())) {}
			//System.out.println("Waiter end");
			return Boolean.TRUE;

		} catch (Exception e) {               // openConnection() failed
			
			return Boolean.FALSE;
		}
	}
	
	public static Boolean test() {return Boolean.TRUE;}
}
