summaryrefslogtreecommitdiffstats
path: root/org/madore/damlengine/TodoElement.java
blob: e2293efa58d7b1f1df67b540349aaa07ee08f22e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package org.madore.damlengine;

import java.util.Map;
import java.util.HashMap;
import org.w3c.dom.Element;

public abstract class TodoElement extends TodoItem {

    public static abstract class Factory {
	public abstract TodoElement newItem(Element node,
					    Map<String,Object> context,
					    Map<String,Object> options);
    }

    protected static Map<String,Factory> damlFactories;
    protected static Factory damlDefaultFactory;

    static {
	damlFactories = new HashMap<String,Factory>();
	damlDefaultFactory = new TodoDefaultElement.Factory();
    }

    Element node;
    Map<String,Object> context;
    Map<String,Object> options;

    public TodoElement(Element node, Map<String,Object> context, Map<String,Object> options) {
	this.node = node;
	this.context = context;
	this.options = options;
    }

    public static TodoElement getTodoElement(Element node,
					     Map<String,Object> context,
					     Map<String,Object> options) {
	Factory factory = null;
	String nsuri = node.getNamespaceURI();
	if ( nsuri != null && nsuri.equals(DamlEngine.DAML_NS) )
	    factory = damlFactories.get(node.getLocalName());
	if ( factory == null )
	    factory = damlDefaultFactory;
	return factory.newItem(node, context, options);
    }

}