KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * Copyright (c) 2005
3  * Anil R. Gangolli. All rights reserved.
4  *
5  * Distributed with the Roller Weblogger Project under the terms of the Roller Software
6  * License
7  */

8
9 package org.roller.pojos;
10
11 import java.sql.Timestamp JavaDoc;
12 import java.io.Serializable JavaDoc;
13
14 /**
15  * Ping queue entry. Each instance of this class represents an entry on the ping queue. The entry indicates when it was
16  * added to the queue, which configuration to apply for the ping, and the number of ping attempts that have been made
17  * for this entry so far.
18  *
19  * @author Anil Gangolli anil@busybuddha.org
20  * @ejb:bean name="PingQueueEntryData"
21  * @hibernate.class table="pingqueueentry"
22  */

23 public class PingQueueEntryData extends PersistentObject implements Serializable JavaDoc
24 {
25     String JavaDoc id;
26     Timestamp JavaDoc entryTime;
27     PingTargetData pingTarget;
28     WebsiteData website;
29     int attempts;
30
31     static final long serialVersionUID = -1468021030819538243L;
32
33     /**
34      * Default constructor. Leaves all fields at Java-specified default values.
35      */

36     public PingQueueEntryData()
37     {
38     }
39
40     /**
41      * Construct with all members
42      *
43      * @param id unique id of this entry
44      * @param entryTime timestamp of first entry onto queue
45      * @param pingTarget target site to ping
46      * @param website website originating the ping
47      * @param attempts number of prior ping attempts
48      */

49     public PingQueueEntryData(String JavaDoc id, Timestamp JavaDoc entryTime, PingTargetData pingTarget, WebsiteData website, int attempts)
50     {
51         this.id = id;
52         this.entryTime = entryTime;
53         this.pingTarget = pingTarget;
54         this.website = website;
55         this.attempts = attempts;
56     }
57
58     /**
59      * @see PersistentObject#setData(PersistentObject)
60      */

61     public void setData(PersistentObject vo)
62     {
63         PingQueueEntryData other = (PingQueueEntryData) vo;
64         id = other.id;
65         entryTime = other.entryTime;
66         pingTarget = other.pingTarget;
67         website = other.website;
68         attempts = other.attempts;
69     }
70
71     /**
72      * Get the unique id (primary key) of this object.
73      *
74      * @return the unique id of this object.
75      * @ejb:persistent-field
76      * @hibernate.id column="id" type="string" generator-class="uuid.hex" unsaved-value="null"
77      */

78     public String JavaDoc getId()
79     {
80         return id;
81     }
82
83     /**
84      * Set the unique id (primary key) of this object.
85      *
86      * @param id
87      * @ejb:persistent-field
88      */

89     public void setId(String JavaDoc id)
90     {
91         this.id = id;
92     }
93
94     /**
95      * Get the entry time. Get the time this entry was first added to the queue.
96      *
97      * @return the time the entry was first added to the queue.
98      * @ejb:persistent-field
99      * @hibernate.property column="entrytime" non-null="true"
100      */

101     public Timestamp JavaDoc getEntryTime()
102     {
103         return entryTime;
104     }
105
106     /**
107      * Set the entry time.
108      *
109      * @param entryTime the time the entry was first added to the queue.
110      * @ejb:persistent-field
111      */

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

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

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

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

158     public void setWebsite(WebsiteData website)
159     {
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     {
172         return attempts;
173     }
174
175     /**
176      * Set the number of failures that have occurred for this queue entry.
177      *
178      * @param attempts
179      * @ejb:persistent-field
180      */

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

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

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

218     public int hashCode()
219     {
220         return (id != null ? id.hashCode() : 0);
221     }
222
223     /**
224      * Generate a string form of the object appropriate for logging or debugging.
225      * @return a string form of the object appropriate for logging or debugging.
226      * @see java.lang.Object#toString()
227      */

228     public String JavaDoc toString()
229     {
230         return "PingQueueEntryData{" +
231             "id='" + id + "'" +
232             ", entryTime=" + entryTime +
233             ", pingTarget=" + pingTarget +
234             ", website= " + (website == null ? "null" : "{id='" + website.getId() + "', user='" + website.getUser().getUserName() + "'} ") +
235             ", attempts=" + attempts +
236             "}";
237     }
238 }
239
Popular Tags