%line | %branch | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
org.apache.jetspeed.om.portlet.impl.ContentTypeSetImpl |
|
|
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.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 | 0 | { |
39 | 0 | innerCollection = new ArrayList(); |
40 | 0 | } |
41 | ||
42 | public ContentTypeSetImpl(Collection collection) |
|
43 | 0 | { |
44 | 0 | innerCollection = collection; |
45 | 0 | } |
46 | ||
47 | public boolean supportsPortletMode(PortletMode mode) |
|
48 | { |
|
49 | // Always support "VIEW". Some portlet vendors do not indicate view |
|
50 | // in the deployment descriptor. |
|
51 | 0 | if(mode.equals(PortletMode.VIEW)) |
52 | { |
|
53 | 0 | return true; |
54 | } |
|
55 | ||
56 | 0 | Iterator itr = innerCollection.iterator(); |
57 | 0 | while (itr.hasNext()) |
58 | { |
|
59 | 0 | ContentType p = (ContentType) itr.next(); |
60 | 0 | if (p.supportsPortletMode(mode)) |
61 | { |
|
62 | 0 | return true; |
63 | } |
|
64 | 0 | } |
65 | ||
66 | 0 | 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 | 0 | Iterator itr = innerCollection.iterator(); |
75 | 0 | while (itr.hasNext()) |
76 | { |
|
77 | 0 | ContentType p = (ContentType) itr.next(); |
78 | 0 | if (p.getContentType().equals(contentType)) |
79 | { |
|
80 | 0 | return p; |
81 | } |
|
82 | 0 | } |
83 | ||
84 | 0 | return null; |
85 | } |
|
86 | ||
87 | /** |
|
88 | * @see java.util.Collection#add(java.lang.Object) |
|
89 | */ |
|
90 | public boolean add(Object o) |
|
91 | { |
|
92 | 0 | ContentType cType = (ContentType) o; |
93 | ||
94 | 0 | 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 | 0 | ContentType cType = (ContentType) o; |
103 | ||
104 | 0 | 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 | 0 | add(contentType); |
113 | 0 | } |
114 | ||
115 | /** |
|
116 | * @see org.apache.pluto.om.portlet.ContentTypeSet#iterator() |
|
117 | */ |
|
118 | public Iterator iterator() |
|
119 | { |
|
120 | 0 | return innerCollection.iterator(); |
121 | } |
|
122 | ||
123 | /** |
|
124 | * @return |
|
125 | */ |
|
126 | public Collection getInnerCollection() |
|
127 | { |
|
128 | 0 | return innerCollection; |
129 | } |
|
130 | ||
131 | /** |
|
132 | * @param collection |
|
133 | */ |
|
134 | public void setInnerCollection(Collection collection) |
|
135 | { |
|
136 | 0 | innerCollection = collection; |
137 | 0 | } |
138 | ||
139 | } |
This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |