package com.sun.j2ee.blueprints.waf.view.template;
import java.util.HashMap;
public class Screens implements java.io.Serializable {
private HashMap screenMap;
private HashMap templateMap;
private String defaultTemplate;
public Screens (String defaultTemplate) {
screenMap = new HashMap();
templateMap = new HashMap();
this.defaultTemplate = defaultTemplate;
}
public String getDefaultTemplate() {
return defaultTemplate;
}
public void addScreen(String screenName, Screen screen) {
if (screenMap.containsKey(screenName)) {
screenMap.remove(screenName);
}
screenMap.put(screenName, screen);
}
public void addTemplate(String templateName, String templateURL) {
if (templateMap.containsKey(templateName)) {
templateMap.remove(templateName);
}
templateMap.put(templateName, templateURL);
}
public Screen getScreen(String screenName) {
if (screenMap.containsKey(screenName)) {
return (Screen)screenMap.get(screenName);
} else {
System.err.println("Screens Error: Screen " + screenName + " not defined.");
return null;
}
}
public boolean containsScreen(String screenName) {
return screenMap.containsKey(screenName);
}
public boolean containsTemplate(String templateName) {
return templateMap.containsKey(templateName);
}
public String getTemplate(String screenName) {
if (screenMap.containsKey(screenName)) {
String templateName = ((Screen)screenMap.get(screenName)).getTemplate();
if ((templateName != null) && templateMap.containsKey(templateName)) {
return (String)templateMap.get(templateName);
} else {
return defaultTemplate;
}
} else {
System.err.println("Screens:getTemplate() error: Screen " + screenName + " not defined.");
return null;
}
}
public String toString() {
return "[Screens: defaultTemplate=" + defaultTemplate + ", " +
"screenMap=" + screenMap +
"templateMap=" + templateMap + "]";
}
}