package cc;
import java.util.Hashtable;

public class Parameters{
	private static int size = 7500;
	private static int delay = 30;
	private static String profile = "hard";
	private static int interval = 2;
	private static int duration = 0;
	private static int timeout = 60;
	
	private static int MAX_DATAGRAM_SIZE = 65507;
	private static int MIN_DATAGRAM_SIZE = 100;
    
	private static int MAX_DELAY = 120;
	private static int MIN_DELAY = 1;

	private static int MaxBucket = 25;
	private static String resend = "off";
	
	public static int getMaxSize(){
		return MAX_DATAGRAM_SIZE;
	}
	public static int getMinSize(){
		return MIN_DATAGRAM_SIZE;
	}
	public static int getMaxDelay(){
		return MAX_DELAY;
	}
	public static int getMinDelay(){
		return MIN_DELAY;
	}
	public static int getSize(){
		return size;
	}
	public static int getDelay(){
		return delay;
	}
	public static String getProfile(){
		return profile;
	}
	public static int getInterval(){
		return interval;
	}
	public static int getDuration(){
		return duration;
	}
	public static int getTimeout(){
		return timeout;
	}
	public static int getMaxBucket(){
		return MaxBucket;
	}
	public static String getResend(){
		return resend;
	}
	
	public static void prUsage(){
		System.out.println("java cc.Client -ORBIntialHost <host> -ORBIntialPort <port> -Diretive <value>");
		System.out.println();
		System.out.println("Default values:");
		System.out.println(" Profile = " + profile);
		System.out.println(" Size = " + size);
		System.out.println(" Delay = " + delay);
		System.out.println(" Interval = " + interval);
		System.out.println(" Duration = " + duration);
		System.out.println(" MaxSize = " + MAX_DATAGRAM_SIZE);
		System.out.println(" MinSize = " + MIN_DATAGRAM_SIZE);
		System.out.println(" MaxDelay = " + MAX_DELAY);
		System.out.println(" MinDelay = " + MIN_DELAY);
		System.out.println(" MaxBucket = " + MaxBucket);
		System.out.println(" Resend = " + resend);
		System.out.println();
		System.out.println();
		System.out.println("java cc.Server -ORBIntialHost <host> -ORBIntialPort <port> -Diretive <value>");
		System.out.println();
		System.out.println("Default values:");
		System.out.println(" Interval = " + interval);
		System.out.println(" Timeout = " + timeout);
	}

	
	public static void parseArgs (String Args[]){
		//Verify Args size
		if (Args.length == 0){
			prUsage();
			System.exit(0);
		}
			
		//Verify if Args size is even
		if (((float)Args.length / 2) > (Args.length / 2)){
			prUsage();
			System.exit(0);
		}

		Hashtable hashArgs = new Hashtable();
        
		for (int i=0 ; i<Args.length ; i+=2){
			hashArgs.put(Args[i], Args[i+1]);
		}
        
		if (hashArgs.containsKey("-Profile"))
			profile = (String) hashArgs.get("-Profile");
		if (hashArgs.containsKey("-Interval"))
			interval = (new Integer((String) hashArgs.get("-Interval"))).intValue();
		if (hashArgs.containsKey("-Duration"))
			duration = (new Integer((String) hashArgs.get("-Duration"))).intValue();
		if (hashArgs.containsKey("-Delay"))
			delay = (new Integer((String) hashArgs.get("-Delay"))).intValue();
		if (hashArgs.containsKey("-Size"))
			size = (new Integer((String) hashArgs.get("-Size"))).intValue();
		if (hashArgs.containsKey("-Timeout"))
			timeout = (new Integer((String) hashArgs.get("-Timeout"))).intValue();
		if (hashArgs.containsKey("-MaxSize"))
			MAX_DATAGRAM_SIZE = (new Integer((String) hashArgs.get("-MaxSize"))).intValue();
		if (hashArgs.containsKey("-MinSize"))
			MIN_DATAGRAM_SIZE = (new Integer((String) hashArgs.get("-MinSize"))).intValue();
		if (hashArgs.containsKey("-MaxDelay"))
			MAX_DELAY = (new Integer((String) hashArgs.get("-MaxDelay"))).intValue();
		if (hashArgs.containsKey("-MinDelay"))
			MIN_DELAY = (new Integer((String) hashArgs.get("-MinDelay"))).intValue();
		if (hashArgs.containsKey("-MaxBucket"))
			MaxBucket = (new Integer((String) hashArgs.get("-MaxBucket"))).intValue();
		if (hashArgs.containsKey("-Resend"))
			resend = (String) hashArgs.get("-Resend");
	}
}