org.barracudamvc.contrib.sam.models
Class MapDecorator
java.lang.Object
org.barracudamvc.contrib.sam.models.TemplateModelDecorator
org.barracudamvc.contrib.sam.models.MapDecorator
- All Implemented Interfaces:
- Contextual, IterativeModel, Model, TemplateModel
- public class MapDecorator
- extends TemplateModelDecorator
MapDecorator is a Decorator class using the well known decorator pattern.
It modifies the return values of the getItem(TemplateDirective)
method of the
decorated model using a Map.
- Version:
- $Id: MapDecorator.java,v 1.11 2004/08/14 18:14:14 jkjome Exp $
- Author:
- Stefan Armbruster
Field Summary |
protected static org.apache.log4j.Logger |
logger
|
protected Map |
mapping
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
logger
protected static org.apache.log4j.Logger logger
mapping
protected Map mapping
MapDecorator
public MapDecorator(TemplateModel tm)
MapDecorator
public MapDecorator(TemplateModel tm,
Map mapping)
- Creates a new instance of MapDecorator
- Parameters:
tm
- decorated modelmapping
- Table containing the mappings, the keys represent the the keys in the getItem(TemplateDirective)
method
setMapping
public void setMapping(Map mapping)
getItem
public Object getItem(TemplateDirective td)
- getItem first checks, if the is a matching entry in
mapping
. If so,
the value of the decorated model is modified depending on the type of the mapper
entry. The following modifications are possible:
Lookup map, implements Map
If the Map contains the value of the underlying model, it is replaced by the
value the the lookup map.
formatting to a specific numeric format, implements NumberFormat
formatting to a specific date format, implements DateFormat
formatting to a user defined class, must implement UserMapping
returning a BAction
, implements ControlEvent
If the value of the mapping table is a ControlEvent, a BAction with the
ControlEvent as href is returned.
- Specified by:
getItem
in interface TemplateModel
- Overrides:
getItem
in class TemplateModelDecorator
- Parameters:
td
- the template directive
- Returns:
- modified return value of underlying model
Copyright © 2004 BarracudaMVC.org All Rights Reserved.