KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jahia > layout > PortletBeanSet


1 package org.jahia.layout;
2
3 /**
4  * Title: Simple container for portlet beans
5  * Description:
6  * Copyright: Copyright (c) 2002
7  * Company: Jahia Ltd
8  * @author Serge Huber
9  * @version 1.0
10  */

11
12 import java.util.Enumeration JavaDoc;
13 import java.util.Vector JavaDoc;
14
15 import org.jahia.exceptions.JahiaException;
16
17 public class PortletBeanSet extends Vector JavaDoc {
18
19     public PortletBeanSet() {
20     }
21
22     /**
23      * Retrieves a portlet in the set by using it's identifier
24      * @param portletID identifier of the portlet to retrieve
25      * @returns a PortletBean object corresponding to the given identifier
26      * @throws JahiaException if the object is not found in the portlet set.
27      */

28     public PortletBean findPortlet(int portletID)
29     throws JahiaException {
30         Enumeration JavaDoc portletList = this.elements();
31         while (portletList.hasMoreElements()) {
32             PortletBean curPortlet = (PortletBean) portletList.nextElement();
33             if (curPortlet.getPortletID() == portletID) {
34                 return curPortlet;
35             }
36         }
37         throw new JahiaException("PortletBeanSet.findPortlet",
38                                  "Portlet not found",
39                                  JahiaException.ERROR_SEVERITY,
40                                  JahiaException.DATA_ERROR);
41     }
42
43     /**
44      * This function doesn't do much in this set object, but we have it here
45      * to make the understanding of the PortletGrid and PortletSpanningGrid
46      * implementations clearer. Also this provides just a little help in the
47      * type checking, since we should only add PortletBean objects to this set
48      * and nothing else.
49      * @param portlet the portlet to be added to the set
50      * @returns true (as per the general contract of Collection.add).
51      */

52     public boolean add(PortletBean portlet) {
53         return super.add(portlet);
54     }
55
56 }
Popular Tags