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, Context ctx, TodoItem caller); } protected static Map damlFactories; protected static Factory damlDefaultFactory; static { damlFactories = new HashMap(); damlDefaultFactory = new TodoDefaultElement.Factory(); damlFactories.put("daml", new TodoDamlElement.Factory()); damlFactories.put("body", new TodoBodyElement.Factory()); } Element node; public TodoElement(Element node, Context ctx, TodoItem caller) { super(ctx, caller); this.node = node; } public static TodoElement getTodoElement(Element node, Context ctx, TodoItem caller) { 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, ctx, caller); } }