KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > roller > pojos > PingQueueEntryData


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.pojos;
20
21 import java.io.Serializable JavaDoc;
22 import java.sql.Timestamp JavaDoc;
23
24 /**
25  * Ping queue entry. Each instance of this class represents an entry on the ping queue. The entry indicates when it was
26  * added to the queue, which configuration to apply for the ping, and the number of ping attempts that have been made
27  * for this entry so far.
28  *
29  * @author <a HREF="mailto:anil@busybuddha.org">Anil Gangolli</a>
30  * @ejb:bean name="PingQueueEntryData"
31  * @hibernate.class lazy="false" table="pingqueueentry"
32  * @hibernate.cache usage="read-write"
33  */

34 public class PingQueueEntryData extends PersistentObject implements Serializable JavaDoc {
35     private String JavaDoc id = null;
36     private Timestamp JavaDoc entryTime = null;
37     private PingTargetData pingTarget = null;
38     private WebsiteData website = null;
39     private int attempts = 0;
40
41     public static final long serialVersionUID = -1468021030819538243L;
42
43     /**
44      * Default constructor. Leaves all fields at Java-specified default values.
45      */

46     public PingQueueEntryData() {
47     }
48
49     /**
50      * Construct with all members
51      *
52      * @param id unique id of this entry
53      * @param entryTime timestamp of first entry onto queue
54      * @param pingTarget target site to ping
55      * @param website website originating the ping
56      * @param attempts number of prior ping attempts
57      */

58     public PingQueueEntryData(String JavaDoc id, Timestamp JavaDoc entryTime, PingTargetData pingTarget, WebsiteData website, int attempts) {
59         this.id = id;
60         this.entryTime = entryTime;
61         this.pingTarget = pingTarget;
62         this.website = website;
63         this.attempts = attempts;
64     }
65
66     /**
67      * @see PersistentObject#setData(PersistentObject)
68      */

69     public void setData(PersistentObject vo) {
70         PingQueueEntryData other = (PingQueueEntryData) vo;
71
72         id = other.getId();
73         entryTime = other.getEntryTime();
74         pingTarget = other.getPingTarget();
75         website = other.getWebsite();
76         attempts = other.getAttempts();
77     }
78
79     /**
80      * Get the unique id (primary key) of this object.
81      *
82      * @return the unique id of this object.
83      * @ejb:persistent-field
84      * @hibernate.id column="id" generator-class="uuid.hex" unsaved-value="null"
85      */

86     public String JavaDoc getId() {
87         return id;
88     }
89
90     /**
91      * Set the unique id (primary key) of this object.
92      *
93      * @param id
94      * @ejb:persistent-field
95      */

96     public void setId(String JavaDoc id) {
97         this.id = id;
98     }
99
100     /**
101      * Get the entry time. Get the time this entry was first added to the queue.
102      *
103      * @return the time the entry was first added to the queue.
104      * @ejb:persistent-field
105      * @hibernate.property column="entrytime" non-null="true"
106      */

107     public Timestamp JavaDoc getEntryTime() {
108         return entryTime;
109     }
110
111     /**
112      * Set the entry time.
113      *
114      * @param entryTime the time the entry was first added to the queue.
115      * @ejb:persistent-field
116      */

117     public void setEntryTime(Timestamp JavaDoc entryTime) {
118         this.entryTime = entryTime;
119     }
120
121     /**
122      * Get the ping target. Get the target to ping.
123      *
124      * @return the ping target to ping.
125      * @ejb:persistent-field
126      * @hibernate.many-to-one column="pingtargetid" cascade="none" not-null="true"
127      */

128     public PingTargetData getPingTarget() {
129         return pingTarget;
130     }
131
132     /**
133      * Set the ping target.
134      *
135      * @param pingTarget target to ping.
136      * @ejb:persistent-field
137      */

138     public void setPingTarget(PingTargetData pingTarget) {
139         this.pingTarget = pingTarget;
140     }
141
142     /**
143      * Get the website originating the ping.
144      *
145      * @return the website originating the ping.
146      * @ejb:persistent-field
147      * @hibernate.many-to-one column="websiteid" cascade="none" not-null="true"
148      */

149     public WebsiteData getWebsite() {
150         return website;
151     }
152
153     /**
154      * Set the website originating the ping.
155      *
156      * @param website the website originating the ping.
157      * @ejb:persistent-field
158      */

159     public void setWebsite(WebsiteData website) {
160         this.website = website;
161     }
162
163     /**
164      * Get the number of ping attempts that have been made for this queue entry.
165      *
166      * @return the number of ping attempts that have been made for this queue entry.
167      * @ejb:persistent-field
168      * @hibernate.property column="attempts" non-null="true"
169      */

170     public int getAttempts() {
171         return attempts;
172     }
173
174     /**
175      * Set the number of failures that have occurred for this queue entry.
176      *
177      * @param attempts
178      * @ejb:persistent-field
179      */

180     public void setAttempts(int attempts) {
181         this.attempts = attempts;
182     }
183
184     /**
185      * Increment the number of failures for this queue entry.
186      *
187      * @return the new value.
188      */

189     public int incrementAttempts() {
190         return ++attempts;
191     }
192
193     /**
194      * @see Object#equals(Object o)
195      */

196     public boolean equals(Object JavaDoc o) {
197         if (this == o) return true;
198         if (!(o instanceof PingQueueEntryData)) return false;
199
200         final PingQueueEntryData pingQueueEntryData = (PingQueueEntryData) o;
201
202         if (attempts != pingQueueEntryData.getAttempts()) return false;
203         if (entryTime != null ? !entryTime.equals(pingQueueEntryData.getEntryTime()) : pingQueueEntryData.getEntryTime() != null)
204         {
205             return false;
206         }
207         if (id != null ? !id.equals(pingQueueEntryData.getId()) : pingQueueEntryData.getId() != null) return false;
208         if (pingTarget != null ? !pingTarget.equals(pingQueueEntryData.getPingTarget()) : pingQueueEntryData.getPingTarget() != null)
209         {
210             return false;
211         }
212         if (website != null ? !website.equals(pingQueueEntryData.getWebsite()) : pingQueueEntryData.getWebsite() != null)
213         {
214             return false;
215         }
216
217         return true;
218     }
219
220     /**
221      * @see Object#hashCode()
222      */

223     public int hashCode() {
224         return (id != null ? id.hashCode() : 0);
225     }
226
227     /**
228      * Generate a string form of the object appropriate for logging or debugging.
229      *
230      * @return a string form of the object appropriate for logging or debugging.
231      * @see Object#toString()
232      */

233     public String JavaDoc toString() {
234         return "PingQueueEntryData{" + "id='" + id + "'" + ", entryTime=" + entryTime + ", pingTarget=" + pingTarget + ", website= " + (website == null ? "null" : "{id='" + website.getId() + "'} ") + ", attempts=" + attempts + "}";
235     }
236 }
237
Popular Tags