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, Context ctx, TodoItem caller); } protected final static Map damlAttrFactories; static { damlAttrFactories = new HashMap(); damlAttrFactories.put("xempty", new TodoXemptyAttr.Factory()); damlAttrFactories.put("wref", new TodoWrefAttr.Factory()); damlAttrFactories.put("wxref", new TodoWXrefAttr.Factory()); } protected final static Factory xmlnsAttrFactory = new TodoXmlnsAttr.Factory(); protected final Attr attr; protected final Element owner; public TodoAttr(Attr attr, Element owner, Context ctx, TodoItem caller) { super(ctx, caller); this.attr = attr; this.owner = owner; } public static TodoAttr getTodoAttr(Attr attr, Element owner, Context ctx, TodoItem caller) { Factory factory = null; String nsuri = attr.getNamespaceURI(); if ( nsuri != null && nsuri.equals(DamlEngine.DAML_NS) ) factory = damlAttrFactories.get(attr.getLocalName()); else if ( nsuri != null && nsuri.equals(DamlEngine.XMLNS_NS) ) // Note to self: even the plain "xmlns" attribute has this namespace factory = xmlnsAttrFactory; if ( factory == null ) return null; return factory.newItem(attr, owner, ctx, caller); } }