com.taursys.xml.render
Class AbstractRenderer

java.lang.Object
  extended bycom.taursys.xml.render.AbstractRenderer
Direct Known Subclasses:
VisibleRenderer

public abstract class AbstractRenderer
extends java.lang.Object

AbstractRenderer is the base class for all Renderers. It contains common behavior for removing(hiding) and restoring(showing) the component.

Version:
1.0
Author:
Marty Phelan

Field Summary
protected  java.lang.String id
           
protected  DocumentAdapter parentDocumentAdapter
           
 
Constructor Summary
AbstractRenderer(Component c)
          Constructs a new AbstractRenderer for the given Component
 
Method Summary
 Component getComponent()
          Get the component for this renderer
protected  org.w3c.dom.Node getComponentNode()
          Get the component node which will be replicated.
 org.w3c.dom.Document getDocument()
          Get the Document for this renderer
 org.w3c.dom.Node getParentNode()
          Get the parent node for the component node.
 org.w3c.dom.Node getSiblingNode()
          Get the sibling node for the component node or null if none.
protected  void init()
          Initializes reference to parentNode and siblingNode.
 boolean isRemoved()
          Get an indicator of whether or not the master component node has been removed.
protected  void removeSelf()
          Remove self from parent/Document (usually done after all nodes populated).
 void render()
          Renders the Component by adding or removing it from the document based on visible property and invokes renderContents if component is visible.
protected abstract  void renderContents()
          Invoked by render method if component's visible property is true, to render the contents of this component.
protected  void restoreSelf()
          Restore self to parent/Document.
 void setRemoved(boolean b)
          Set an indicator of whether or not the master component node has been removed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

parentDocumentAdapter

protected DocumentAdapter parentDocumentAdapter

id

protected java.lang.String id
Constructor Detail

AbstractRenderer

public AbstractRenderer(Component c)
Constructs a new AbstractRenderer for the given Component

Parameters:
c - Component which owns this renderer
Method Detail

init

protected void init()
             throws RenderException
Initializes reference to parentNode and siblingNode. Only acts if componentNode is null and document has not changed

Throws:
RenderException - if parent, DocumentAdapter, or Document is null.

removeSelf

protected void removeSelf()
Remove self from parent/Document (usually done after all nodes populated). Only acts if not already removed (removed=false) and parentNode and componentNode are not null. The method reset changes the removed flag back to true.


restoreSelf

protected void restoreSelf()
Restore self to parent/Document. Tries to restore to original position which is BEFORE the sibling node, otherwise as the first child. Only acts if already removed (removed=true)and parentNode and componentNode are not null. The method reset changes the removed flag to false.


render

public void render()
            throws RenderException
Renders the Component by adding or removing it from the document based on visible property and invokes renderContents if component is visible.

Throws:
RenderException - if any problem occurs during rendering

renderContents

protected abstract void renderContents()
                                throws RenderException
Invoked by render method if component's visible property is true, to render the contents of this component.

Throws:
RenderException

getComponentNode

protected org.w3c.dom.Node getComponentNode()
Get the component node which will be replicated. The init method must be invoked before using this method for the first time.

Returns:
the component node which will be replicated.

getParentNode

public org.w3c.dom.Node getParentNode()
Get the parent node for the component node. The init method must be invoked before using this method for the first time.

Returns:
the parent node for the component node

getSiblingNode

public org.w3c.dom.Node getSiblingNode()
Get the sibling node for the component node or null if none. This is the sibling that follows the component node. The init method must be invoked before using this method for the first time.

Returns:
the sibling node for the component node or null if none

getComponent

public Component getComponent()
Get the component for this renderer

Returns:
the component for this renderer

getDocument

public org.w3c.dom.Document getDocument()
Get the Document for this renderer

Returns:
the Document for this renderer

setRemoved

public void setRemoved(boolean b)
Set an indicator of whether or not the master component node has been removed.

Parameters:
b - an indicator of whether or not the master component node has been removed.

isRemoved

public boolean isRemoved()
Get an indicator of whether or not the master component node has been removed.

Returns:
an indicator of whether or not the master component node has been removed.


Copyright © 2007 Martin T Phelan. All Rights Reserved.