File Source: WeblogReferrer.java
/*
P/P * Method: void readObject(ObjectInputStream)
*
* Preconditions:
* Param_1 != null
*
* Presumptions:
* init'ed(org.apache.openjpa.enhance.PersistenceCapable.DESERIALIZED)
*
* Postconditions:
* Param_0.pcDetachedState == org.apache.openjpa.enhance.PersistenceCapable.DESERIALIZED
* (soft) init'ed(Param_0.pcDetachedState)
*/
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;
20
21 import java.io.Serializable;
22 import org.apache.commons.lang.StringEscapeUtils;
23 import org.apache.commons.lang.builder.EqualsBuilder;
24 import org.apache.commons.lang.builder.HashCodeBuilder;
25 import org.apache.roller.util.UUIDGenerator;
26
27
28 /**
29 * Referrer bean.
30 *
31 * @author David M Johnson
32 */
33 public class WeblogReferrer implements Serializable {
34
35 public static final long serialVersionUID = -1817992900602131316L;
36
37 private String id = UUIDGenerator.generateUUID();
38 private Weblog website = null;
39 private WeblogEntry weblogEntry = null;
40 private String dateString = null;
41 private String refererUrl = null;
42 private String refererPermalink = null;
43 private String requestUrl = null;
44 private String title = null;
45 private String excerpt = null;
46 private Boolean visible = null;
47 private Boolean duplicate = null;
48 private Integer dayHits = null;
49 private Integer totalHits = null;
50
51
/*
P/P * Method: void org.apache.roller.weblogger.pojos.WeblogReferrer()
*
* Postconditions:
* this.dateString == null
* this.dayHits == null
* this.duplicate == null
* this.excerpt == null
* this.refererPermalink == null
* this.refererUrl == null
* this.requestUrl == null
* this.title == null
* this.totalHits == null
* this.visible == null
* ...
*/
52 public WeblogReferrer() {
53 }
54
55 public WeblogReferrer(String id,
56 org.apache.roller.weblogger.pojos.Weblog website,org.apache.roller.weblogger.pojos.WeblogEntry weblogEntry,
57 String dateString, String refererUrl,
58 String refererPermalink,
59 String requestUrl, String title,
60 String excerpt, Boolean visible,
61 Boolean duplicate, Integer dayHits,
/*
P/P * Method: void org.apache.roller.weblogger.pojos.WeblogReferrer(String, Weblog, WeblogEntry, String, String, String, String, String, String, Boolean, Boolean, Integer, Integer)
*
* Postconditions:
* this.dateString == dateString
* init'ed(this.dateString)
* this.dayHits == dayHits
* init'ed(this.dayHits)
* this.duplicate == duplicate
* init'ed(this.duplicate)
* this.excerpt == excerpt
* init'ed(this.excerpt)
* init'ed(this.id)
* this.refererPermalink == refererPermalink
* ...
*/
62 Integer totalHits) {
63 //this.id = id;
64 this.website = website;
65 this.weblogEntry = weblogEntry;
66 this.dateString = dateString;
67 this.refererUrl = refererUrl;
68 this.refererPermalink = refererPermalink;
69 this.requestUrl = requestUrl;
70 this.title = title;
71 this.excerpt = excerpt;
72 this.visible = visible;
73 this.duplicate = duplicate;
74 this.dayHits = dayHits;
75 this.totalHits = totalHits;
76 }
77
78 //------------------------------------------------------- Simple properties
79
80 /**
81 * Unique ID and primary key of this Referer.
82 */
83 public String getId() {
/*
P/P * Method: String pcgetId()
*
* Preconditions:
* init'ed(this.id)
*
* Postconditions:
* return_value == this.id
* init'ed(return_value)
*/
84 return this.id;
85 }
86
87 public void setId(String id) {
/*
P/P * Method: void pcsetId(String)
*
* Postconditions:
* this.id == Param_1
* init'ed(this.id)
*/
88 this.id = id;
89 }
90
91
92 /**
93 * ID of website that this referer refers to.
94 *
95 * @roller.wrapPojoMethod type="pojo"
96 * @hibernate.many-to-one column="websiteid" cascade="none" not-null="true"
97 */
98 public org.apache.roller.weblogger.pojos.Weblog getWebsite() {
/*
P/P * Method: Weblog pcgetWebsite()
*
* Preconditions:
* init'ed(this.website)
*
* Postconditions:
* return_value == this.website
* init'ed(return_value)
*/
99 return this.website;
100 }
101
102 public void setWebsite(org.apache.roller.weblogger.pojos.Weblog website) {
/*
P/P * Method: void pcsetWebsite(Weblog)
*
* Postconditions:
* this.website == Param_1
* init'ed(this.website)
*/
103 this.website = website;
104 }
105
106 /**
107 * @roller.wrapPojoMethod type="pojo"
108 * @hibernate.many-to-one column="entryid" cascade="none"
109 */
110 public org.apache.roller.weblogger.pojos.WeblogEntry getWeblogEntry() {
/*
P/P * Method: WeblogEntry pcgetWeblogEntry()
*
* Preconditions:
* init'ed(this.weblogEntry)
*
* Postconditions:
* return_value == this.weblogEntry
* init'ed(return_value)
*/
111 return weblogEntry;
112 }
113
114 /**
115 * @param data
116 */
117 public void setWeblogEntry(org.apache.roller.weblogger.pojos.WeblogEntry data) {
/*
P/P * Method: void pcsetWeblogEntry(WeblogEntry)
*
* Postconditions:
* this.weblogEntry == Param_1
* init'ed(this.weblogEntry)
*/
118 weblogEntry = data;
119 }
120
121 /**
122 * Date string in YYYYMMDD format.
123 *
124 * @roller.wrapPojoMethod type="simple"
125 * @hibernate.property column="datestr" non-null="true" unique="false"
126 */
127 public String getDateString() {
/*
P/P * Method: String pcgetDateString()
*
* Preconditions:
* init'ed(this.dateString)
*
* Postconditions:
* return_value == this.dateString
* init'ed(return_value)
*/
128 return this.dateString;
129 }
130
131 public void setDateString(String dateString) {
/*
P/P * Method: void pcsetDateString(String)
*
* Postconditions:
* this.dateString == Param_1
* init'ed(this.dateString)
*/
132 this.dateString = dateString;
133 }
134
135 /**
136 * URL of the refering page.
137 *
138 * @roller.wrapPojoMethod type="simple"
139 * @hibernate.property column="refurl" non-null="true" unique="false"
140 */
141 public String getRefererUrl() {
/*
P/P * Method: String pcgetRefererUrl()
*
* Preconditions:
* init'ed(this.refererUrl)
*
* Postconditions:
* return_value == this.refererUrl
* init'ed(return_value)
*/
142 return this.refererUrl;
143 }
144
145 public void setRefererUrl(String refererUrl) {
/*
P/P * Method: void pcsetRefererUrl(String)
*
* Postconditions:
* this.refererUrl == Param_1
* init'ed(this.refererUrl)
*/
146 this.refererUrl = refererUrl;
147 }
148
149 /**
150 * Requested URL, the URL linked to by the refering page.
151 *
152 * @roller.wrapPojoMethod type="simple"
153 * @hibernate.property column="refpermalink" non-null="true" unique="false"
154 */
155 public String getRefererPermalink() {
/*
P/P * Method: String pcgetRefererPermalink()
*
* Preconditions:
* init'ed(this.refererPermalink)
*
* Postconditions:
* return_value == this.refererPermalink
* init'ed(return_value)
*/
156 return this.refererPermalink;
157 }
158
159 public void setRefererPermalink(String refererPermalink) {
/*
P/P * Method: void pcsetRefererPermalink(String)
*
* Postconditions:
* this.refererPermalink == Param_1
* init'ed(this.refererPermalink)
*/
160 this.refererPermalink = refererPermalink;
161 }
162
163 /**
164 * Requested URL, the URL linked to by the refering page.
165 *
166 * @roller.wrapPojoMethod type="simple"
167 * @hibernate.property column="requrl" non-null="true" unique="false"
168 */
169 public String getRequestUrl() {
/*
P/P * Method: String pcgetRequestUrl()
*
* Preconditions:
* init'ed(this.requestUrl)
*
* Postconditions:
* return_value == this.requestUrl
* init'ed(return_value)
*/
170 return this.requestUrl;
171 }
172
173 public void setRequestUrl(String requestUrl) {
/*
P/P * Method: void pcsetRequestUrl(String)
*
* Postconditions:
* this.requestUrl == Param_1
* init'ed(this.requestUrl)
*/
174 this.requestUrl = requestUrl;
175 }
176
177 /**
178 * The text on the refering page that surrounds the refering link.
179 *
180 * @roller.wrapPojoMethod type="simple"
181 * @hibernate.property column="title" non-null="true" unique="false"
182 */
183 public String getTitle() {
/*
P/P * Method: String pcgetTitle()
*
* Preconditions:
* init'ed(this.title)
*
* Postconditions:
* return_value == this.title
* init'ed(return_value)
*/
184 return this.title;
185 }
186
187 public void setTitle(String title) {
/*
P/P * Method: void pcsetTitle(String)
*
* Postconditions:
* this.title == Param_1
* init'ed(this.title)
*/
188 this.title = title;
189 }
190
191 /**
192 * The text on the refering page that surrounds the refering link.
193 *
194 * @roller.wrapPojoMethod type="simple"
195 * @hibernate.property column="excerpt" non-null="true" unique="false"
196 */
197 public String getExcerpt() {
/*
P/P * Method: String pcgetExcerpt()
*
* Preconditions:
* init'ed(this.excerpt)
*
* Postconditions:
* return_value == this.excerpt
* init'ed(return_value)
*/
198 return this.excerpt;
199 }
200
201 public void setExcerpt(String excerpt) {
/*
P/P * Method: void pcsetExcerpt(String)
*
* Postconditions:
* this.excerpt == Param_1
* init'ed(this.excerpt)
*/
202 this.excerpt = excerpt;
203 }
204
205 /**
206 * Should this referer be displayed?
207 *
208 * @roller.wrapPojoMethod type="simple"
209 * @hibernate.property column="visible" non-null="true" unique="false"
210 */
211 public Boolean getVisible() {
/*
P/P * Method: Boolean pcgetVisible()
*
* Preconditions:
* init'ed(this.visible)
*
* Postconditions:
* return_value == this.visible
* init'ed(return_value)
*/
212 return this.visible;
213 }
214
215 public void setVisible(Boolean visible) {
/*
P/P * Method: void pcsetVisible(Boolean)
*
* Postconditions:
* this.visible == Param_1
* init'ed(this.visible)
*/
216 this.visible = visible;
217 }
218
219 /**
220 * Is this referer a duplicate?
221 *
222 * @roller.wrapPojoMethod type="simple"
223 * @hibernate.property column="duplicate" non-null="true" unique="false"
224 */
225 public Boolean getDuplicate() {
/*
P/P * Method: Boolean pcgetDuplicate()
*
* Preconditions:
* init'ed(this.duplicate)
*
* Postconditions:
* return_value == this.duplicate
* init'ed(return_value)
*/
226 return this.duplicate;
227 }
228
229 public void setDuplicate(Boolean duplicate) {
/*
P/P * Method: void pcsetDuplicate(Boolean)
*
* Postconditions:
* this.duplicate == Param_1
* init'ed(this.duplicate)
*/
230 this.duplicate = duplicate;
231 }
232
233 /**
234 * Hits received today from this referer.
235 *
236 * @roller.wrapPojoMethod type="simple"
237 * @hibernate.property column="dayhits" non-null="true" unique="false"
238 */
239 public Integer getDayHits() {
/*
P/P * Method: Integer pcgetDayHits()
*
* Preconditions:
* init'ed(this.dayHits)
*
* Postconditions:
* return_value == this.dayHits
* init'ed(return_value)
*/
240 return this.dayHits;
241 }
242
243 public void setDayHits(Integer dayHits) {
/*
P/P * Method: void pcsetDayHits(Integer)
*
* Postconditions:
* this.dayHits == Param_1
* init'ed(this.dayHits)
*/
244 this.dayHits = dayHits;
245 }
246
247 /**
248 * Total hits received from this referer.
249 *
250 * @roller.wrapPojoMethod type="simple"
251 * @hibernate.property column="totalhits" non-null="true" unique="false"
252 */
253 public Integer getTotalHits() {
/*
P/P * Method: Integer pcgetTotalHits()
*
* Preconditions:
* init'ed(this.totalHits)
*
* Postconditions:
* return_value == this.totalHits
* init'ed(return_value)
*/
254 return this.totalHits;
255 }
256
257 public void setTotalHits(Integer totalHits) {
/*
P/P * Method: void pcsetTotalHits(Integer)
*
* Postconditions:
* this.totalHits == Param_1
* init'ed(this.totalHits)
*/
258 this.totalHits = totalHits;
259 }
260
261 //-------------------------------------------------------------------------
262
263 /**
264 * @roller.wrapPojoMethod type="simple"
265 */
266 public String getDisplayUrl(int maxWidth, boolean includeHits) {
/*
P/P * Method: String getDisplayUrl(int, bool)
*
* Preconditions:
* init'ed(this.pcStateManager)
* init'ed(this.refererPermalink)
* (soft) pcInheritedFieldCount <= 232-7
* (soft) init'ed(this.dayHits)
* (soft) init'ed(this.refererUrl)
*
* Presumptions:
* org.apache.commons.lang.StringEscapeUtils:escapeHtml(...)@269 != null
*
* Postconditions:
* java.lang.StringBuffer:toString(...)._tainted == 0
* return_value == &java.lang.StringBuffer:toString(...)
*
* Test Vectors:
* includeHits: {0}, {1}
* java.lang.String:startsWith(...)@273: {0}, {1}
* java.lang.String:startsWith(...)@283: {0}, {1}
* java.lang.String:startsWith(...)@306: {0}, {1}
* java.lang.StringBuffer:length(...)@294: {-231..0}, {1..232-1}
*/
267 StringBuffer sb = new StringBuffer();
268
269 String url = StringEscapeUtils.escapeHtml(getUrl());
270 String displayUrl = url.trim();
271 String restOfUrl = null;
272
273 if (displayUrl.startsWith("http://")) {
274 displayUrl = displayUrl.substring(7);
275 }
276
277 if (displayUrl.length() > maxWidth) {
278 restOfUrl = "..." +
279 displayUrl.substring(maxWidth, displayUrl.length());
280 displayUrl = displayUrl.substring(0, maxWidth) + "...";
281 }
282
283 if (url.startsWith("http://")) {
284 sb.append("<a href=\"");
285 sb.append(url);
286 }
287
288 // add a title with the rest of the url if it exists
289 if (restOfUrl != null) {
290 sb.append("\" title=\"");
291 sb.append(restOfUrl);
292 }
293
294 if (sb.length() > 0) {
295 sb.append("\">");
296 }
297
298 sb.append(displayUrl);
299
300 if (includeHits) {
301 sb.append(" (");
302 sb.append(getDayHits());
303 sb.append(")");
304 }
305
306 if (url.startsWith("http://")) {
307 sb.append("</a>");
308 }
309
310 return sb.toString();
311 }
312
313 //-------------------------------------------------------------------------
314
315 /**
316 * @roller.wrapPojoMethod type="simple"
317 */
318 public String getUrl() {
/*
P/P * Method: String getUrl()
*
* Preconditions:
* init'ed(this.pcStateManager)
* init'ed(this.refererPermalink)
* (soft) pcInheritedFieldCount <= 232-7
* (soft) init'ed(this.refererUrl)
*
* Postconditions:
* return_value == One-of{this.refererPermalink, this.refererUrl}
* (soft) init'ed(return_value)
*
* Test Vectors:
* this.refererPermalink: Addr_Set{null}, Inverse{null}
*/
319 if (getRefererPermalink() != null) {
320 return getRefererPermalink();
321 } else {
322 return getRefererUrl();
323 }
324 }
325
326 //-------------------------------------------------------------------------
327
328 /**
329 * @roller.wrapPojoMethod type="simple"
330 */
331 public String getDisplayUrl() {
/*
P/P * Method: String getDisplayUrl()
*
* Preconditions:
* init'ed(this.pcStateManager)
* init'ed(this.refererPermalink)
* (soft) pcInheritedFieldCount <= 232-7
* (soft) init'ed(this.dayHits)
* (soft) init'ed(this.refererUrl)
*
* Postconditions:
* java.lang.StringBuffer:toString(...)._tainted == 0
* return_value == &java.lang.StringBuffer:toString(...)
*/
332 return getDisplayUrl(50, false);
333 }
334
335 //------------------------------------------------------- Good citizenship
336
337 public String toString() {
/*
P/P * Method: String toString()
*
* Preconditions:
* init'ed(this.dayHits)
* init'ed(this.id)
* init'ed(this.refererUrl)
* init'ed(this.requestUrl)
* init'ed(this.totalHits)
*
* Postconditions:
* java.lang.StringBuffer:toString(...)._tainted == this.refererUrl._tainted | this.id._tainted | this.requestUrl._tainted
* init'ed(java.lang.StringBuffer:toString(...)._tainted)
* return_value == &java.lang.StringBuffer:toString(...)
*/
338 StringBuffer buf = new StringBuffer();
339 buf.append("{");
340 buf.append(this.id);
341 buf.append(", ").append(this.requestUrl);
342 buf.append(", ").append(this.refererUrl);
343 buf.append(", ").append(this.dayHits);
344 buf.append(", ").append(this.totalHits);
345 buf.append("}");
346 return buf.toString();
347 }
348
349 public boolean equals(Object other) {
/*
P/P * Method: bool equals(Object)
*
* Preconditions:
* (soft) init'ed(other.pcStateManager)
* (soft) init'ed(other.refererUrl)
* (soft) init'ed(other.weblogEntry)
* (soft) init'ed(other.website)
* (soft) pcInheritedFieldCount <= 232-13
* (soft) init'ed(this.pcStateManager)
* (soft) init'ed(this.refererUrl)
* (soft) init'ed(this.weblogEntry)
* (soft) init'ed(this.website)
*
* Presumptions:
* org.apache.commons.lang.builder.EqualsBuilder:append(...)@353 != null
*
* Postconditions:
* init'ed(return_value)
*
* Test Vectors:
* other == this: {0}, {1}
*/
350 if (other == this) return true;
351 if (other instanceof WeblogReferrer != true) return false;
352 WeblogReferrer o = (WeblogReferrer)other;
353 return new EqualsBuilder()
354 .append(getRefererUrl(), o.getRefererUrl())
355 .append(getWeblogEntry(), o.getWeblogEntry())
356 .append(getWebsite(),o.getWebsite())
357 .isEquals();
358 }
359
360 public int hashCode() {
/*
P/P * Method: int hashCode()
*
* Preconditions:
* init'ed(this.pcStateManager)
* init'ed(this.refererUrl)
* init'ed(this.weblogEntry)
* init'ed(this.website)
* (soft) pcInheritedFieldCount <= 232-13
*
* Presumptions:
* org.apache.commons.lang.builder.HashCodeBuilder:append(...)@361 != null
*
* Postconditions:
* init'ed(return_value)
*/
361 return new HashCodeBuilder()
362 .append(getRefererUrl())
363 .append(getWeblogEntry())
364 .append(getWebsite())
365 .toHashCode();
366 }
367
368 }
+ 369 Other Messages
SofCheck Inspector Build Version : 2.18479
| WeblogReferrer.java |
2009-Jan-02 14:25:14 |
| WeblogReferrer.class |
2009-Sep-04 03:12:37 |