to.etc.domui.dom
Class HtmlTagRenderer

java.lang.Object
  extended by to.etc.domui.dom.HtmlTagRenderer
All Implemented Interfaces:
INodeVisitor
Direct Known Subclasses:
MsGarbageHtmlTagRenderer, StandardHtmlTagRenderer

public class HtmlTagRenderer
extends java.lang.Object
implements INodeVisitor

Basic, mostly standard-compliant handler for rendering HTML tags.

Author:
Frits Jalvingh Created on Aug 17, 2007

Constructor Summary
protected HtmlTagRenderer(BrowserVersion bv, IBrowserOutput o)
           
 
Method Summary
protected  void addDelayedAttrs(NodeBase n, java.lang.String... pairs)
          For browsers that have trouble with attribute updates (Microsoft's sinking flagship of course) this can be used to postphone setting node attributes until after the delta has been applied to the DOM; it executes attribute updates using Javascript at the end of a delta update.
 void appendStyle(CssBase c, java.lang.Appendable a)
           
 void basicNodeRender(NodeBase b, IBrowserOutput o)
          Basic rendering of a node.
static java.lang.String fixColor(java.lang.String s)
           
protected  BrowserVersion getBrowser()
           
 HtmlRenderMode getMode()
           
protected  java.lang.String getStyleFor(NodeBase b)
          Returns the style for the node.
protected  boolean isFullRender()
           
 boolean isTagless()
          When T this only renders attributes but no tags and tag-ends.
protected  IBrowserOutput o()
           
protected  void renderChecked(NodeBase n, boolean checked)
          Render the "checked" attribute.
protected  void renderDiRo(NodeBase n, boolean disabled, boolean readonly)
           
protected  void renderDisabled(NodeBase n, boolean disabled)
          Render the "disabled" attribute.
 void renderEndTag(NodeBase b)
           
protected  void renderReadOnly(NodeBase n, boolean readonly)
          Render the 'readonly' attribute.
protected  void renderSelected(NodeBase n, boolean checked)
          Render the 'selected' attribute.
protected  void renderTag(NodeBase b, IBrowserOutput o)
           
protected  void renderTagend(NodeBase b, IBrowserOutput o)
           
protected  java.lang.StringBuilder sb()
          Return the cleared scratchbuffer.
 void setRenderMode(HtmlRenderMode rm)
           
 void setTagless(boolean tagless)
          When T this only renders attributes but no tags and tag-ends.
 void visitA(ATag a)
           
 void visitBR(BR n)
           
 void visitButton(Button n)
           
 void visitCheckbox(Checkbox n)
          Render the basic input tag.
 void visitDiv(Div n)
          Special thingy; this can actually be a BODY instead of a DIV; in that case we render some extra arguments...
 void visitFileInput(FileInput n)
           
 void visitForm(Form n)
           
 void visitH(HTag n)
           
 void visitImg(Img n)
           
 void visitInput(Input n)
          Render the basic input tag.
 void visitLabel(Label n)
           
 void visitLi(Li n)
           
 void visitLiteralXhtml(LiteralXhtml n)
          Deprecated. 
 void visitOption(SelectOption n)
           
 void visitRadioButton(RadioButton n)
          JoS : 20 Augustus 2008 Render the basic radio button
 void visitSelect(Select n)
           
 void visitSpan(Span n)
           
 void visitTable(Table n)
           
 void visitTBody(TBody n)
           
 void visitTD(TD n)
           
 void visitTextArea(TextArea n)
          FIXME This now contains IE code where browser-standard code would just generate a proper TextArea with a content block.
 void visitTextNode(TextNode n)
           
 void visitTH(TH n)
           
 void visitTHead(THead n)
           
 void visitTR(TR n)
           
 void visitUl(Ul n)
           
 void visitXmlNode(XmlTextNode n)
          This is a TextNode with the special characteristic that it contains not normal text but XML to be rendered verbatim.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HtmlTagRenderer

protected HtmlTagRenderer(BrowserVersion bv,
                          IBrowserOutput o)
Method Detail

getBrowser

protected BrowserVersion getBrowser()

isTagless

public boolean isTagless()
When T this only renders attributes but no tags and tag-ends.

Returns:

setTagless

public void setTagless(boolean tagless)
When T this only renders attributes but no tags and tag-ends.


setRenderMode

public void setRenderMode(HtmlRenderMode rm)

getMode

public HtmlRenderMode getMode()

isFullRender

protected boolean isFullRender()

sb

protected java.lang.StringBuilder sb()
Return the cleared scratchbuffer.

Returns:

addDelayedAttrs

protected void addDelayedAttrs(NodeBase n,
                               java.lang.String... pairs)
For browsers that have trouble with attribute updates (Microsoft's sinking flagship of course) this can be used to postphone setting node attributes until after the delta has been applied to the DOM; it executes attribute updates using Javascript at the end of a delta update.

Parameters:
nodeID -
pairs -

renderDisabled

protected void renderDisabled(NodeBase n,
                              boolean disabled)
                       throws java.io.IOException
Render the "disabled" attribute. Override for shitware.

Parameters:
n -
disabled -
Throws:
java.io.IOException

renderChecked

protected void renderChecked(NodeBase n,
                             boolean checked)
                      throws java.io.IOException
Render the "checked" attribute. Override for shitware.

Parameters:
n -
checked -
Throws:
java.io.IOException

renderSelected

protected void renderSelected(NodeBase n,
                              boolean checked)
                       throws java.io.IOException
Render the 'selected' attribute. Override for shitware.

Parameters:
n -
checked -
Throws:
java.io.IOException

renderReadOnly

protected void renderReadOnly(NodeBase n,
                              boolean readonly)
                       throws java.io.IOException
Render the 'readonly' attribute. Override for shitware.

Parameters:
n -
readonly -
Throws:
java.io.IOException

renderDiRo

protected void renderDiRo(NodeBase n,
                          boolean disabled,
                          boolean readonly)
                   throws java.io.IOException
Throws:
java.io.IOException

fixColor

public static java.lang.String fixColor(java.lang.String s)

appendStyle

public void appendStyle(CssBase c,
                        java.lang.Appendable a)
                 throws java.io.IOException
Throws:
java.io.IOException

o

protected final IBrowserOutput o()

getStyleFor

protected java.lang.String getStyleFor(NodeBase b)
                                throws java.io.IOException
Returns the style for the node. It uses the cached style and recreates it when it has changed.

Parameters:
b -
Returns:
Throws:
java.io.IOException

renderTag

protected void renderTag(NodeBase b,
                         IBrowserOutput o)
                  throws java.lang.Exception
Throws:
java.lang.Exception

renderTagend

protected void renderTagend(NodeBase b,
                            IBrowserOutput o)
                     throws java.lang.Exception
Throws:
java.lang.Exception

basicNodeRender

public void basicNodeRender(NodeBase b,
                            IBrowserOutput o)
                     throws java.lang.Exception
Basic rendering of a node. This renders the tag and all shared attributes.

Parameters:
o -
Throws:
java.lang.Exception

visitDiv

public void visitDiv(Div n)
              throws java.lang.Exception
Special thingy; this can actually be a BODY instead of a DIV; in that case we render some extra arguments...

Specified by:
visitDiv in interface INodeVisitor
Throws:
java.lang.Exception
See Also:
INodeVisitor.visitDiv(to.etc.domui.dom.html.Div)

visitSpan

public void visitSpan(Span n)
               throws java.lang.Exception
Specified by:
visitSpan in interface INodeVisitor
Throws:
java.lang.Exception

visitTable

public void visitTable(Table n)
                throws java.lang.Exception
Specified by:
visitTable in interface INodeVisitor
Throws:
java.lang.Exception

visitTHead

public void visitTHead(THead n)
                throws java.lang.Exception
Specified by:
visitTHead in interface INodeVisitor
Throws:
java.lang.Exception

visitTBody

public void visitTBody(TBody n)
                throws java.lang.Exception
Specified by:
visitTBody in interface INodeVisitor
Throws:
java.lang.Exception

visitTD

public void visitTD(TD n)
             throws java.lang.Exception
Specified by:
visitTD in interface INodeVisitor
Throws:
java.lang.Exception

visitTH

public void visitTH(TH n)
             throws java.lang.Exception
Specified by:
visitTH in interface INodeVisitor
Throws:
java.lang.Exception

visitTR

public void visitTR(TR n)
             throws java.lang.Exception
Specified by:
visitTR in interface INodeVisitor
Throws:
java.lang.Exception

visitTextNode

public void visitTextNode(TextNode n)
                   throws java.lang.Exception
Specified by:
visitTextNode in interface INodeVisitor
Throws:
java.lang.Exception

visitXmlNode

public void visitXmlNode(XmlTextNode n)
                  throws java.lang.Exception
This is a TextNode with the special characteristic that it contains not normal text but XML to be rendered verbatim. The XML may not be indented in any way and may not be escaped (that should already have been done by the one creating it).

Specified by:
visitXmlNode in interface INodeVisitor
Throws:
java.lang.Exception
See Also:
INodeVisitor.visitXmlNode(to.etc.domui.dom.html.XmlTextNode)

renderEndTag

public void renderEndTag(NodeBase b)
                  throws java.io.IOException
Throws:
java.io.IOException

visitA

public void visitA(ATag a)
            throws java.lang.Exception
Specified by:
visitA in interface INodeVisitor
Throws:
java.lang.Exception

visitLi

public void visitLi(Li n)
             throws java.lang.Exception
Specified by:
visitLi in interface INodeVisitor
Throws:
java.lang.Exception

visitUl

public void visitUl(Ul n)
             throws java.lang.Exception
Specified by:
visitUl in interface INodeVisitor
Throws:
java.lang.Exception

visitInput

public void visitInput(Input n)
                throws java.lang.Exception
Render the basic input tag.

Specified by:
visitInput in interface INodeVisitor
Throws:
java.lang.Exception
See Also:
INodeVisitor.visitInput(to.etc.domui.dom.html.Input)

visitFileInput

public void visitFileInput(FileInput n)
                    throws java.lang.Exception
Specified by:
visitFileInput in interface INodeVisitor
Throws:
java.lang.Exception

visitCheckbox

public void visitCheckbox(Checkbox n)
                   throws java.lang.Exception
Render the basic input tag.

Specified by:
visitCheckbox in interface INodeVisitor
Throws:
java.lang.Exception
See Also:
INodeVisitor.visitInput(to.etc.domui.dom.html.Input)

visitRadioButton

public void visitRadioButton(RadioButton n)
                      throws java.lang.Exception
JoS : 20 Augustus 2008 Render the basic radio button

Specified by:
visitRadioButton in interface INodeVisitor
Throws:
java.lang.Exception
See Also:
INodeVisitor.visitInput(to.etc.domui.dom.html.Input)

visitImg

public void visitImg(Img n)
              throws java.lang.Exception
Specified by:
visitImg in interface INodeVisitor
Throws:
java.lang.Exception

visitButton

public void visitButton(Button n)
                 throws java.lang.Exception
Specified by:
visitButton in interface INodeVisitor
Throws:
java.lang.Exception

visitLabel

public void visitLabel(Label n)
                throws java.lang.Exception
Specified by:
visitLabel in interface INodeVisitor
Throws:
java.lang.Exception

visitSelect

public void visitSelect(Select n)
                 throws java.lang.Exception
Specified by:
visitSelect in interface INodeVisitor
Throws:
java.lang.Exception

visitOption

public void visitOption(SelectOption n)
                 throws java.lang.Exception
Specified by:
visitOption in interface INodeVisitor
Throws:
java.lang.Exception

visitBR

public void visitBR(BR n)
             throws java.lang.Exception
Specified by:
visitBR in interface INodeVisitor
Throws:
java.lang.Exception

visitTextArea

public void visitTextArea(TextArea n)
                   throws java.lang.Exception
FIXME This now contains IE code where browser-standard code would just generate a proper TextArea with a content block. It needs to move to the crapware renderers.

Specified by:
visitTextArea in interface INodeVisitor
Throws:
java.lang.Exception
See Also:
INodeVisitor.visitTextArea(to.etc.domui.dom.html.TextArea)

visitForm

public void visitForm(Form n)
               throws java.lang.Exception
Specified by:
visitForm in interface INodeVisitor
Throws:
java.lang.Exception

visitLiteralXhtml

@Deprecated
public void visitLiteralXhtml(LiteralXhtml n)
                       throws java.lang.Exception
Deprecated. 

Specified by:
visitLiteralXhtml in interface INodeVisitor
Throws:
java.lang.Exception

visitH

public void visitH(HTag n)
            throws java.lang.Exception
Specified by:
visitH in interface INodeVisitor
Throws:
java.lang.Exception