KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > teamkonzept > field > TKSwitchListShowIterator


1 /*
2  * $Header: /cvsroot/webman-cms/source/webman/com/teamkonzept/field/TKSwitchListShowIterator.java,v 1.7 2000/10/13 13:54:22 alex Exp $
3  *
4  */

5 package com.teamkonzept.field;
6
7 import com.teamkonzept.lib.*;
8 import com.teamkonzept.web.*;
9
10 public class TKSwitchListShowIterator implements TKListIterator {
11
12     TKListIterator oldIterator;
13     String JavaDoc switchListName;
14     TKEmbededSwitch embededSwitch;
15     TKVector dataVector;
16     int entryCount;
17     String JavaDoc scope;
18     String JavaDoc listName;
19     
20     public TKSwitchListShowIterator(
21         TKVector dataVector,
22         TKEmbededSwitch embededSwitch,
23         String JavaDoc scope,
24         String JavaDoc switchListName,
25         TKListIterator oldIterator
26     )
27     {
28         this.oldIterator = oldIterator;
29         this.embededSwitch = embededSwitch;
30         this.switchListName = switchListName;
31         this.dataVector = dataVector;
32         this.scope = scope;
33         this.entryCount = dataVector.size();
34         this.listName = scope+"."+switchListName;
35     }
36     
37     public boolean apply( TKTemplate t, int i, String JavaDoc currListName )
38     {
39         TKHTMLTemplate template = (TKHTMLTemplate) t;
40         
41         if( currListName.equalsIgnoreCase( listName ) ) {
42             if( i >= entryCount ) return false;
43             Object JavaDoc data = dataVector.get( i );
44             template.set( "SCOPE", listName );
45             template.set( listName+".IDX", String.valueOf(i+1) );
46             embededSwitch.setEmbedName( switchListName );
47             embededSwitch.fillIntoPresentation( template, data, scope );
48             return true;
49         }
50         else if( oldIterator != null ) {
51             return oldIterator.apply( template, i, currListName );
52         }
53         else {
54             return false;
55         }
56     }
57 }
58
59
Popular Tags