1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.jetspeed.om.portlet.impl;
18
19 import java.io.Serializable;
20 import java.util.ArrayList;
21 import java.util.Collection;
22 import java.util.Iterator;
23
24
25
26 import org.apache.pluto.om.common.ObjectID;
27 import org.apache.pluto.om.portlet.PortletDefinition;
28 import org.apache.pluto.om.portlet.PortletDefinitionList;
29
30 /***
31 *
32 * PortletDefinitionListImpl
33 *
34 * @author <a href="mailto:weaver@apache.org">Scott T. Weaver</a>
35 * @version $Id: PortletDefinitionListImpl.java 516448 2007-03-09 16:25:47Z ate $
36 *
37 */
38 public class PortletDefinitionListImpl implements PortletDefinitionList, Serializable
39 {
40
41 protected Collection innerCollection;
42
43 /***
44 *
45 */
46 public PortletDefinitionListImpl()
47 {
48 super();
49 innerCollection = new ArrayList();
50 }
51
52 public PortletDefinitionListImpl(Collection collection)
53 {
54 super();
55 innerCollection = collection;
56 }
57
58 /***
59 * @see org.apache.pluto.om.portlet.PortletDefinitionList#iterator()
60 */
61 public Iterator iterator()
62 {
63 return innerCollection.iterator();
64 }
65
66 /***
67 * @see org.apache.pluto.om.portlet.PortletDefinitionList#get(org.apache.pluto.om.common.ObjectID)
68 */
69 public PortletDefinition get(ObjectID id)
70 {
71 Iterator itr = innerCollection.iterator();
72 while (itr.hasNext())
73 {
74 PortletDefinition pd = (PortletDefinition) itr.next();
75 if (pd.getId().equals(id))
76 {
77 return pd;
78 }
79 }
80
81 return null;
82 }
83
84 /***
85 * Retrieves a <code>PortletDefinition</code> from this
86 * collection by the PortletDefinitions proper name
87 * @param name Proper name of PortletDefinition to locate.
88 * @return PortletDefinition matching <code>name</code> or <code>null</code>
89 * if no PortletDefinition within this PortletApplication has that name.
90 */
91 public PortletDefinition get(String name)
92 {
93 Iterator itr = innerCollection.iterator();
94 while (itr.hasNext())
95 {
96 PortletDefinition pd = (PortletDefinition) itr.next();
97 if (pd.getName().equals(name))
98 {
99 return pd;
100 }
101 }
102
103 return null;
104 }
105
106 /***
107 * @see java.util.Collection#add(java.lang.Object)
108 */
109 public boolean add(Object o)
110 {
111 PortletDefinition pd = (PortletDefinition) o;
112 return innerCollection.add(pd);
113 }
114
115 /***
116 * @see java.util.Collection#remove(java.lang.Object)
117 */
118 public boolean remove(Object o)
119 {
120 PortletDefinition pd = (PortletDefinition) o;
121 return innerCollection.remove(pd);
122 }
123
124 /***
125 * @return
126 */
127 public Collection getInnerCollection()
128 {
129 return innerCollection;
130 }
131
132 /***
133 * @param collection
134 */
135 public void setInnerCollection(Collection collection)
136 {
137 innerCollection = collection;
138 }
139
140 }