File Source: WeblogWrapper.java
/*
P/P * Method: org.apache.roller.weblogger.pojos.wrapper.WeblogWrapper__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.util.ArrayList;
22 import java.util.Date;
23 import java.util.Iterator;
24 import java.util.List;
25 import java.util.Locale;
26 import java.util.Set;
27 import java.util.TimeZone;
28 import org.apache.commons.lang.StringEscapeUtils;
29 import org.apache.roller.weblogger.WebloggerException;
30 import org.apache.roller.weblogger.business.URLStrategy;
31 import org.apache.roller.weblogger.pojos.ThemeTemplate;
32 import org.apache.roller.weblogger.pojos.Weblog;
33 import org.apache.roller.weblogger.pojos.WeblogCategory;
34 import org.apache.roller.weblogger.pojos.WeblogEntry;
35 import org.apache.roller.weblogger.pojos.WeblogEntryComment;
36 import org.apache.roller.weblogger.pojos.WeblogReferrer;
37
38
39 /**
40 * Pojo safety wrapper for Weblog objects.
41 */
42 public class WeblogWrapper {
43
44 // keep a reference to the wrapped pojo
45 private final Weblog pojo;
46
47 // url strategy to use for any url building
48 private final URLStrategy urlStrategy;
49
50
51 // 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.WeblogWrapper(Weblog, URLStrategy)
*
* Postconditions:
* this.pojo == toWrap
* init'ed(this.pojo)
* this.urlStrategy == strat
* init'ed(this.urlStrategy)
*/
52 private WeblogWrapper(Weblog toWrap, URLStrategy strat) {
53 this.pojo = toWrap;
54 this.urlStrategy = strat;
55 }
56
57
58 // wrap the given pojo if it is not null
59 public static WeblogWrapper wrap(Weblog toWrap, URLStrategy strat) {
/*
P/P * Method: WeblogWrapper wrap(Weblog, URLStrategy)
*
* Postconditions:
* return_value == One-of{&new WeblogWrapper(wrap#1), null}
* return_value in Addr_Set{null,&new WeblogWrapper(wrap#1)}
* new WeblogWrapper(wrap#1) num objects <= 1
* new WeblogWrapper(wrap#1).pojo == toWrap
* new WeblogWrapper(wrap#1).pojo != null
* new WeblogWrapper(wrap#1).urlStrategy == strat
* init'ed(new WeblogWrapper(wrap#1).urlStrategy)
*
* Test Vectors:
* toWrap: Addr_Set{null}, Inverse{null}
*/
60 if(toWrap != null)
61 return new WeblogWrapper(toWrap, strat);
62
63 return null;
64 }
65
66
67 public ThemeTemplateWrapper getPageByAction(String action)
68 throws WebloggerException {
/*
P/P * Method: ThemeTemplateWrapper getPageByAction(String)
*
* Preconditions:
* this.pojo != null
*
* Presumptions:
* org.apache.roller.weblogger.pojos.Weblog:getTheme(...)@69 != null
*
* Postconditions:
* init'ed(return_value)
*/
69 return ThemeTemplateWrapper.wrap(this.pojo.getTheme().getTemplateByAction(action));
70 }
71
72
73 public ThemeTemplateWrapper getPageByName(String name)
74 throws WebloggerException {
/*
P/P * Method: ThemeTemplateWrapper getPageByName(String)
*
* Preconditions:
* this.pojo != null
*
* Presumptions:
* org.apache.roller.weblogger.pojos.Weblog:getTheme(...)@75 != null
*
* Postconditions:
* init'ed(return_value)
*/
75 return ThemeTemplateWrapper.wrap(this.pojo.getTheme().getTemplateByName(name));
76 }
77
78
79 public ThemeTemplateWrapper getPageByLink(String link)
80 throws WebloggerException {
/*
P/P * Method: ThemeTemplateWrapper getPageByLink(String)
*
* Preconditions:
* this.pojo != null
*
* Presumptions:
* org.apache.roller.weblogger.pojos.Weblog:getTheme(...)@81 != null
*
* Postconditions:
* init'ed(return_value)
*/
81 return ThemeTemplateWrapper.wrap(this.pojo.getTheme().getTemplateByLink(link));
82 }
83
84
85 public List getPages() throws WebloggerException {
86
/*
P/P * Method: List getPages()
*
* Preconditions:
* this.pojo != null
*
* Presumptions:
* org.apache.roller.weblogger.pojos.Weblog:getTheme(...)@87 != null
* org.apache.roller.weblogger.pojos.WeblogTheme:getTemplates(...)@87 != null
*
* Postconditions:
* return_value == &new ArrayList(getPages#1)
* new ArrayList(getPages#1) num objects == 1
*
* Test Vectors:
* java.util.Iterator:hasNext(...)@95: {0}, {1}
*/
87 List initialCollection = this.pojo.getTheme().getTemplates();
88
89 // iterate through and wrap
90 // we force the use of an ArrayList because it should be good enough to cover
91 // for any Collection type we encounter.
92 ArrayList wrappedCollection = new ArrayList(initialCollection.size());
93 Iterator it = initialCollection.iterator();
94 int i = 0;
95 while(it.hasNext()) {
96 wrappedCollection.add(i,ThemeTemplateWrapper.wrap((ThemeTemplate) it.next()));
+ 97 i++;
98 }
99
100 return wrappedCollection;
101 }
102
103
104 public String getId() {
/*
P/P * Method: String getId()
*
* Preconditions:
* this.pojo != null
*
* Postconditions:
* init'ed(return_value)
*/
105 return this.pojo.getId();
106 }
107
108
109 public String getHandle() {
/*
P/P * Method: String getHandle()
*
* Preconditions:
* this.pojo != null
*
* Postconditions:
* init'ed(return_value)
*/
110 return this.pojo.getHandle();
111 }
112
113
114 public String getName() {
/*
P/P * Method: String getName()
*
* Preconditions:
* this.pojo != null
*
* Postconditions:
* init'ed(return_value)
*/
115 return StringEscapeUtils.escapeHtml(this.pojo.getName());
116 }
117
118
119 public String getDescription() {
/*
P/P * Method: String getDescription()
*
* Preconditions:
* this.pojo != null
*
* Postconditions:
* init'ed(return_value)
*/
120 return this.pojo.getDescription();
121 }
122
123
124 public UserWrapper getCreator() {
/*
P/P * Method: UserWrapper getCreator()
*
* Preconditions:
* this.pojo != null
*
* Postconditions:
* init'ed(return_value)
*/
125 return UserWrapper.wrap(this.pojo.getCreator());
126 }
127
128
129 public String getDefaultPageId() {
/*
P/P * Method: String getDefaultPageId()
*
* Preconditions:
* this.pojo != null
*
* Postconditions:
* init'ed(return_value)
*/
130 return this.pojo.getDefaultPageId();
131 }
132
133
134 public String getWeblogDayPageId() {
/*
P/P * Method: String getWeblogDayPageId()
*
* Preconditions:
* this.pojo != null
*
* Postconditions:
* init'ed(return_value)
*/
135 return this.pojo.getWeblogDayPageId();
136 }
137
138
139 public Boolean getEnableBloggerApi() {
/*
P/P * Method: Boolean getEnableBloggerApi()
*
* Preconditions:
* this.pojo != null
*
* Postconditions:
* init'ed(return_value)
*/
140 return this.pojo.getEnableBloggerApi();
141 }
142
143
144 public WeblogCategoryWrapper getBloggerCategory() {
/*
P/P * Method: WeblogCategoryWrapper getBloggerCategory()
*
* Preconditions:
* this.pojo != null
*
* Presumptions:
* org.apache.roller.weblogger.pojos.Weblog:getBloggerCategory(...)@145 != 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)
*/
145 return WeblogCategoryWrapper.wrap(this.pojo.getBloggerCategory(), urlStrategy);
146 }
147
148
149 public WeblogCategoryWrapper getDefaultCategory() {
/*
P/P * Method: WeblogCategoryWrapper getDefaultCategory()
*
* Preconditions:
* this.pojo != null
*
* Presumptions:
* org.apache.roller.weblogger.pojos.Weblog:getDefaultCategory(...)@150 != 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)
*/
150 return WeblogCategoryWrapper.wrap(this.pojo.getDefaultCategory(), urlStrategy);
151 }
152
153
154 public String getEditorPage() {
/*
P/P * Method: String getEditorPage()
*
* Preconditions:
* this.pojo != null
*
* Postconditions:
* init'ed(return_value)
*/
155 return this.pojo.getEditorPage();
156 }
157
158
159 public String getBlacklist() {
/*
P/P * Method: String getBlacklist()
*
* Preconditions:
* this.pojo != null
*
* Postconditions:
* init'ed(return_value)
*/
160 return this.pojo.getBlacklist();
161 }
162
163
164 public Boolean getAllowComments() {
/*
P/P * Method: Boolean getAllowComments()
*
* Preconditions:
* this.pojo != null
*
* Postconditions:
* init'ed(return_value)
*/
165 return this.pojo.getAllowComments();
166 }
167
168
169 public Boolean getDefaultAllowComments() {
/*
P/P * Method: Boolean getDefaultAllowComments()
*
* Preconditions:
* this.pojo != null
*
* Postconditions:
* init'ed(return_value)
*/
170 return this.pojo.getDefaultAllowComments();
171 }
172
173
174 public int getDefaultCommentDays() {
/*
P/P * Method: int getDefaultCommentDays()
*
* Preconditions:
* this.pojo != null
*
* Postconditions:
* init'ed(return_value)
*/
175 return this.pojo.getDefaultCommentDays();
176 }
177
178
179 public Boolean getModerateComments() {
/*
P/P * Method: Boolean getModerateComments()
*
* Preconditions:
* this.pojo != null
*
* Postconditions:
* init'ed(return_value)
*/
180 return this.pojo.getModerateComments();
181 }
182
183
184 public Boolean getEmailComments() {
/*
P/P * Method: Boolean getEmailComments()
*
* Preconditions:
* this.pojo != null
*
* Postconditions:
* init'ed(return_value)
*/
185 return this.pojo.getEmailComments();
186 }
187
188
189 public String getEmailFromAddress() {
/*
P/P * Method: String getEmailFromAddress()
*
* Preconditions:
* this.pojo != null
*
* Postconditions:
* init'ed(return_value)
*/
190 return this.pojo.getEmailFromAddress();
191 }
192
193
194 public String getEmailAddress() {
/*
P/P * Method: String getEmailAddress()
*
* Preconditions:
* this.pojo != null
*
* Postconditions:
* init'ed(return_value)
*/
195 return this.pojo.getEmailAddress();
196 }
197
198
199 public String getEditorTheme() {
/*
P/P * Method: String getEditorTheme()
*
* Preconditions:
* this.pojo != null
*
* Postconditions:
* init'ed(return_value)
*/
200 return this.pojo.getEditorTheme();
201 }
202
203
204 public String getLocale() {
/*
P/P * Method: String getLocale()
*
* Preconditions:
* this.pojo != null
*
* Postconditions:
* init'ed(return_value)
*/
205 return this.pojo.getLocale();
206 }
207
208
209 public String getTimeZone() {
/*
P/P * Method: String getTimeZone()
*
* Preconditions:
* this.pojo != null
*
* Postconditions:
* init'ed(return_value)
*/
210 return this.pojo.getTimeZone();
211 }
212
213
214 public Date getDateCreated() {
/*
P/P * Method: Date getDateCreated()
*
* Preconditions:
* this.pojo != null
*
* Postconditions:
* init'ed(return_value)
*/
215 return this.pojo.getDateCreated();
216 }
217
218
219 public String getDefaultPlugins() {
/*
P/P * Method: String getDefaultPlugins()
*
* Preconditions:
* this.pojo != null
*
* Postconditions:
* init'ed(return_value)
*/
220 return this.pojo.getDefaultPlugins();
221 }
222
223
224 public Locale getLocaleInstance() {
/*
P/P * Method: Locale getLocaleInstance()
*
* Preconditions:
* this.pojo != null
*
* Postconditions:
* init'ed(return_value)
*/
225 return this.pojo.getLocaleInstance();
226 }
227
228
229 public TimeZone getTimeZoneInstance() {
/*
P/P * Method: TimeZone getTimeZoneInstance()
*
* Preconditions:
* this.pojo != null
*
* Postconditions:
* init'ed(return_value)
*/
230 return this.pojo.getTimeZoneInstance();
231 }
232
233
234 public int getEntryDisplayCount() {
/*
P/P * Method: int getEntryDisplayCount()
*
* Preconditions:
* this.pojo != null
*
* Postconditions:
* init'ed(return_value)
*/
235 return this.pojo.getEntryDisplayCount();
236 }
237
238
239 public Boolean getEnabled() {
/*
P/P * Method: Boolean getEnabled()
*
* Preconditions:
* this.pojo != null
*
* Postconditions:
* init'ed(return_value)
*/
240 return this.pojo.getEnabled();
241 }
242
243
244 public Boolean getActive() {
/*
P/P * Method: Boolean getActive()
*
* Preconditions:
* this.pojo != null
*
* Postconditions:
* init'ed(return_value)
*/
245 return this.pojo.getActive();
246 }
247
248
249 public Date getLastModified() {
/*
P/P * Method: Date getLastModified()
*
* Preconditions:
* this.pojo != null
*
* Postconditions:
* init'ed(return_value)
*/
250 return this.pojo.getLastModified();
251 }
252
253
254 public boolean isEnableMultiLang() {
/*
P/P * Method: bool isEnableMultiLang()
*
* Preconditions:
* this.pojo != null
*
* Postconditions:
* init'ed(return_value)
*/
255 return this.pojo.isEnableMultiLang();
256 }
257
258
259 public boolean isShowAllLangs() {
/*
P/P * Method: bool isShowAllLangs()
*
* Preconditions:
* this.pojo != null
*
* Postconditions:
* init'ed(return_value)
*/
260 return this.pojo.isShowAllLangs();
261 }
262
263
264 public String getStylesheet() throws WebloggerException {
265 // custom stylesheet comes from the weblog theme
/*
P/P * Method: String getStylesheet()
*
* Preconditions:
* this.pojo != null
* (soft) this.urlStrategy != null
*
* Presumptions:
* org.apache.roller.weblogger.pojos.Weblog:getTheme(...)@266 != null
* org.apache.roller.weblogger.pojos.Weblog:getTheme(...)@267 != null
* org.apache.roller.weblogger.pojos.WeblogTheme:getStylesheet(...)@267 != null
*
* Postconditions:
* init'ed(return_value)
*
* Test Vectors:
* org.apache.roller.weblogger.pojos.WeblogTheme:getStylesheet(...)@266: Addr_Set{null}, Inverse{null}
*/
266 if(this.pojo.getTheme().getStylesheet() != null) {
267 return urlStrategy.getWeblogPageURL(this.pojo, null, this.pojo.getTheme().getStylesheet().getLink(), null, null, null, null, 0, false);
268 }
269 return null;
270 }
271
272
273 /**
274 * Get path to weblog icon image if defined.
275 *
276 * This method is somewhat smart in the sense that it will check the entered
277 * icon value and if it is a full url then it will be left alone, but if it
278 * is a relative path to a file in the weblog's uploads section then it will
279 * build the full url to that resource and return it.
280 */
281 public String getIcon() {
282
/*
P/P * Method: String getIcon()
*
* Preconditions:
* this.pojo != null
* (soft) this.urlStrategy != null
*
* Postconditions:
* init'ed(return_value)
*
* Test Vectors:
* java.lang.String:startsWith(...)@288: {1}, {0}
* java.lang.String:startsWith(...)@288: {0}, {1}
* org.apache.roller.weblogger.pojos.Weblog:getIconPath(...)@283: Inverse{null}, Addr_Set{null}
*/
283 String iconPath = this.pojo.getIconPath();
284 if(iconPath == null) {
285 return null;
286 }
287
288 if(iconPath.startsWith("http") || iconPath.startsWith("/")) {
289 // if icon path is a relative path then assume it's a weblog resource
290 return iconPath;
291 } else {
292 // otherwise it's just a plain old url
293 return urlStrategy.getWeblogResourceURL(this.pojo, iconPath, false);
294 }
295
296 }
297
298
299 public String getAbout() {
/*
P/P * Method: String getAbout()
*
* Preconditions:
* this.pojo != null
*
* Postconditions:
* init'ed(return_value)
*/
300 return this.pojo.getAbout();
301 }
302
303
304
305 public String getURL() {
/*
P/P * Method: String getURL()
*
* Preconditions:
* this.pojo != null
*
* Postconditions:
* init'ed(return_value)
*/
306 return this.pojo.getURL();
307 }
308
309
310 public String getAbsoluteURL() {
/*
P/P * Method: String getAbsoluteURL()
*
* Preconditions:
* this.pojo != null
*
* Postconditions:
* init'ed(return_value)
*/
311 return this.pojo.getAbsoluteURL();
312 }
313
314
315 public WeblogEntryWrapper getWeblogEntry(String anchor) {
/*
P/P * Method: WeblogEntryWrapper getWeblogEntry(String)
*
* Preconditions:
* this.pojo != null
*
* Presumptions:
* org.apache.roller.weblogger.pojos.Weblog:getWeblogEntry(...)@316 != null
*
* Postconditions:
* return_value == &new WeblogEntryWrapper(wrap#1)
* new WeblogEntryWrapper(wrap#1) num objects == 1
* new WeblogEntryWrapper(wrap#1).pojo != null
* new WeblogEntryWrapper(wrap#1).urlStrategy == this.urlStrategy
* init'ed(new WeblogEntryWrapper(wrap#1).urlStrategy)
*/
316 return WeblogEntryWrapper.wrap(this.pojo.getWeblogEntry(anchor), urlStrategy);
317 }
318
319
320 public List getWeblogCategories() {
/*
P/P * Method: List getWeblogCategories()
*
* Preconditions:
* this.pojo != null
*
* Presumptions:
* org.apache.roller.weblogger.pojos.Weblog:getWeblogCategories(...)@321 != null
*
* Postconditions:
* return_value == &new ArrayList(getWeblogCategories#1)
* new ArrayList(getWeblogCategories#1) num objects == 1
*
* Test Vectors:
* java.util.Iterator:hasNext(...)@329: {0}, {1}
*/
321 Set initialCollection = this.pojo.getWeblogCategories();
322
323 // iterate through and wrap
324 // we force the use of an ArrayList because it should be good enough to cover
325 // for any Collection type we encounter.
326 ArrayList wrappedCollection = new ArrayList(initialCollection.size());
327 Iterator it = initialCollection.iterator();
328 int i = 0;
329 while(it.hasNext()) {
330 wrappedCollection.add(i,WeblogCategoryWrapper.wrap((WeblogCategory) it.next(), urlStrategy));
+ 331 i++;
332 }
333
334 return wrappedCollection;
335 }
336
337
338 public List getWeblogCategories(String categoryPath) {
/*
P/P * Method: List getWeblogCategories(String)
*
* Preconditions:
* this.pojo != null
*
* Presumptions:
* org.apache.roller.weblogger.pojos.Weblog:getWeblogCategories(...)@339 != null
*
* Postconditions:
* return_value == &new ArrayList(getWeblogCategories#1)
* new ArrayList(getWeblogCategories#1) num objects == 1
*
* Test Vectors:
* java.util.Iterator:hasNext(...)@347: {0}, {1}
*/
339 Set initialCollection = this.pojo.getWeblogCategories(categoryPath);
340
341 // iterate through and wrap
342 // we force the use of an ArrayList because it should be good enough to cover
343 // for any Collection type we encounter.
344 ArrayList wrappedCollection = new ArrayList(initialCollection.size());
345 Iterator it = initialCollection.iterator();
346 int i = 0;
347 while(it.hasNext()) {
348 wrappedCollection.add(i,WeblogCategoryWrapper.wrap((WeblogCategory) it.next(), urlStrategy));
+ 349 i++;
350 }
351
352 return wrappedCollection;
353 }
354
355
356 public WeblogCategoryWrapper getWeblogCategory(String categoryPath) {
/*
P/P * Method: WeblogCategoryWrapper getWeblogCategory(String)
*
* Preconditions:
* this.pojo != null
*
* Presumptions:
* org.apache.roller.weblogger.pojos.Weblog:getWeblogCategory(...)@357 != 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)
*/
357 return WeblogCategoryWrapper.wrap(this.pojo.getWeblogCategory(categoryPath), urlStrategy);
358 }
359
360
361 public List getRecentWeblogEntries(String cat,int length) {
/*
P/P * Method: List getRecentWeblogEntries(String, int)
*
* Preconditions:
* this.pojo != null
*
* Presumptions:
* org.apache.roller.weblogger.pojos.Weblog:getRecentWeblogEntries(...)@362 != null
*
* Postconditions:
* return_value == &new ArrayList(getRecentWeblogEntries#1)
* new ArrayList(getRecentWeblogEntries#1) num objects == 1
*
* Test Vectors:
* java.util.Iterator:hasNext(...)@370: {0}, {1}
*/
362 List initialCollection = this.pojo.getRecentWeblogEntries(cat,length);
363
364 // iterate through and wrap
365 // we force the use of an ArrayList because it should be good enough to cover
366 // for any Collection type we encounter.
367 ArrayList wrappedCollection = new ArrayList(initialCollection.size());
368 Iterator it = initialCollection.iterator();
369 int i = 0;
370 while(it.hasNext()) {
371 wrappedCollection.add(i,WeblogEntryWrapper.wrap((WeblogEntry) it.next(), urlStrategy));
+ 372 i++;
373 }
374
375 return wrappedCollection;
376 }
377
378
379 public List getRecentWeblogEntriesByTag(String tag,int length) {
/*
P/P * Method: List getRecentWeblogEntriesByTag(String, int)
*
* Preconditions:
* this.pojo != null
*
* Presumptions:
* org.apache.roller.weblogger.pojos.Weblog:getRecentWeblogEntriesByTag(...)@380 != null
*
* Postconditions:
* return_value == &new ArrayList(getRecentWeblogEntriesByTag#1)
* new ArrayList(getRecentWeblogEntriesByTag#1) num objects == 1
*
* Test Vectors:
* java.util.Iterator:hasNext(...)@388: {0}, {1}
*/
380 List initialCollection = this.pojo.getRecentWeblogEntriesByTag(tag,length);
381
382 // iterate through and wrap
383 // we force the use of an ArrayList because it should be good enough to cover
384 // for any Collection type we encounter.
385 ArrayList wrappedCollection = new ArrayList(initialCollection.size());
386 Iterator it = initialCollection.iterator();
387 int i = 0;
388 while(it.hasNext()) {
389 wrappedCollection.add(i,WeblogEntryWrapper.wrap((WeblogEntry) it.next(), urlStrategy));
+ 390 i++;
391 }
392
393 return wrappedCollection;
394 }
395
396
397 public List getRecentComments(int length) {
/*
P/P * Method: List getRecentComments(int)
*
* Preconditions:
* this.pojo != null
*
* Presumptions:
* org.apache.roller.weblogger.pojos.Weblog:getRecentComments(...)@398 != null
*
* Postconditions:
* return_value == &new ArrayList(getRecentComments#1)
* new ArrayList(getRecentComments#1) num objects == 1
*
* Test Vectors:
* java.util.Iterator:hasNext(...)@406: {0}, {1}
*/
398 List initialCollection = this.pojo.getRecentComments(length);
399
400 // iterate through and wrap
401 // we force the use of an ArrayList because it should be good enough to cover
402 // for any Collection type we encounter.
403 ArrayList wrappedCollection = new ArrayList(initialCollection.size());
404 Iterator it = initialCollection.iterator();
405 int i = 0;
406 while(it.hasNext()) {
407 wrappedCollection.add(i,WeblogEntryCommentWrapper.wrap((WeblogEntryComment) it.next(), urlStrategy));
+ 408 i++;
409 }
410
411 return wrappedCollection;
412 }
413
414
415 public WeblogBookmarkFolderWrapper getBookmarkFolder(String folderName) {
/*
P/P * Method: WeblogBookmarkFolderWrapper getBookmarkFolder(String)
*
* Preconditions:
* this.pojo != null
*
* Postconditions:
* init'ed(return_value)
*/
416 return WeblogBookmarkFolderWrapper.wrap(this.pojo.getBookmarkFolder(folderName));
417 }
418
419
420 public List getTodaysReferrers() {
/*
P/P * Method: List getTodaysReferrers()
*
* Preconditions:
* this.pojo != null
*
* Presumptions:
* org.apache.roller.weblogger.pojos.Weblog:getTodaysReferrers(...)@421 != null
*
* Postconditions:
* return_value == &new ArrayList(getTodaysReferrers#1)
* new ArrayList(getTodaysReferrers#1) num objects == 1
*
* Test Vectors:
* java.util.Iterator:hasNext(...)@429: {0}, {1}
*/
421 List initialCollection = this.pojo.getTodaysReferrers();
422
423 // iterate through and wrap
424 // we force the use of an ArrayList because it should be good enough to cover
425 // for any Collection type we encounter.
426 ArrayList wrappedCollection = new ArrayList(initialCollection.size());
427 Iterator it = initialCollection.iterator();
428 int i = 0;
429 while(it.hasNext()) {
430 wrappedCollection.add(i,WeblogReferrerWrapper.wrap((WeblogReferrer) it.next(), urlStrategy));
+ 431 i++;
432 }
433
434 return wrappedCollection;
435 }
436
437
438 public int getTodaysHits() {
/*
P/P * Method: int getTodaysHits()
*
* Preconditions:
* this.pojo != null
*
* Postconditions:
* init'ed(return_value)
*/
439 return this.pojo.getTodaysHits();
440 }
441
442 // TODO: needs wrapping
443 public List getPopularTags(int sinceDays,int length) {
/*
P/P * Method: List getPopularTags(int, int)
*
* Preconditions:
* this.pojo != null
*
* Postconditions:
* init'ed(return_value)
*/
444 return this.pojo.getPopularTags(sinceDays,length);
445 }
446
447
448 public long getCommentCount() {
/*
P/P * Method: long getCommentCount()
*
* Preconditions:
* this.pojo != null
*
* Postconditions:
* init'ed(return_value)
*/
449 return this.pojo.getCommentCount();
450 }
451
452
453 public long getEntryCount() {
/*
P/P * Method: long getEntryCount()
*
* Preconditions:
* this.pojo != null
*
* Postconditions:
* init'ed(return_value)
*/
454 return this.pojo.getEntryCount();
455 }
456
457
458 /**
459 * this is a special method to access the original pojo
460 * we don't really want to do this, but it's necessary
461 * because some parts of the rendering process still need the
462 * orginal pojo object
463 */
464 public Weblog getPojo() {
/*
P/P * Method: Weblog getPojo()
*
* Postconditions:
* return_value == this.pojo
* init'ed(return_value)
*/
465 return this.pojo;
466 }
467
468 }
SofCheck Inspector Build Version : 2.18479
| WeblogWrapper.java |
2009-Jan-02 14:25:32 |
| WeblogWrapper.class |
2009-Sep-04 03:12:32 |