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 import javax.portlet.PortletMode;
25
26 import org.apache.jetspeed.om.common.portlet.ContentTypeSetComposite;
27 import org.apache.pluto.om.portlet.ContentType;
28
29 /***
30 * @author <a href="mailto:weaver@apache.org">Scott T. Weaver</a>
31 */
32 public class ContentTypeSetImpl implements ContentTypeSetComposite, Serializable
33 {
34
35 protected Collection innerCollection;
36
37 public ContentTypeSetImpl()
38 {
39 innerCollection = new ArrayList();
40 }
41
42 public ContentTypeSetImpl(Collection collection)
43 {
44 innerCollection = collection;
45 }
46
47 public boolean supportsPortletMode(PortletMode mode)
48 {
49
50
51 if(mode.equals(PortletMode.VIEW))
52 {
53 return true;
54 }
55
56 Iterator itr = innerCollection.iterator();
57 while (itr.hasNext())
58 {
59 ContentType p = (ContentType) itr.next();
60 if (p.supportsPortletMode(mode))
61 {
62 return true;
63 }
64 }
65
66 return false;
67 }
68
69 /***
70 * @see org.apache.pluto.om.portlet.ContentTypeSet#get(java.lang.String)
71 */
72 public ContentType get(String contentType)
73 {
74 Iterator itr = innerCollection.iterator();
75 while (itr.hasNext())
76 {
77 ContentType p = (ContentType) itr.next();
78 if (p.getContentType().equals(contentType))
79 {
80 return p;
81 }
82 }
83
84 return null;
85 }
86
87 /***
88 * @see java.util.Collection#add(java.lang.Object)
89 */
90 public boolean add(Object o)
91 {
92 ContentType cType = (ContentType) o;
93
94 return innerCollection.add(cType);
95 }
96
97 /***
98 * @see java.util.Collection#remove(java.lang.Object)
99 */
100 public boolean remove(Object o)
101 {
102 ContentType cType = (ContentType) o;
103
104 return innerCollection.remove(cType);
105 }
106
107 /***
108 * @see org.apache.jetspeed.om.common.portlet.ContentTypeSetComposite#addContentType(org.apache.pluto.om.portlet.ContentType)
109 */
110 public void addContentType(ContentType contentType)
111 {
112 add(contentType);
113 }
114
115 /***
116 * @see org.apache.pluto.om.portlet.ContentTypeSet#iterator()
117 */
118 public Iterator iterator()
119 {
120 return innerCollection.iterator();
121 }
122
123 /***
124 * @return
125 */
126 public Collection getInnerCollection()
127 {
128 return innerCollection;
129 }
130
131 /***
132 * @param collection
133 */
134 public void setInnerCollection(Collection collection)
135 {
136 innerCollection = collection;
137 }
138
139 }