1 18 package org.apache.beehive.netui.tags.rendering; 19 20 import org.apache.beehive.netui.tags.html.HtmlConstants; 21 22 import java.util.HashMap ; 23 24 30 public abstract class BaseTag extends TagHtmlBase implements HtmlConstants 31 { 32 public static void add(HashMap html, HashMap htmlQuirks, HashMap xhtml) 33 { 34 html.put(BASE_TAG, new HtmlRendering()); 35 htmlQuirks.put(BASE_TAG, new HtmlRendering()); 36 xhtml.put(BASE_TAG, new XhtmlRendering()); 37 } 38 39 public static class State extends AbstractAttributeState 40 { 41 public String target; 42 public String href; 43 44 public void clear() 45 { 46 super.clear(); 47 48 target = null; 49 href = null; 50 } 51 } 52 53 public void doStartTag(AbstractRenderAppender sb, AbstractTagState renderState) 54 { 55 assert(sb != null) : "Parameter 'sb' must not be null"; 56 assert(renderState != null) : "Parameter 'renderState' must not be null"; 57 assert(renderState instanceof BaseTag.State) : "Paramater 'renderState' must be an instance of Base.State"; 58 59 State state = (State) renderState; 60 61 renderTag(sb, BASE); 62 renderAttribute(sb, HREF, state.href); 63 renderAttribute(sb, TARGET, state.target); 64 65 renderAttributes(AbstractHtmlState.ATTR_GENERAL, sb, state); 67 writeEnd(sb); 68 } 69 70 public void doEndTag(AbstractRenderAppender sb) 71 { 72 } 74 75 abstract protected void writeEnd(AbstractRenderAppender sb); 76 77 78 private static class HtmlRendering extends BaseTag 79 { 80 protected void writeEnd(AbstractRenderAppender sb) 81 { 82 sb.append(">"); 83 } 84 } 85 86 private static class XhtmlRendering extends BaseTag 87 { 88 protected void writeEnd(AbstractRenderAppender sb) 89 { 90 sb.append(" />"); 91 } 92 } 93 } 94 | Popular Tags |