package org.madore.damlengine; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.util.Map; import java.util.HashMap; import org.w3c.dom.Element; public abstract class TodoElement extends TodoItem { protected static Map> damlConstructors; static { damlConstructors = new HashMap>(); } Element node; Map context; Map options; public TodoElement(Element node, Map context, Map options) { this.node = node; this.context = context; this.options = options; } public static TodoElement getTodoElement(Element node, Map context, Map options) { Constructor constructor = null; String nsuri = node.getNamespaceURI(); if ( nsuri != null && nsuri.equals(DamlEngine.DAML_NS) ) constructor = damlConstructors.get(node.getLocalName()); if ( constructor != null ) try { return constructor.newInstance(new Object[]{node, context, options}); } catch (InstantiationException e) { // FIXME: Do something intelligent here! } catch (IllegalAccessException e) { // FIXME: Do something intelligent here! } catch (InvocationTargetException e) { // FIXME: Do something intelligent here! } return new TodoDefaultElement(node, context, options); } }