KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > portal > server > plugins > windowstate > WindowStates


1 /*****************************************
2  * *
3  * JBoss Portal: The OpenSource Portal *
4  * *
5  * Distributable under LGPL license. *
6  * See terms of license at gnu.org. *
7  * *
8  *****************************************/

9 package org.jboss.portal.server.plugins.windowstate;
10
11 import java.util.HashSet JavaDoc;
12 import java.util.Iterator JavaDoc;
13 import java.util.Set JavaDoc;
14
15 import org.jboss.portal.common.metadata.MetaData;
16 import org.jboss.portal.server.metadata.WindowStatesMetaData;
17 import org.jboss.portal.server.plugins.PluginService;
18
19 /**
20  * @author <a HREF="mailto:julien@jboss.org">Julien Viet</a>
21  * @version $Revision: 1.3 $
22  */

23 public class WindowStates
24    extends PluginService
25    implements WindowStateProvider
26 {
27
28    protected WindowStatesMetaData metaData;
29
30    protected Set JavaDoc windowStates;
31
32    /**
33     * @throws IllegalArgumentException if the window state is null
34     */

35    public boolean containsWindowState(WindowState windowState)
36    {
37       if (windowState == null)
38       {
39          throw new IllegalArgumentException JavaDoc("Window state must not be null");
40       }
41       return windowStates.contains(windowState);
42    }
43
44    /**
45     * @throws IllegalArgumentException if the window state is null
46     */

47    public void addWindowState(WindowState windowState)
48    {
49       if (windowState == null)
50       {
51          throw new IllegalArgumentException JavaDoc("Window state must not be null");
52       }
53       windowStates.add(windowState);
54    }
55
56    /**
57     * @throws IllegalArgumentException if the window state is null
58     */

59    public void removeWindowState(WindowState windowState)
60    {
61       if (windowState == null)
62       {
63          throw new IllegalArgumentException JavaDoc("Window state must not be null");
64       }
65       windowStates.remove(windowState);
66    }
67
68    public Set JavaDoc getWindowStates()
69    {
70       return windowStates;
71    }
72
73    public void start() throws Exception JavaDoc
74    {
75       this.windowStates = new HashSet JavaDoc();
76       for (Iterator JavaDoc i = this.metaData.getWindowStates().iterator();i.hasNext();)
77       {
78          String JavaDoc windowStateAsString = (String JavaDoc)i.next();
79          WindowState windowState = WindowState.create(windowStateAsString);
80          windowStates.add(windowState);
81       }
82    }
83
84    public void setMetaData(MetaData metaData)
85    {
86       this.metaData = (WindowStatesMetaData)metaData;
87    }
88
89    public MetaData getMetaData()
90    {
91       return metaData;
92    }
93 }
94
Popular Tags