View Javadoc

1   /*
2    * Copyright 2003,2004 The Apache Software Foundation.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  /* 
17  
18   */
19  
20  package org.apache.pluto.portalImpl.om.window.impl;
21  
22  import java.util.HashMap;
23  
24  import org.apache.pluto.om.common.ObjectID;
25  import org.apache.pluto.om.window.PortletWindow;
26  import org.apache.pluto.om.window.PortletWindowList;
27  import org.apache.pluto.om.window.PortletWindowListCtrl;
28  
29  public class PortletWindowListImpl implements PortletWindowList, PortletWindowListCtrl {
30  
31      
32      HashMap windows;
33  
34      public PortletWindowListImpl() {
35          windows = new HashMap();
36      }
37  
38      // PortletWindowList implementation.
39  
40      /***
41       * Returns the elements of this set
42       * 
43       * @return An iterator containg all elements
44       */
45      public java.util.Iterator iterator() {
46  
47          return windows.values().iterator();
48      }
49  
50  
51      /***
52       * Returns the portlet window object of the given id
53       *
54       * @param id the window id.
55       *
56       * @return the portlet window object or null if the list does not
57       *         contain a portlet window with the given id
58       **/
59      public PortletWindow get(ObjectID id)
60      {
61          return (PortletWindow)windows.get(id.toString());
62      }
63  
64      // PortletWindowListCtrl implementation.
65      
66      /***
67       * Add a portlet window to the list
68       * 
69       * @param window the porlet window to add
70       **/
71      public void add(PortletWindow window) {
72          if(window != null) {
73              windows.put(window.getId().toString(), window);
74          }
75      }
76  
77      /***
78       * Remove the portlet window with the given Id from the list
79       * 
80       * @param id the Id of the portlet window which should be removed
81       **/
82      public void remove(ObjectID id){
83          if(id != null) {
84              windows.remove(id.toString());
85          }
86      }
87  }