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; import org.w3c.dom.Attr; public abstract class TodoAttr extends TodoItem { protected static Map> damlAttrConstructors; static { damlAttrConstructors = new HashMap>(); Class[] argTypes = new Class[]{ Attr.class, Element.class, Map.class, Map.class }; try { damlAttrConstructors.put("xempty", TodoXemptyAttr.class.getConstructor(argTypes)); } catch (NoSuchMethodException e) { // FIXME: Do something intelligent here! } } Attr attr; Element owner; Map context; Map options; public TodoAttr(Attr attr, Element owner, Map context, Map options) { this.attr = attr; this.owner = owner; this.context = context; this.options = options; } public static TodoAttr getTodoAttr(Attr attr, Element owner, Map context, Map options) { Constructor constructor = null; String nsuri = attr.getNamespaceURI(); if ( nsuri != null && nsuri.equals(DamlEngine.DAML_NS) ) constructor = damlAttrConstructors.get(attr.getLocalName()); if ( constructor != null ) try { return constructor.newInstance(new Object[]{attr, owner, 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 null; } }