summaryrefslogtreecommitdiffstats
path: root/org/madore/damlengine/TodoAttr.java
blob: 0cc538939c30bf8871474186cfdd97301881d9a8 (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;
import org.w3c.dom.Attr;

public abstract class TodoAttr extends TodoItem {

    public static abstract class Factory {
	public abstract TodoAttr newItem(Attr attr, Element owner,
					 TodoContext context,
					 TodoItem.Options options);
    }

    protected static Map<String,Factory> damlAttrFactories;

    static {
	damlAttrFactories = new HashMap<String,Factory>();
	damlAttrFactories.put("xempty", new TodoXemptyAttr.Factory());
    }

    Attr attr;
    Element owner;

    public TodoAttr(Attr attr, Element owner,
		    TodoContext context, TodoItem.Options options) {
	super(context, options);
	this.attr = attr;
	this.owner = owner;
    }

    public static TodoAttr getTodoAttr(Attr attr, Element owner,
				       TodoContext context,
				       TodoItem.Options options) {
	Factory factory = null;
	String nsuri = attr.getNamespaceURI();
	if ( nsuri != null && nsuri.equals(DamlEngine.DAML_NS) )
	    factory = damlAttrFactories.get(attr.getLocalName());
	if ( factory == null )
	    return null;
	return factory.newItem(attr, owner, context, options);
    }

}