01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * 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.cocoon.portal.pluto.om;
18:
19: import java.util.HashMap;
20:
21: import org.apache.pluto.om.common.ObjectID;
22: import org.apache.pluto.om.window.PortletWindow;
23: import org.apache.pluto.om.window.PortletWindowList;
24: import org.apache.pluto.om.window.PortletWindowListCtrl;
25:
26: /**
27: *
28: *
29: * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
30: *
31: * @version CVS $Id: PortletWindowListImpl.java 433543 2006-08-22 06:22:54Z crossley $
32: */
33: public class PortletWindowListImpl implements PortletWindowList,
34: PortletWindowListCtrl {
35:
36: private final HashMap windows;
37:
38: public PortletWindowListImpl() {
39: windows = new HashMap();
40: }
41:
42: // PortletWindowList implementation.
43:
44: /**
45: * Returns the elements of this set
46: *
47: * @return An iterator containg all elements
48: */
49: public java.util.Iterator iterator() {
50:
51: return windows.values().iterator();
52: }
53:
54: /**
55: * Returns the portlet window object of the given id
56: *
57: * @param id id of the portlet window object
58: *
59: * @return the portlet window object or null if the list does not
60: * contain a portlet window with the given id
61: **/
62: public PortletWindow get(ObjectID id) {
63: return (PortletWindow) windows.get(id.toString());
64: }
65:
66: // PortletWindowListCtrl implementation.
67:
68: /**
69: * Add a portlet window to the list
70: *
71: * @param window the porlet window to add
72: **/
73: public void add(PortletWindow window) {
74: if (window != null) {
75: windows.put(window.getId().toString(), window);
76: }
77: }
78:
79: /**
80: * Remove the portlet window with the given Id from the list
81: *
82: * @param id the Id of the portlet window which should be removed
83: **/
84: public void remove(ObjectID id) {
85: if (id != null) {
86: windows.remove(id.toString());
87: }
88: }
89: }
|