File Source: WeblogEntryWrapper.java
/*
P/P * Method: org.apache.roller.weblogger.pojos.wrapper.WeblogEntryWrapper__static_init
*/
1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. The ASF licenses this file to You
4 * under the Apache License, Version 2.0 (the "License"); you may not
5 * use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License. For additional information regarding
15 * copyright in this work, please see the NOTICE file in the top level
16 * directory of this distribution.
17 */
18
19 package org.apache.roller.weblogger.pojos.wrapper;
20
21 import java.sql.Timestamp;
22 import java.util.ArrayList;
23 import java.util.Iterator;
24 import java.util.List;
25 import java.util.Set;
26 import org.apache.roller.weblogger.business.URLStrategy;
27 import org.apache.roller.weblogger.pojos.WeblogCategory;
28 import org.apache.roller.weblogger.pojos.WeblogEntry;
29 import org.apache.roller.weblogger.pojos.WeblogEntryAttribute;
30 import org.apache.roller.weblogger.pojos.WeblogEntryComment;
31 import org.apache.roller.weblogger.pojos.WeblogEntryTag;
32 import org.apache.roller.weblogger.pojos.WeblogReferrer;
33
34
35 /**
36 * Pojo safety wrapper for WeblogEntry objects.
37 */
38 public class WeblogEntryWrapper {
39
40 // keep a reference to the wrapped pojo
41 private final WeblogEntry pojo;
42
43 // url strategy to use for any url building
44 private final URLStrategy urlStrategy;
45
46
47 // this is private so that we can force the use of the .wrap(pojo) method
/*
P/P * Method: void org.apache.roller.weblogger.pojos.wrapper.WeblogEntryWrapper(WeblogEntry, URLStrategy)
*
* Postconditions:
* this.pojo == toWrap
* init'ed(this.pojo)
* this.urlStrategy == strat
* init'ed(this.urlStrategy)
*/
48 private WeblogEntryWrapper(WeblogEntry toWrap, URLStrategy strat) {
49 this.pojo = toWrap;
50 this.urlStrategy = strat;
51 }
52
53
54 // wrap the given pojo if it is not null
55 public static WeblogEntryWrapper wrap(WeblogEntry toWrap, URLStrategy strat) {
/*
P/P * Method: WeblogEntryWrapper wrap(WeblogEntry, URLStrategy)
*
* Postconditions:
* return_value == One-of{&new WeblogEntryWrapper(wrap#1), null}
* return_value in Addr_Set{null,&new WeblogEntryWrapper(wrap#1)}
* new WeblogEntryWrapper(wrap#1) num objects <= 1
* new WeblogEntryWrapper(wrap#1).pojo == toWrap
* new WeblogEntryWrapper(wrap#1).pojo != null
* new WeblogEntryWrapper(wrap#1).urlStrategy == strat
* init'ed(new WeblogEntryWrapper(wrap#1).urlStrategy)
*
* Test Vectors:
* toWrap: Addr_Set{null}, Inverse{null}
*/
56 if(toWrap != null)
57 return new WeblogEntryWrapper(toWrap, strat);
58
59 return null;
60 }
61
62
63 public String getId() {
/*
P/P * Method: String getId()
*
* Preconditions:
* this.pojo != null
*
* Postconditions:
* init'ed(return_value)
*/
64 return this.pojo.getId();
65 }
66
67
68 public WeblogCategoryWrapper getCategory() {
/*
P/P * Method: WeblogCategoryWrapper getCategory()
*
* Preconditions:
* this.pojo != null
*
* Presumptions:
* org.apache.roller.weblogger.pojos.WeblogEntry:getCategory(...)@69 != null
*
* Postconditions:
* return_value == &new WeblogCategoryWrapper(wrap#1)
* new WeblogCategoryWrapper(wrap#1) num objects == 1
* new WeblogCategoryWrapper(wrap#1).pojo != null
* new WeblogCategoryWrapper(wrap#1).urlStrategy == this.urlStrategy
* init'ed(new WeblogCategoryWrapper(wrap#1).urlStrategy)
*/
69 return WeblogCategoryWrapper.wrap(this.pojo.getCategory(), urlStrategy);
70 }
71
72
73 public List getCategories() {
/*
P/P * Method: List getCategories()
*
* Preconditions:
* this.pojo != null
*
* Presumptions:
* org.apache.roller.weblogger.pojos.WeblogEntry:getCategories(...)@74 != null
*
* Postconditions:
* return_value == &new ArrayList(getCategories#1)
* new ArrayList(getCategories#1) num objects == 1
*
* Test Vectors:
* java.util.Iterator:hasNext(...)@82: {0}, {1}
*/
74 List initialCollection = this.pojo.getCategories();
75
76 // iterate through and wrap
77 // we force the use of an ArrayList because it should be good enough to cover
78 // for any Collection type we encounter.
79 ArrayList wrappedCollection = new ArrayList(initialCollection.size());
80 Iterator it = initialCollection.iterator();
81 int i = 0;
82 while(it.hasNext()) {
83 wrappedCollection.add(i,WeblogCategoryWrapper.wrap((WeblogCategory) it.next(), urlStrategy));
+ 84 i++;
85 }
86
87 return wrappedCollection;
88 }
89
90
91 public WeblogWrapper getWebsite() {
/*
P/P * Method: WeblogWrapper getWebsite()
*
* Preconditions:
* this.pojo != null
*
* Presumptions:
* org.apache.roller.weblogger.pojos.WeblogEntry:getWebsite(...)@92 != null
*
* Postconditions:
* return_value == &new WeblogWrapper(wrap#1)
* new WeblogWrapper(wrap#1) num objects == 1
* new WeblogWrapper(wrap#1).pojo != null
* new WeblogWrapper(wrap#1).urlStrategy == this.urlStrategy
* init'ed(new WeblogWrapper(wrap#1).urlStrategy)
*/
92 return WeblogWrapper.wrap(this.pojo.getWebsite(), urlStrategy);
93 }
94
95
96 public UserWrapper getCreator() {
/*
P/P * Method: UserWrapper getCreator()
*
* Preconditions:
* this.pojo != null
*
* Postconditions:
* init'ed(return_value)
*/
97 return UserWrapper.wrap(this.pojo.getCreator());
98 }
99
100
101 public String getTitle() {
/*
P/P * Method: String getTitle()
*
* Preconditions:
* this.pojo != null
*
* Postconditions:
* init'ed(return_value)
*/
102 return this.pojo.getTitle();
103 }
104
105
106 public String getSummary() {
/*
P/P * Method: String getSummary()
*
* Preconditions:
* this.pojo != null
*
* Postconditions:
* init'ed(return_value)
*/
107 return this.pojo.getSummary();
108 }
109
110 /**
111 * pojo method tagged with @roller.wrapPojoMethod type="simple"
112 *
113 * Simply returns the same value that the pojo would have returned.
114 */
115 public String getText() {
/*
P/P * Method: String getText()
*
* Preconditions:
* this.pojo != null
*
* Postconditions:
* init'ed(return_value)
*/
116 return this.pojo.getText();
117 }
118
119
120 public String getContentType() {
/*
P/P * Method: String getContentType()
*
* Preconditions:
* this.pojo != null
*
* Postconditions:
* init'ed(return_value)
*/
121 return this.pojo.getContentType();
122 }
123
124
125 public String getContentSrc() {
/*
P/P * Method: String getContentSrc()
*
* Preconditions:
* this.pojo != null
*
* Postconditions:
* init'ed(return_value)
*/
126 return this.pojo.getContentSrc();
127 }
128
129
130 public String getAnchor() {
/*
P/P * Method: String getAnchor()
*
* Preconditions:
* this.pojo != null
*
* Postconditions:
* init'ed(return_value)
*/
131 return this.pojo.getAnchor();
132 }
133
134
135 public List getEntryAttributes() {
/*
P/P * Method: List getEntryAttributes()
*
* Preconditions:
* this.pojo != null
*
* Presumptions:
* org.apache.roller.weblogger.pojos.WeblogEntry:getEntryAttributes(...)@136 != null
*
* Postconditions:
* return_value == &new ArrayList(getEntryAttributes#1)
* new ArrayList(getEntryAttributes#1) num objects == 1
*
* Test Vectors:
* java.util.Iterator:hasNext(...)@144: {0}, {1}
*/
136 Set initialCollection = this.pojo.getEntryAttributes();
137
138 // iterate through and wrap
139 // we force the use of an ArrayList because it should be good enough to cover
140 // for any Collection type we encounter.
141 ArrayList wrappedCollection = new ArrayList(initialCollection.size());
142 Iterator it = initialCollection.iterator();
143 int i = 0;
144 while(it.hasNext()) {
145 wrappedCollection.add(i,WeblogEntryAttributeWrapper.wrap((WeblogEntryAttribute) it.next()));
+ 146 i++;
147 }
148
149 return wrappedCollection;
150 }
151
152
153 public String findEntryAttribute(String name) {
/*
P/P * Method: String findEntryAttribute(String)
*
* Preconditions:
* this.pojo != null
*
* Postconditions:
* init'ed(return_value)
*/
154 return this.pojo.findEntryAttribute(name);
155 }
156
157
158 public Timestamp getPubTime() {
/*
P/P * Method: Timestamp getPubTime()
*
* Preconditions:
* this.pojo != null
*
* Postconditions:
* init'ed(return_value)
*/
159 return this.pojo.getPubTime();
160 }
161
162
163 public Timestamp getUpdateTime() {
/*
P/P * Method: Timestamp getUpdateTime()
*
* Preconditions:
* this.pojo != null
*
* Postconditions:
* init'ed(return_value)
*/
164 return this.pojo.getUpdateTime();
165 }
166
167
168 public String getStatus() {
/*
P/P * Method: String getStatus()
*
* Preconditions:
* this.pojo != null
*
* Postconditions:
* init'ed(return_value)
*/
169 return this.pojo.getStatus();
170 }
171
172
173 public String getLink() {
/*
P/P * Method: String getLink()
*
* Preconditions:
* this.pojo != null
*
* Postconditions:
* init'ed(return_value)
*/
174 return this.pojo.getLink();
175 }
176
177
178 public String getPlugins() {
/*
P/P * Method: String getPlugins()
*
* Preconditions:
* this.pojo != null
*
* Postconditions:
* init'ed(return_value)
*/
179 return this.pojo.getPlugins();
180 }
181
182
183 public Boolean getAllowComments() {
/*
P/P * Method: Boolean getAllowComments()
*
* Preconditions:
* this.pojo != null
*
* Postconditions:
* init'ed(return_value)
*/
184 return this.pojo.getAllowComments();
185 }
186
187
188 public Integer getCommentDays() {
/*
P/P * Method: Integer getCommentDays()
*
* Preconditions:
* this.pojo != null
*
* Postconditions:
* init'ed(return_value)
*/
189 return this.pojo.getCommentDays();
190 }
191
192
193 public Boolean getRightToLeft() {
/*
P/P * Method: Boolean getRightToLeft()
*
* Preconditions:
* this.pojo != null
*
* Postconditions:
* init'ed(return_value)
*/
194 return this.pojo.getRightToLeft();
195 }
196
197
198 public Boolean getPinnedToMain() {
/*
P/P * Method: Boolean getPinnedToMain()
*
* Preconditions:
* this.pojo != null
*
* Postconditions:
* init'ed(return_value)
*/
199 return this.pojo.getPinnedToMain();
200 }
201
202
203 public String getLocale() {
/*
P/P * Method: String getLocale()
*
* Preconditions:
* this.pojo != null
*
* Postconditions:
* init'ed(return_value)
*/
204 return this.pojo.getLocale();
205 }
206
207
208 public List getTags() {
/*
P/P * Method: List getTags()
*
* Preconditions:
* this.pojo != null
*
* Presumptions:
* org.apache.roller.weblogger.pojos.WeblogEntry:getTags(...)@209 != null
*
* Postconditions:
* return_value == &new ArrayList(getTags#1)
* new ArrayList(getTags#1) num objects == 1
*
* Test Vectors:
* java.util.Iterator:hasNext(...)@217: {0}, {1}
*/
209 Set initialCollection = this.pojo.getTags();
210
211 // iterate through and wrap
212 // we force the use of an ArrayList because it should be good enough to cover
213 // for any Collection type we encounter.
214 ArrayList wrappedCollection = new ArrayList(initialCollection.size());
215 Iterator it = initialCollection.iterator();
216 int i = 0;
217 while(it.hasNext()) {
218 wrappedCollection.add(i,WeblogEntryTagWrapper.wrap((WeblogEntryTag) it.next()));
+ 219 i++;
220 }
221
222 return wrappedCollection;
223 }
224
225
226 public String getTagsAsString() {
/*
P/P * Method: String getTagsAsString()
*
* Preconditions:
* this.pojo != null
*
* Postconditions:
* init'ed(return_value)
*/
227 return this.pojo.getTagsAsString();
228 }
229
230
231 public boolean getCommentsStillAllowed() {
/*
P/P * Method: bool getCommentsStillAllowed()
*
* Preconditions:
* this.pojo != null
*
* Postconditions:
* init'ed(return_value)
*/
232 return this.pojo.getCommentsStillAllowed();
233 }
234
235
236 public String formatPubTime(String pattern) {
/*
P/P * Method: String formatPubTime(String)
*
* Preconditions:
* this.pojo != null
*
* Postconditions:
* init'ed(return_value)
*/
237 return this.pojo.formatPubTime(pattern);
238 }
239
240
241 public String formatUpdateTime(String pattern) {
/*
P/P * Method: String formatUpdateTime(String)
*
* Preconditions:
* this.pojo != null
*
* Postconditions:
* init'ed(return_value)
*/
242 return this.pojo.formatUpdateTime(pattern);
243 }
244
245
246 public List getComments() {
/*
P/P * Method: List getComments()
*
* Preconditions:
* this.pojo != null
*
* Presumptions:
* org.apache.roller.weblogger.pojos.WeblogEntry:getComments(...)@247 != null
*
* Postconditions:
* return_value == &new ArrayList(getComments#1)
* new ArrayList(getComments#1) num objects == 1
*
* Test Vectors:
* java.util.Iterator:hasNext(...)@255: {0}, {1}
*/
247 List initialCollection = this.pojo.getComments();
248
249 // iterate through and wrap
250 // we force the use of an ArrayList because it should be good enough to cover
251 // for any Collection type we encounter.
252 ArrayList wrappedCollection = new ArrayList(initialCollection.size());
253 Iterator it = initialCollection.iterator();
254 int i = 0;
255 while(it.hasNext()) {
256 wrappedCollection.add(i,WeblogEntryCommentWrapper.wrap((WeblogEntryComment) it.next(), urlStrategy));
+ 257 i++;
258 }
259
260 return wrappedCollection;
261 }
262
263
264 public List getComments(boolean ignoreSpam,boolean approvedOnly) {
/*
P/P * Method: List getComments(bool, bool)
*
* Preconditions:
* this.pojo != null
*
* Presumptions:
* org.apache.roller.weblogger.pojos.WeblogEntry:getComments(...)@265 != null
*
* Postconditions:
* return_value == &new ArrayList(getComments#1)
* new ArrayList(getComments#1) num objects == 1
*
* Test Vectors:
* java.util.Iterator:hasNext(...)@273: {0}, {1}
*/
265 List initialCollection = this.pojo.getComments(ignoreSpam,approvedOnly);
266
267 // iterate through and wrap
268 // we force the use of an ArrayList because it should be good enough to cover
269 // for any Collection type we encounter.
270 ArrayList wrappedCollection = new ArrayList(initialCollection.size());
271 Iterator it = initialCollection.iterator();
272 int i = 0;
273 while(it.hasNext()) {
274 wrappedCollection.add(i,WeblogEntryCommentWrapper.wrap((WeblogEntryComment) it.next(), urlStrategy));
+ 275 i++;
276 }
277
278 return wrappedCollection;
279 }
280
281
282 public int getCommentCount() {
/*
P/P * Method: int getCommentCount()
*
* Preconditions:
* this.pojo != null
*
* Postconditions:
* init'ed(return_value)
*/
283 return this.pojo.getCommentCount();
284 }
285
286
287 public List getReferers() {
/*
P/P * Method: List getReferers()
*
* Preconditions:
* this.pojo != null
*
* Presumptions:
* org.apache.roller.weblogger.pojos.WeblogEntry:getReferers(...)@288 != null
*
* Postconditions:
* return_value == &new ArrayList(getReferers#1)
* new ArrayList(getReferers#1) num objects == 1
*
* Test Vectors:
* java.util.Iterator:hasNext(...)@296: {0}, {1}
*/
288 List initialCollection = this.pojo.getReferers();
289
290 // iterate through and wrap
291 // we force the use of an ArrayList because it should be good enough to cover
292 // for any Collection type we encounter.
293 ArrayList wrappedCollection = new ArrayList(initialCollection.size());
294 Iterator it = initialCollection.iterator();
295 int i = 0;
296 while(it.hasNext()) {
297 wrappedCollection.add(i,WeblogReferrerWrapper.wrap((WeblogReferrer) it.next(), urlStrategy));
+ 298 i++;
299 }
300
301 return wrappedCollection;
302 }
303
304
305 public String getPermalink() {
/*
P/P * Method: String getPermalink()
*
* Preconditions:
* this.pojo != null
*
* Postconditions:
* init'ed(return_value)
*/
306 return this.pojo.getPermalink();
307 }
308
309
310 public String getPermaLink() {
/*
P/P * Method: String getPermaLink()
*
* Preconditions:
* this.pojo != null
*
* Postconditions:
* init'ed(return_value)
*/
311 return this.pojo.getPermaLink();
312 }
313
314
315 public String getCommentsLink() {
/*
P/P * Method: String getCommentsLink()
*
* Preconditions:
* this.pojo != null
*
* Postconditions:
* init'ed(return_value)
*/
316 return this.pojo.getCommentsLink();
317 }
318
319
320 public String getDisplayTitle() {
/*
P/P * Method: String getDisplayTitle()
*
* Preconditions:
* this.pojo != null
*
* Postconditions:
* init'ed(return_value)
*/
321 return this.pojo.getDisplayTitle();
322 }
323
324
325 public String getRss09xDescription() {
/*
P/P * Method: String getRss09xDescription()
*
* Preconditions:
* this.pojo != null
*
* Postconditions:
* init'ed(return_value)
*/
326 return this.pojo.getRss09xDescription();
327 }
328
329
330 public String getRss09xDescription(int maxLength) {
/*
P/P * Method: String getRss09xDescription(int)
*
* Preconditions:
* this.pojo != null
*
* Postconditions:
* init'ed(return_value)
*/
331 return this.pojo.getRss09xDescription(maxLength);
332 }
333
334
335 // TODO: check this method for safety
336 public List getPluginsList() {
/*
P/P * Method: List getPluginsList()
*
* Preconditions:
* this.pojo != null
*
* Postconditions:
* init'ed(return_value)
*/
337 return this.pojo.getPluginsList();
338 }
339
340
341 public String getTransformedText() {
/*
P/P * Method: String getTransformedText()
*
* Preconditions:
* this.pojo != null
*
* Postconditions:
* init'ed(return_value)
*/
342 return this.pojo.getTransformedText();
343 }
344
345
346 public String getTransformedSummary() {
/*
P/P * Method: String getTransformedSummary()
*
* Preconditions:
* this.pojo != null
*
* Postconditions:
* init'ed(return_value)
*/
347 return this.pojo.getTransformedSummary();
348 }
349
350
351 public String displayContent(String readMoreLink) {
/*
P/P * Method: String displayContent(String)
*
* Preconditions:
* this.pojo != null
*
* Postconditions:
* init'ed(return_value)
*/
352 return this.pojo.displayContent(readMoreLink);
353 }
354
355
356 public String getDisplayContent() {
/*
P/P * Method: String getDisplayContent()
*
* Preconditions:
* this.pojo != null
*
* Postconditions:
* init'ed(return_value)
*/
357 return this.pojo.getDisplayContent();
358 }
359
360
361 /**
362 * this is a special method to access the original pojo.
363 * we don't really want to do this, but it's necessary
364 * because some parts of the rendering process still need the
365 * orginal pojo object.
366 */
367 public WeblogEntry getPojo() {
/*
P/P * Method: WeblogEntry getPojo()
*
* Postconditions:
* return_value == this.pojo
* init'ed(return_value)
*/
368 return this.pojo;
369 }
370
371 }
SofCheck Inspector Build Version : 2.18479
| WeblogEntryWrapper.java |
2009-Jan-02 14:25:28 |
| WeblogEntryWrapper.class |
2009-Sep-04 03:12:32 |