From e3b7a9c657a6a5f5a7a8f3c7ee4fdff1aee6410f Mon Sep 17 00:00:00 2001 From: "David A. Madore" Date: Tue, 13 Apr 2010 15:21:41 +0200 Subject: Framework for handling attributes. --- org/madore/damlengine/TodoItem.java | 51 ++----------------------------------- 1 file changed, 2 insertions(+), 49 deletions(-) (limited to 'org/madore/damlengine/TodoItem.java') diff --git a/org/madore/damlengine/TodoItem.java b/org/madore/damlengine/TodoItem.java index 941460e..677b3b1 100644 --- a/org/madore/damlengine/TodoItem.java +++ b/org/madore/damlengine/TodoItem.java @@ -1,54 +1,7 @@ package org.madore.damlengine; -import java.lang.reflect.Method; -import java.lang.reflect.InvocationTargetException; -import java.util.Map; -import java.util.HashMap; -import org.w3c.dom.Node; +public abstract class TodoItem { -public class TodoItem { - - protected static Map damlHandlers; - protected static Method defaultHandler; - - { - Class[] handlerArgTypes = new Class[]{ TodoItem.class }; - damlHandlers = new HashMap(); - try { - defaultHandler = DefaultHandler.class.getMethod("handle", handlerArgTypes); - } catch (NoSuchMethodException e) { - // FIXME: this isn't good... - throw new Error("this is impossible"); - } - } - - Node node; - Map context; - Map options; - - public TodoItem(Node node, Map context, Map options) { - this.node = node; - this.context = context; - this.options = options; - } - - public void dispatch() { - Method handler; - if ( node.getNamespaceURI().equals(DamlEngine.DAML_NS) ) { - handler = damlHandlers.get(node.getLocalName()); - if ( handler == null ) - handler = defaultHandler; - } else - handler = defaultHandler; - try { - handler.invoke(null, new Object[]{this}); - } catch (IllegalAccessException e) { - // FIXME: this isn't good... - throw new Error("this is impossible"); - } catch (InvocationTargetException e) { - // FIXME: this isn't good... - throw new Error("this is impossible"); - } - } + public abstract void dispatch(); } -- cgit v1.2.3