View Javadoc

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