package org.madore.damlengine; import java.util.ArrayList; import org.w3c.dom.*; public final class TodoTitleOrSubtitle extends TodoElement { public enum Type { TITLE("h1","title"), SUBTITLE("p","subtitle"); final String eltName; final String eltClass; Type(String eltName, String eltClass) { this.eltName = eltName; this.eltClass = eltClass; } } final Type t; public TodoTitleOrSubtitle(Type t, Element node, Context ctx, TodoItem caller) { super(node, ctx, caller); this.t = t; } @Override public void handle() { Element elt = ctx.doc.createElementNS(DamlEngine.XHTML_NS, t.eltName); String expLang = (t==Type.TITLE)?ctx.gc.titleLang:ctx.gc.subtitleLang; if ( expLang != null ) LangHelper.setLangNorec(node, expLang); elt.setAttributeNS(null, "class", t.eltClass); node.getParentNode().replaceChild(elt, node); ArrayList childList = TodoDefaultElement.getChildList((t==Type.TITLE)?ctx.gc.title:ctx.gc.subtitle); for ( Node child : childList ) elt.appendChild(child.cloneNode(true)); TodoElement it = TodoElement.getTodoElement(elt, this.ctx, this); this.ownerDeque.registerAtStart(it); } }