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.*;
23  import org.apache.pluto.om.window.*;
24  import org.apache.pluto.om.common.ObjectID;
25  
26  public class PortletWindowListImpl implements PortletWindowList, PortletWindowListCtrl {
27  
28      
29      HashMap windows = null;
30  
31      public PortletWindowListImpl() {
32          windows = new HashMap();
33      }
34  
35      // PortletWindowList implementation.
36  
37      /***
38       * Returns the elements of this set
39       * 
40       * @return An iterator containg all elements
41       */
42      public java.util.Iterator iterator() {
43  
44          return windows.values().iterator();
45      }
46  
47  
48      /***
49       * Returns the portlet window object of the given id
50       *
51       * @param id the window id.
52       *
53       * @return the portlet window object or null if the list does not
54       *         contain a portlet window with the given id
55       **/
56      public PortletWindow get(ObjectID id)
57      {
58          return (PortletWindow)windows.get(id.toString());
59      }
60  
61      // PortletWindowListCtrl implementation.
62      
63      /***
64       * Add a portlet window to the list
65       * 
66       * @param window the porlet window to add
67       **/
68      public void add(PortletWindow window) {
69          if(window != null) {
70              windows.put(window.getId().toString(), window);
71          }
72      }
73  
74      /***
75       * Remove the portlet window with the given Id from the list
76       * 
77       * @param id the Id of the portlet window which should be removed
78       **/
79      public void remove(ObjectID id){
80          if(id != null) {
81              windows.remove(id.toString());
82          }
83      }
84  }