KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > de > webman > generator > PrimContentsIterator


1 package de.webman.generator;
2
3 import com.teamkonzept.lib.*;
4 import java.util.*;
5
6 /**
7     Used by Preview.
8     * @author $Author: alex $
9     * @version $Revision: 1.1 $
10 */

11 public class PrimContentsIterator implements TKListIterator
12 {
13
14     private TKListIterator oldIterator;
15     private String JavaDoc listName;
16     private TKVector list;
17     private Enumeration loop;
18     
19     public PrimContentsIterator( TKVector list, TKListIterator oldIterator, String JavaDoc listName)
20     {
21         this.oldIterator = oldIterator;
22         this.listName = listName;
23         this.list = list;
24         this.loop = list.elements();
25     }
26
27     public boolean apply( TKTemplate template, int i, String JavaDoc currListName )
28     {
29         if( currListName.equalsIgnoreCase( listName ) ) {
30
31             SiteContent sc = null;
32
33             while ((sc == null) && loop.hasMoreElements())
34                 sc = (SiteContent) loop.nextElement();
35
36             if (sc == null) { loop = list.elements(); return false; }
37                 
38             try {
39                 template.set( "INSTANCE_ID", new Integer JavaDoc(sc.getInstanceId()) );
40                 template.set( "VERSION_ID", new Integer JavaDoc(sc.getVersionId()) );
41                 template.set( "CONTENT_ID", new Integer JavaDoc(sc.getContentId()) );
42                 template.set( "CONTENT_NODE_NAME",sc.getName());
43                 template.set( "CONTENT_NODE_SHORTNAME",sc.getShortName());
44             }
45             catch ( Throwable JavaDoc th ) {
46                 throw new Error JavaDoc( th.getMessage() );
47             }
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
Popular Tags