package com.udapsoft.waf.system.handler.dao;

import java.util.HashMap;
import java.util.Iterator;

public class EventMappings {

	HashMap<String, EventMapping> eventMappingHashMap = null;

	public EventMappings() {
		eventMappingHashMap = new HashMap<String, EventMapping>();
	}

	public void put(String screen, String event, EventMapping eventMapping) {
		this.eventMappingHashMap.put(key(screen, event), eventMapping);
	}

	public EventMapping get(String screen, String event) {
		return (EventMapping) eventMappingHashMap.get(key(screen, event));
	}

	public int size() {
		return this.eventMappingHashMap.size();
	}

	private String key(String screen, String event) {
		return screen + "!" + event;
	}

	public String toString() {
		String str = "";
		int i = 0;
		for (Iterator<String> itr = eventMappingHashMap.keySet().iterator(); itr.hasNext(); i++) {
			String key = (String) itr.next();
			str += "index(" + i + ")=" + this.eventMappingHashMap.get(key).toString() + "\n";
		}
		return str;
	}
}
