org.enhydra.barracuda.core.comp
Class DefaultTemplateView

java.lang.Object
  extended byorg.enhydra.barracuda.core.comp.DefaultView
      extended byorg.enhydra.barracuda.core.comp.DefaultTemplateView
All Implemented Interfaces:
Cloneable, TemplateView, View

public class DefaultTemplateView
extends DefaultView
implements TemplateView

This class provides the default implementation for a TemplateView. It provides a View for components to render themselves in.


Field Summary
protected  String dirAttrName
           
protected  Map dirMap
           
protected  String idAttrName
           
protected  StateMap idMap
           
protected static org.apache.log4j.Logger logger
           
protected  Node masterTemplate
           
 
Fields inherited from class org.enhydra.barracuda.core.comp.DefaultView
localFactory, node, templateNodes
 
Constructor Summary
DefaultTemplateView()
          Public noargs constructor.
DefaultTemplateView(Node node)
          Create a view and bind it to a node.
DefaultTemplateView(Node node, String idAttrName, StateMap idMap)
          Create a view and bind it to a node.
DefaultTemplateView(Node node, String idAttrName, String dirAttrName)
          Create a view and bind it to a node.
 
Method Summary
 Object clone()
          When a template view is cloned, the underlying masterTemplate node is set to null; this ensures the new node to which this view is bound will in fact be used for the template
protected  void customSearchForTemplates(Node curnode)
          Here we are going to look for custom header, footer, and body elements
 String getDirAttrName()
          Get the directive attr name (defaults to "class").
 StateMap getDirIDMap()
          Get the directive ID map.
 String getIDAttrName()
          Get the id attr name (defaults to "id").
 Node getMasterTemplate()
          Get the master template
 TemplateDirective lookupDir(String dirStr)
          Look up a directive by it's string representation (rather than reparsing it).
 List lookupDirsByID(String idStr)
          Look up a list of directives based on a given id
 void setDirAttrName(String idirAttrName)
          Set the directive attr name.
 void setDirIDMap(StateMap iidMap)
          Set the directive ID map.
 void setIDAttrName(String iidAttrName)
          Set the id attr name.
 String toString()
          Get a String describing the view
 
Methods inherited from class org.enhydra.barracuda.core.comp.DefaultView
getElementFactory, getName, getNode, searchForTemplates, setName, setNode
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.enhydra.barracuda.core.comp.View
getElementFactory, getName, getNode, setName, setNode
 

Field Detail

logger

protected static final org.apache.log4j.Logger logger

masterTemplate

protected Node masterTemplate

dirMap

protected Map dirMap

idMap

protected StateMap idMap

idAttrName

protected String idAttrName

dirAttrName

protected String dirAttrName
Constructor Detail

DefaultTemplateView

public DefaultTemplateView()
Public noargs constructor. This creates a view which is not bound to any particular node. You must bind the view to a node before you can actually use it for anything


DefaultTemplateView

public DefaultTemplateView(Node node)
Create a view and bind it to a node.

Parameters:
node - the node the view should be bound to

DefaultTemplateView

public DefaultTemplateView(Node node,
                           String idAttrName,
                           String dirAttrName)
Create a view and bind it to a node. Specify the name of the attribute to be used to search for a directive list (defaults to "class")

Parameters:
node - the node the view should be bound to
idAttrName - name of the id attribute
dirAttrName - name of the attribute to search for directives in

DefaultTemplateView

public DefaultTemplateView(Node node,
                           String idAttrName,
                           StateMap idMap)
Create a view and bind it to a node. Pass in a pre-poulated directive map.

Parameters:
node - the node the view should be bound to
idAttrName - name of the id attribute
idMap - the directive map to be used
Method Detail

getMasterTemplate

public Node getMasterTemplate()
Get the master template

Specified by:
getMasterTemplate in interface TemplateView
Returns:
the master template

setDirIDMap

public void setDirIDMap(StateMap iidMap)
Set the directive ID map. This map allows you to lookup directives associated with a given id. Each item in the map should correspond to a list of directives.

Specified by:
setDirIDMap in interface TemplateView
Parameters:
iidMap - the directive map

getDirIDMap

public StateMap getDirIDMap()
Get the directive ID map. This map allows you to lookup directives associated with a given id.

Specified by:
getDirIDMap in interface TemplateView
Returns:
the idMap for this view

setIDAttrName

public void setIDAttrName(String iidAttrName)
Set the id attr name. Specify the name of the id attribute

Specified by:
setIDAttrName in interface TemplateView
Parameters:
iidAttrName - the name of the id attribute

getIDAttrName

public String getIDAttrName()
Get the id attr name (defaults to "id").

Specified by:
getIDAttrName in interface TemplateView
Returns:
the id attr name

setDirAttrName

public void setDirAttrName(String idirAttrName)
Set the directive attr name. Specify the name of the attribute to search for a list of directives in.

Specified by:
setDirAttrName in interface TemplateView
Parameters:
idirAttrName - the name of the attribute to search for a list of directives in

getDirAttrName

public String getDirAttrName()
Get the directive attr name (defaults to "class").

Specified by:
getDirAttrName in interface TemplateView
Returns:
the directive attr name

lookupDir

public TemplateDirective lookupDir(String dirStr)
Look up a directive by it's string representation (rather than reparsing it). May be null if the template directive is not part of the master template.

Specified by:
lookupDir in interface TemplateView
Parameters:
dirStr - a string representation of a directive
Returns:
the actual template directive that corresponds to the String representation.

lookupDirsByID

public List lookupDirsByID(String idStr)
Look up a list of directives based on a given id

Specified by:
lookupDirsByID in interface TemplateView
Parameters:
idStr - the id in question
Returns:
a list of template directive for the given id

customSearchForTemplates

protected void customSearchForTemplates(Node curnode)
Here we are going to look for custom header, footer, and body elements

Overrides:
customSearchForTemplates in class DefaultView

toString

public String toString()
Description copied from class: DefaultView
Get a String describing the view

Overrides:
toString in class DefaultView

clone

public Object clone()
When a template view is cloned, the underlying masterTemplate node is set to null; this ensures the new node to which this view is bound will in fact be used for the template

Specified by:
clone in interface View
Overrides:
clone in class DefaultView


Copyright © 2003 BarracudaMVC.org All Rights Reserved.