2 * (c) Copyright IBM Corp. 2000, 2001.
5 package net.sourceforge.phpdt.internal.corext.template;
7 import java.util.HashMap;
8 import java.util.Iterator;
11 import net.sourceforge.phpdt.internal.corext.template.php.HTMLContextType;
12 import net.sourceforge.phpdt.internal.corext.template.php.PHPContextType;
17 * A singleton to keep track of all known context types.
19 public class ContextTypeRegistry {
22 private static ContextTypeRegistry fInstance;
24 /** all known context types */
25 private final Map fContextTypes= new HashMap();
28 * Returns the single instance of this class.
30 public static ContextTypeRegistry getInstance() {
31 if (fInstance == null)
32 fInstance= new ContextTypeRegistry();
38 * Adds a context type to the registry.
40 public void add(ContextType contextType) {
41 fContextTypes.put(contextType.getName(), contextType);
45 * Removes a context type from the registry.
47 public void remove(ContextType contextType) {
48 fContextTypes.remove(contextType.getName());
52 * Returns the context type if the name is valid, <code>null</code> otherwise.
54 public ContextType getContextType(String name) {
55 return (ContextType) fContextTypes.get(name);
59 * Returns an iterator over the registered context type names.
61 public Iterator iterator() {
62 return fContextTypes.keySet().iterator();
65 // XXX bootstrap with java and javadoc context types
66 private ContextTypeRegistry() {
67 add(new PHPContextType());
68 add(new HTMLContextType());