KickJava   Java API By Example, From Geeks To Geeks.

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


1 package de.webman.generator;
2
3 import com.teamkonzept.lib.*;
4 import com.teamkonzept.webman.*;
5 import java.util.*;
6
7 /**
8     Verwaltet die statischen Daten und Methoden von SiteContentIntegration
9  * @author $Author: alex $
10  * @version $Revision: 1.2 $
11 */

12 public class SiteContentIntegrationStatics
13 {
14
15     /**
16         Verweis zurück auf den aktuellen statischen Kontext des laufenden Threads
17     */

18     private GeneratorContext context;
19
20     /**
21         Ein globaler Hash, in dem eventuelle
22         Selektionsergebnisse zwischengespeichert werden.
23         Key := selectionKey
24         Value := TKVector of SiteContent
25     */

26     private TKHashtable selectionHash;
27
28     public SiteContentIntegrationStatics (GeneratorContext context)
29     {
30         this.context = context != null ? context : GeneratorContext.setup ();
31         this.selectionHash = null;
32     }
33     
34     /**
35         fuehrt die uebergebene Selection durch, traegt die Ergebnisliste
36         in selectionHash ein und liefert den verwendeten Zugriffskey
37         zurueck.
38     */

39     public String JavaDoc newSelection( String JavaDoc type, String JavaDoc data, int nodeId )
40     {
41         String JavaDoc key = type + data + nodeId;
42         if( selectionHash.get( key ) == null ) {
43             TKVector conts = TKWMContentSelectorReg.select( type, data, nodeId );
44             TKVector result = new TKVector( conts.size()+1 );
45             Enumeration e = conts.elements();
46             while( e.hasMoreElements() )
47             {
48                 Object JavaDoc siteContent = context.siteContents.getContent(((Integer JavaDoc)e.nextElement()).intValue());
49                 // Version control might lead to the case that a selected content
50
// is not generatable and thus not stored in the contentHash.
51
// So, we must do the null-pointer check:
52
if (siteContent != null) {
53                     result.addElement(siteContent);
54                 }
55             }
56             selectionHash.put( key, result );
57         }
58         return key;
59     }
60
61     /**
62         liefert das zum uebergebenen Key passende Selectionsergebnis
63         (TKVector of SiteContent)
64     */

65     public final TKVector getSelection( String JavaDoc key )
66     {
67         return (TKVector) selectionHash.get( key );
68     }
69     
70     /**
71         erzeugt den selectionHash
72     */

73     public final void initSelection()
74     {
75         selectionHash = new TKHashtable();
76     }
77 }
78
Popular Tags