File Source: PingTarget.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 java.sql.Timestamp;
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 * Ping target. Each instance represents a possible target of a weblog update ping that we send. Ping targets are
30 * either common (defined centrally by an administrator and used by any website), or custom (defined by the user of a
31 * specific website) for update pings issued for that website.
32 *
33 * @author <a href="mailto:anil@busybuddha.org">Anil Gangolli</a>
34 */
35 public class PingTarget implements Serializable {
36
37 public static final long serialVersionUID = -6354583200913127874L;
38
39 public static final int CONDITION_OK = 0; // last use (after possible retrials) was successful
40 public static final int CONDITION_FAILING = 1; // last use failed after retrials
41 public static final int CONDITION_DISABLED = 2; // disabled by failure policy after failures - editing resets
42
43 private String id = UUIDGenerator.generateUUID();
44 private String name = null;
45 private String pingUrl = null;
46 private Weblog website = null;
47 private int conditionCode = -1;
48 private Timestamp lastSuccess = null;
49 private boolean autoEnabled = false;
50
51
52 /**
53 * Default empty constructor.
54 */
/*
P/P * Method: void org.apache.roller.weblogger.pojos.PingTarget()
*
* Postconditions:
* this.autoEnabled == 0
* this.conditionCode == -1
* init'ed(this.id)
* this.lastSuccess == null
* this.name == null
* this.pingUrl == null
* this.website == null
*/
55 public PingTarget() {
56 }
57
58
59 /**
60 * Constructor.
61 *
62 * @param id the id (primary key) of this target
63 * @param name the descriptive name of this target
64 * @param pingUrl the URL to which to send the ping
65 * @param website the website (on this server) for which this is a custom ping target (may be null)
66 */
/*
P/P * Method: void org.apache.roller.weblogger.pojos.PingTarget(String, String, String, Weblog, bool)
*
* Postconditions:
* this.autoEnabled == autoEnable
* init'ed(this.autoEnabled)
* this.conditionCode == 0
* init'ed(this.id)
* this.lastSuccess == null
* this.name == name
* init'ed(this.name)
* this.pingUrl == pingUrl
* init'ed(this.pingUrl)
* this.website == website
* ...
*/
67 public PingTarget(String id, String name, String pingUrl, Weblog website, boolean autoEnable) {
68 //this.id = id;
69 this.name = name;
70 this.pingUrl = pingUrl;
71 this.website = website;
72 this.conditionCode = CONDITION_OK;
73 this.lastSuccess = null;
74 this.autoEnabled = autoEnable;
75 }
76
77
78 /**
79 * Get the unique id of this ping target.
80 *
81 * @return the unique id of this ping target.
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
88 /**
89 * Set the unique id of this ping target
90 *
91 * @param id
92 */
93 public void setId(String id) {
/*
P/P * Method: void pcsetId(String)
*
* Postconditions:
* this.id == Param_1
* init'ed(this.id)
*/
94 this.id = id;
95 }
96
97
98 /**
99 * get the name of this ping target. This is a name assigned by the administrator or a user (for custom) targets.
100 * It is deescriptive and is not necessarily unique.
101 *
102 * @return the name of this ping target
103 */
104 public String getName() {
/*
P/P * Method: String pcgetName()
*
* Preconditions:
* init'ed(this.name)
*
* Postconditions:
* return_value == this.name
* init'ed(return_value)
*/
105 return this.name;
106 }
107
108
109 /**
110 * Set the name of this ping target.
111 *
112 * @param name the name of this ping target
113 */
114 public void setName(String name) {
/*
P/P * Method: void pcsetName(String)
*
* Postconditions:
* this.name == Param_1
* init'ed(this.name)
*/
115 this.name = name;
116 }
117
118
119 /**
120 * Get the URL to ping.
121 *
122 * @return the URL to ping.
123 */
124 public String getPingUrl() {
/*
P/P * Method: String pcgetPingUrl()
*
* Preconditions:
* init'ed(this.pingUrl)
*
* Postconditions:
* return_value == this.pingUrl
* init'ed(return_value)
*/
125 return pingUrl;
126 }
127
128
129 /**
130 * Set the URL to ping.
131 *
132 * @param pingUrl
133 */
134 public void setPingUrl(String pingUrl) {
/*
P/P * Method: void pcsetPingUrl(String)
*
* Postconditions:
* this.pingUrl == Param_1
* init'ed(this.pingUrl)
*/
135 this.pingUrl = pingUrl;
136 }
137
138
139 /**
140 * Get the website (on this server) for which this ping target is a custom target. This may be null, indicating
141 * that it is a common ping target, not a custom one.
142 *
143 * @return the website for which this ping target is a custom target, or null if this ping target is not a custom
144 * target.
145 */
146 public Weblog getWebsite() {
/*
P/P * Method: Weblog pcgetWebsite()
*
* Preconditions:
* init'ed(this.website)
*
* Postconditions:
* return_value == this.website
* init'ed(return_value)
*/
147 return website;
148 }
149
150
151 /**
152 * Set the website (on this server) for which this ping target is a custom target.
153 *
154 * @param website the website for which this ping target is a custom target, or null if this ping target is not a
155 * custom target
156 */
157 public void setWebsite(Weblog website) {
/*
P/P * Method: void pcsetWebsite(Weblog)
*
* Postconditions:
* this.website == Param_1
* init'ed(this.website)
*/
158 this.website = website;
159 }
160
161
162 /**
163 * Get the condition code value. This code, in combination with the last success timestamp, provides a status
164 * indicator on the ping target based on its usage by the ping queue processor. It can be used to implement a
165 * failure-based disabling policy.
166 *
167 * @return one of the condition codes {@link #CONDITION_OK}, {@link #CONDITION_FAILING}, {@link
168 * #CONDITION_DISABLED}.
169 */
170 public int getConditionCode() {
/*
P/P * Method: int pcgetConditionCode()
*
* Preconditions:
* init'ed(this.conditionCode)
*
* Postconditions:
* return_value == this.conditionCode
* init'ed(return_value)
*/
171 return conditionCode;
172 }
173
174
175 /**
176 * Set the condition code value.
177 *
178 * @param conditionCode the condition code value to set
179 */
180 public void setConditionCode(int conditionCode) {
/*
P/P * Method: void pcsetConditionCode(int)
*
* Postconditions:
* this.conditionCode == Param_1
* init'ed(this.conditionCode)
*/
181 this.conditionCode = conditionCode;
182 }
183
184
185 /**
186 * Get the timestamp of the last successful ping (UTC/GMT).
187 *
188 * @return the timestamp of the last successful ping; <code>null</code> if the target has not yet been used.
189 */
190 public Timestamp getLastSuccess() {
/*
P/P * Method: Timestamp pcgetLastSuccess()
*
* Preconditions:
* init'ed(this.lastSuccess)
*
* Postconditions:
* return_value == this.lastSuccess
* init'ed(return_value)
*/
191 return lastSuccess;
192 }
193
194
195 /**
196 * Set the timestamp of the last successful ping.
197 *
198 * @param lastSuccess the timestamp of the last successful ping.
199 */
200 public void setLastSuccess(Timestamp lastSuccess) {
/*
P/P * Method: void pcsetLastSuccess(Timestamp)
*
* Postconditions:
* this.lastSuccess == Param_1
* init'ed(this.lastSuccess)
*/
201 this.lastSuccess = lastSuccess;
202 }
203
204
205 /**
206 * Is this ping target enabled by default for new weblogs?
207 *
208 * @return true if ping target is auto enabled. false otherwise.
209 */
210 public boolean isAutoEnabled() {
/*
P/P * Method: bool pcisAutoEnabled()
*
* Preconditions:
* init'ed(this.autoEnabled)
*
* Postconditions:
* return_value == this.autoEnabled
* init'ed(return_value)
*/
211 return autoEnabled;
212 }
213
214
215 /**
216 * Set the auto enabled status for this ping target. This field only
217 * applies for common ping targets.
218 *
219 * @param autoEnabled true if the ping target should be auto enabled.
220 */
221 public void setAutoEnabled(boolean autoEnabled) {
/*
P/P * Method: void pcsetAutoEnabled(bool)
*
* Postconditions:
* this.autoEnabled == Param_1
* init'ed(this.autoEnabled)
*/
222 this.autoEnabled = autoEnabled;
223 }
224
225
226 //------------------------------------------------------- Good citizenship
227
228 public String toString() {
/*
P/P * Method: String toString()
*
* Preconditions:
* init'ed(this.autoEnabled)
* init'ed(this.id)
* init'ed(this.lastSuccess)
* init'ed(this.name)
* init'ed(this.pingUrl)
*
* Postconditions:
* java.lang.StringBuffer:toString(...)._tainted == this.pingUrl._tainted | this.id._tainted | this.name._tainted
* init'ed(java.lang.StringBuffer:toString(...)._tainted)
* return_value == &java.lang.StringBuffer:toString(...)
*/
229 StringBuffer buf = new StringBuffer();
230 buf.append("{");
231 buf.append(this.id);
232 buf.append(", ").append(this.name);
233 buf.append(", ").append(this.pingUrl);
234 buf.append(", ").append(this.lastSuccess);
235 buf.append(", ").append(this.autoEnabled);
236 buf.append("}");
237 return buf.toString();
238 }
239
240 public boolean equals(Object other) {
/*
P/P * Method: bool equals(Object)
*
* Preconditions:
* (soft) init'ed(other.id)
* (soft) init'ed(other.pcStateManager)
* (soft) pcInheritedFieldCount <= 232-3
* (soft) init'ed(this.id)
* (soft) init'ed(this.pcStateManager)
*
* Presumptions:
* org.apache.commons.lang.builder.EqualsBuilder:append(...)@244 != null
*
* Postconditions:
* init'ed(return_value)
*
* Test Vectors:
* other == this: {0}, {1}
*/
241 if (other == this) return true;
242 if (other instanceof PingTarget != true) return false;
243 PingTarget o = (PingTarget)other;
244 return new EqualsBuilder()
245 .append(getId(), o.getId())
246 .isEquals();
247 }
248
249 public int hashCode() {
/*
P/P * Method: int hashCode()
*
* Preconditions:
* init'ed(this.id)
*
* Presumptions:
* org.apache.commons.lang.builder.HashCodeBuilder:append(...)@250 != null
*
* Postconditions:
* init'ed(return_value)
*/
250 return new HashCodeBuilder()
251 .append(id)
252 .toHashCode();
253 }
254
255 }
+ 256 Other Messages
SofCheck Inspector Build Version : 2.18479
| PingTarget.java |
2009-Jan-02 14:25:16 |
| PingTarget.class |
2009-Sep-04 03:12:38 |