%line | %branch | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
org.apache.jetspeed.capabilities.impl.MediaTypeImpl |
|
|
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.capabilities.impl; |
|
18 | ||
19 | import java.util.ArrayList; |
|
20 | import java.util.Collection; |
|
21 | ||
22 | import org.apache.commons.collections.CollectionUtils; |
|
23 | import org.apache.jetspeed.capabilities.Capability; |
|
24 | import org.apache.jetspeed.capabilities.MediaType; |
|
25 | import org.apache.jetspeed.capabilities.MimeType; |
|
26 | ||
27 | /** |
|
28 | * Default bean like implementation of MediaTypeEntry interface |
|
29 | * suitable for serializing with Castor |
|
30 | * |
|
31 | * @author <a href="mailto:raphael@apache.org">Rapha\u00ebl Luta</a> |
|
32 | * @version $Id: MediaTypeImpl.java 516448 2007-03-09 16:25:47Z ate $ |
|
33 | */ |
|
34 | public class MediaTypeImpl |
|
35 | implements MediaType |
|
36 | { |
|
37 | protected String characterSet; |
|
38 | private Collection capabilities; |
|
39 | private Collection mimetypes; |
|
40 | private int mediatypeId; |
|
41 | private String title; |
|
42 | private String description; |
|
43 | ||
44 | private String name; // MediaTypeEntry name |
|
45 | ||
46 | public MediaTypeImpl() |
|
47 | 0 | {} |
48 | ||
49 | public MediaTypeImpl(long id, |
|
50 | String name, |
|
51 | int _hidden, |
|
52 | String mimeType, |
|
53 | String title, |
|
54 | String description, |
|
55 | String image, |
|
56 | String role) |
|
57 | 0 | { |
58 | 0 | this.mimetypes.add(mimeType); |
59 | 0 | } |
60 | ||
61 | /** |
|
62 | * Implements the equals operation so that 2 elements are equal if |
|
63 | * all their member values are equal. |
|
64 | */ |
|
65 | public boolean equals(Object object) |
|
66 | { |
|
67 | 0 | if (this == object) |
68 | 0 | return true; |
69 | 0 | if (object==null) |
70 | 0 | return false; |
71 | ||
72 | 0 | MediaTypeImpl obj = (MediaTypeImpl)object; |
73 | ||
74 | ||
75 | 0 | if (this.name!=null) |
76 | { |
|
77 | 0 | if (!name.equals(obj.name)) |
78 | { |
|
79 | 0 | return false; |
80 | } |
|
81 | } |
|
82 | else |
|
83 | { |
|
84 | 0 | if (obj.name!=null) |
85 | { |
|
86 | 0 | return false; |
87 | } |
|
88 | } |
|
89 | ||
90 | 0 | if (this.description!=null) |
91 | { |
|
92 | 0 | if (!description.equals(obj.description)) |
93 | { |
|
94 | 0 | return false; |
95 | } |
|
96 | } |
|
97 | else |
|
98 | { |
|
99 | 0 | if (obj.description!=null) |
100 | { |
|
101 | 0 | return false; |
102 | } |
|
103 | } |
|
104 | ||
105 | 0 | if (characterSet!=null) |
106 | { |
|
107 | 0 | if (!characterSet.equals(obj.characterSet)) |
108 | { |
|
109 | 0 | return false; |
110 | } |
|
111 | } |
|
112 | else |
|
113 | { |
|
114 | 0 | if (obj.characterSet!=null) |
115 | { |
|
116 | 0 | return false; |
117 | } |
|
118 | } |
|
119 | ||
120 | ||
121 | 0 | if (this.title!=null) |
122 | { |
|
123 | 0 | if (!title.equals(obj.title)) |
124 | { |
|
125 | 0 | return false; |
126 | } |
|
127 | } |
|
128 | else |
|
129 | { |
|
130 | 0 | if (obj.title!=null) |
131 | { |
|
132 | 0 | return false; |
133 | } |
|
134 | } |
|
135 | ||
136 | ||
137 | 0 | if (mimetypes != null) |
138 | { |
|
139 | 0 | if (!CollectionUtils.isEqualCollection(mimetypes, obj.mimetypes)) |
140 | { |
|
141 | 0 | return false; |
142 | } |
|
143 | } |
|
144 | else |
|
145 | { |
|
146 | 0 | if (obj.mimetypes != null) |
147 | { |
|
148 | 0 | return false; |
149 | } |
|
150 | } |
|
151 | ||
152 | 0 | if (capabilities != null) |
153 | { |
|
154 | 0 | if (!(CollectionUtils.isEqualCollection(capabilities,obj.capabilities ))) |
155 | 0 | return false; |
156 | } |
|
157 | else |
|
158 | { |
|
159 | 0 | if (obj.capabilities != null) |
160 | { |
|
161 | 0 | return false; |
162 | } |
|
163 | } |
|
164 | ||
165 | 0 | return true; |
166 | } |
|
167 | ||
168 | ||
169 | /** @return the character set associated with this MediaType */ |
|
170 | public String getCharacterSet() |
|
171 | { |
|
172 | 0 | return this.characterSet; |
173 | } |
|
174 | ||
175 | /** Sets the character set associated with this MediaType */ |
|
176 | public void setCharacterSet( String charSet) |
|
177 | { |
|
178 | 0 | this.characterSet = charSet; |
179 | 0 | } |
180 | ||
181 | ||
182 | public Collection getCapabilities() |
|
183 | { |
|
184 | 0 | return this.capabilities; |
185 | } |
|
186 | ||
187 | public void setCapabilities(Collection capabilities) |
|
188 | { |
|
189 | 0 | this.capabilities = capabilities; |
190 | 0 | } |
191 | ||
192 | ||
193 | public Collection getMimetypes() |
|
194 | { |
|
195 | 0 | return this.mimetypes; |
196 | } |
|
197 | ||
198 | public void setMimetypes(Collection mimetypes) |
|
199 | { |
|
200 | 0 | this.mimetypes = mimetypes; |
201 | 0 | } |
202 | ||
203 | public void addMimetype(MimeType mimeType) |
|
204 | { |
|
205 | 0 | if (mimetypes == null) |
206 | 0 | mimetypes = new ArrayList(); |
207 | 0 | if (!mimetypes.contains(mimeType.getName())) |
208 | { |
|
209 | 0 | mimetypes.add(mimeType); |
210 | } |
|
211 | 0 | } |
212 | ||
213 | ||
214 | public void addCapability(Capability capability) |
|
215 | { |
|
216 | 0 | if (capabilities == null) |
217 | 0 | capabilities = new ArrayList(); |
218 | 0 | if (!capabilities.contains(capability.getName())) |
219 | { |
|
220 | 0 | capabilities.add(capability); |
221 | } |
|
222 | 0 | } |
223 | ||
224 | public void removeMimetype(String name) |
|
225 | { |
|
226 | 0 | mimetypes.remove(name); |
227 | 0 | } |
228 | ||
229 | /** |
|
230 | * Set MediaType ID -- Assigns ID |
|
231 | * @param id |
|
232 | */ |
|
233 | public void setMediatypeId(int id) |
|
234 | { |
|
235 | 0 | this.mediatypeId = id; |
236 | 0 | } |
237 | ||
238 | /** |
|
239 | * Get MediaType ID -- Return ID |
|
240 | * @return MediaTypeID |
|
241 | */ |
|
242 | public int getMediatypeId() |
|
243 | { |
|
244 | 0 | return this.mediatypeId; |
245 | } |
|
246 | ||
247 | /** |
|
248 | * Set name ob MediaTypeEntry |
|
249 | */ |
|
250 | public void setName(String name) |
|
251 | { |
|
252 | 0 | this.name = name; |
253 | 0 | } |
254 | ||
255 | /** |
|
256 | * Get name ob MediaTypeEntry |
|
257 | */ |
|
258 | ||
259 | public String getName() |
|
260 | { |
|
261 | 0 | return this.name; |
262 | } |
|
263 | ||
264 | public String getTitle() |
|
265 | { |
|
266 | 0 | return this.title; |
267 | } |
|
268 | ||
269 | public void setTitle(String title) |
|
270 | { |
|
271 | 0 | this.title = title; |
272 | 0 | } |
273 | ||
274 | public String getDescription() |
|
275 | { |
|
276 | 0 | return this.description; |
277 | } |
|
278 | ||
279 | ||
280 | public void setDescription(String desc) |
|
281 | { |
|
282 | 0 | this.description = desc; |
283 | 0 | } |
284 | } |
This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |