org.barracudamvc.contrib.dbroggisch.display
Class IterativeCollectionModel

java.lang.Object
  extended by org.barracudamvc.core.comp.AbstractTemplateModel
      extended by org.barracudamvc.contrib.dbroggisch.display.IterativeCollectionModel
All Implemented Interfaces:
Contextual, IterativeModel, Model, TemplateModel
Direct Known Subclasses:
ErrorModel

public class IterativeCollectionModel
extends AbstractTemplateModel
implements IterativeModel

Support class to build IterativeModels Use this class to build IterativeModels bassed on arbitrary Collections. The class will iterate over the Collection 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:
IterativeCollectionModel ilm = new IterativeCollectionModel() {
public Object getItem(Strink key) {
if(key.equals("MYKEY"))= { return _current;
}
}}

If the Collection is of type TemplateModel, it could look like this:
IterativeCollectionModel ilm = new IterativeCollectionModel() {
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
IterativeCollectionModel()
          Creates a new IterativeCollectionModel instance.
IterativeCollectionModel(String name)
          Creates a new IterativeCollectionModel instance.
IterativeCollectionModel(String name, Collection models)
          Creates a new IterativeCollectionModel instance.
 
Method Summary
 void add(Object val)
          Describe add method here.
 Collection getModels()
          Gets the value of _models
 String getName()
          getName.
 boolean hasNext()
           
 void loadNext()
           
 void postIterate()
           
 void preIterate()
           
 void setModels(Collection 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

IterativeCollectionModel

public IterativeCollectionModel(String name,
                                Collection models)
Creates a new IterativeCollectionModel instance.

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

IterativeCollectionModel

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

Parameters:
name - a String value

IterativeCollectionModel

public IterativeCollectionModel()
Creates a new IterativeCollectionModel 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 Collection getModels()
Gets the value of _models

Returns:
the value of _models

setModels

public void setModels(Collection 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 © 2006 BarracudaMVC.org All Rights Reserved.