01: /*
02: * $Header: /cvsroot/webman-cms/source/webman/com/teamkonzept/field/TKFieldSwitchListIterator.java,v 1.7 2000/10/13 13:54:22 alex Exp $
03: *
04: */
05: package com.teamkonzept.field;
06:
07: import com.teamkonzept.lib.*;
08: import com.teamkonzept.web.*;
09:
10: public class TKFieldSwitchListIterator implements TKListIterator {
11:
12: TKListIterator oldIterator;
13: String listName;
14: TKEmbededSwitch embededSwitch;
15: TKVector dataVector;
16: int entryCount;
17: String prefix;
18:
19: public TKFieldSwitchListIterator(TKVector dataVector,
20: TKEmbededSwitch embededSwitch, String prefix,
21: TKListIterator oldIterator, String listName) {
22: this .oldIterator = oldIterator;
23: this .embededSwitch = embededSwitch;
24: this .listName = listName;
25: this .dataVector = dataVector;
26: this .prefix = prefix;
27: this .entryCount = dataVector.size();
28: }
29:
30: public boolean apply(TKTemplate t, int i, String currListName) {
31: TKHTMLTemplate template = (TKHTMLTemplate) t;
32:
33: if (currListName.equalsIgnoreCase(listName)) {
34: if (i >= entryCount)
35: return false;
36: Object data = dataVector.get(i);
37: template.set("LISTPOS", String.valueOf(i + 1));
38: embededSwitch.setEmbedName(String.valueOf(i));
39: embededSwitch.fillIntoTemplate(template, data, prefix);
40: return true;
41: } else if (oldIterator != null) {
42: return oldIterator.apply(template, i, currListName);
43: } else {
44: return false;
45: }
46: }
47: }
|