org.barracudamvc.contrib.dbroggisch.display
Class IterativeListModel

java.lang.Object
  extended byorg.barracudamvc.core.comp.AbstractTemplateModel
      extended byorg.barracudamvc.contrib.dbroggisch.display.IterativeListModel
All Implemented Interfaces:
Contextual, IterativeModel, Model, TemplateModel

public class IterativeListModel
extends AbstractTemplateModel
implements IterativeModel

Support class to build IterativeModels Use this class to build IterativeModels bassed on arbitrary Lists. The class will iterate over the List and store the current item in the _current variable.

To make this class work, you will have to subclass it and provide a getItem implementation.

A possible usage as anonymous inner class could look like this:
IterativeListModel ilm = new IterativeListModel() {
public Object getItem(Strink key) {
if(key.equals("MYKEY"))= { return _current;
}
}}

If the List is of type TemplateModel, it could look like this:
IterativeListModel ilm = new IterativeListModel() {
public Object getItem(Strink key) {
return ((TemplateModel)_current).getItem(key);
}
}}

Version:
1.0
Author:
Diez B. Roggisch

Field Summary
protected  Object _current
          The current item of the list.
 
Fields inherited from class org.barracudamvc.core.comp.AbstractTemplateModel
listeners, UNDEFINED, viewContext
 
Constructor Summary
IterativeListModel()
          Creates a new IterativeListModel instance.
IterativeListModel(String name)
          Creates a new IterativeListModel instance.
IterativeListModel(String name, List models)
          Creates a new IterativeListModel instance.
 
Method Summary
 void add(Object val)
          Describe add method here.
 List getModels()
          Gets the value of _models
 String getName()
          getName.
 boolean hasNext()
           
 void loadNext()
           
 void postIterate()
           
 void preIterate()
           
 void setModels(List arg_models)
          Sets the value of _models
 void setName(String name)
          Sets the modelname
 
Methods inherited from class org.barracudamvc.core.comp.AbstractTemplateModel
addModelListener, fireModelChanged, getItem, getItem, getViewContext, processDirective, removeModelListener, setViewContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_current

protected Object _current
The current item of the list.

Constructor Detail

IterativeListModel

public IterativeListModel(String name,
                          List models)
Creates a new IterativeListModel instance.

Parameters:
name - a String value
models - a List value

IterativeListModel

public IterativeListModel(String name)
Creates a new IterativeListModel instance.

Parameters:
name - a String value

IterativeListModel

public IterativeListModel()
Creates a new IterativeListModel instance.

Method Detail

setName

public void setName(String name)
Sets the modelname

Parameters:
name - a String value

getName

public String getName()
getName.

Specified by:
getName in interface TemplateModel
Returns:
a String value

getModels

public List getModels()
Gets the value of _models

Returns:
the value of _models

setModels

public void setModels(List arg_models)
Sets the value of _models

Parameters:
arg_models - Value to assign to this._models

add

public void add(Object val)
Describe add method here.

Parameters:
val - an Object value

hasNext

public boolean hasNext()
Specified by:
hasNext in interface IterativeModel

preIterate

public void preIterate()
Specified by:
preIterate in interface IterativeModel

postIterate

public void postIterate()
Specified by:
postIterate in interface IterativeModel

loadNext

public void loadNext()
Specified by:
loadNext in interface IterativeModel


Copyright © 2004 BarracudaMVC.org All Rights Reserved.