KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > j2biz > blogunity > pojo > VisitedPage


1 /*
2  * $Id: VisitedPage.java,v 1.2 2005/01/05 22:51:03 michelson Exp $
3  *
4  * Copyright (c) 2005 j2biz Group, http://www.j2biz.com Koeln / Duesseldorf ,
5  * Germany
6  *
7  * @author Max Kalina
8  *
9  *
10  * This program is free software; you can redistribute it and/or modify it under
11  * the terms of the GNU General Public License as published by the Free Software
12  * Foundation; either version 2 of the License, or (at your option) any later
13  * version.
14  *
15  * This program is distributed in the hope that it will be useful, but WITHOUT
16  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
18  * details.
19  *
20  * You should have received a copy of the GNU General Public License along with
21  * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
22  * Place, Suite 330, Boston, MA 02111-1307 USA
23  *
24  */

25
26 package com.j2biz.blogunity.pojo;
27
28 import java.io.Serializable JavaDoc;
29 import java.util.Date JavaDoc;
30
31 import org.apache.commons.lang.StringUtils;
32
33 /**
34  * @hibernate.class table="VISITED_PAGES" dynamic-insert = "true" dynamic-update =
35  * "true"
36  *
37  */

38 public class VisitedPage implements Serializable JavaDoc {
39
40     private static final long serialVersionUID = 3618698608842373556L;
41
42     private Long JavaDoc id;
43
44     private String JavaDoc pageUrl;
45
46     private String JavaDoc ip;
47
48     private long visitTimeInMillis;
49
50     private Blog blog;
51
52     /**
53      * <code>numberOfVisitedPages</code> is a transient property used for
54      * statistical queries.
55      */

56     private int numberOfVisitedPages;
57
58     /**
59      *
60      */

61     public VisitedPage() {
62     }
63
64     /**
65      *
66      */

67     public VisitedPage(Blog blog, String JavaDoc pageUrl, String JavaDoc ip, Date JavaDoc visitTime) {
68         this(blog, pageUrl, ip, visitTime.getTime());
69     }
70
71     public VisitedPage(Blog blog, String JavaDoc pageUrl, String JavaDoc ip, long visitTimeInMillis) {
72         this.blog = blog;
73         this.pageUrl = pageUrl;
74         this.ip = ip;
75         this.visitTimeInMillis = visitTimeInMillis;
76     }
77
78     /**
79      * This constructor is used only for statistical HQL-queries in RefererDAO.
80      *
81      * @param blog
82      * @param referer
83      * @param numberOfReferers
84      */

85     public VisitedPage(String JavaDoc pageUrl, int numberOfVisitedPages) {
86         this.pageUrl = pageUrl;
87         this.numberOfVisitedPages = numberOfVisitedPages;
88     }
89
90     /**
91      * @hibernate.id generator-class="increment" type="long" column="ID"
92      * unsaved-value="null"
93      *
94      * @return Returns the id.
95      */

96     public Long JavaDoc getId() {
97         return id;
98     }
99
100     /**
101      * @param id
102      * The id to set.
103      */

104     public void setId(Long JavaDoc id) {
105         this.id = id;
106     }
107
108     /**
109      * @hibernate.many-to-one column="BLOG_ID"
110      * class="com.j2biz.blogunity.pojo.Blog"
111      *
112      * @return
113      */

114     public Blog getBlog() {
115         return blog;
116     }
117
118     /**
119      * @param blog
120      */

121     public void setBlog(Blog blog) {
122         this.blog = blog;
123     }
124
125     /**
126      * @hibernate.property name="ip" column="IP" type="string" not-null="true"
127      * unique="false"
128      *
129      * @return
130      */

131     public String JavaDoc getIp() {
132         return ip;
133     }
134
135     /**
136      * @param ip
137      */

138     public void setIp(String JavaDoc ip) {
139         this.ip = ip;
140     }
141
142     /**
143      * @hibernate.property name="pageUrl" column="PAGE_URL" type="string"
144      * not-null="false" unique="false"
145      *
146      * @return
147      */

148     public String JavaDoc getPageUrl() {
149         return pageUrl;
150     }
151
152     /**
153      * @param pageUrl
154      */

155     public void setPageUrl(String JavaDoc pageUrl) {
156         this.pageUrl = pageUrl;
157     }
158
159     /**
160      * @hibernate.property name="visitTimeInMillis"
161      * column="VISIT_TIME_IN_MILLIS" type="long"
162      * not-null="true" unique="false"
163      *
164      * @return long
165      */

166     public long getVisitTimeInMillis() {
167         return visitTimeInMillis;
168     }
169
170     /**
171      * @param visitTimeInMillis
172      */

173     public void setVisitTimeInMillis(long visitTimeInMillis) {
174         this.visitTimeInMillis = visitTimeInMillis;
175     }
176
177     /**
178      * @return
179      */

180     public Date JavaDoc getVisitTime() {
181         return new Date JavaDoc(visitTimeInMillis);
182     }
183
184     /**
185      * @param visitTime
186      */

187     public void setVisitTime(Date JavaDoc visitTime) {
188         this.visitTimeInMillis = visitTime.getTime();
189     }
190
191     /**
192      * @return
193      */

194     public int getNumberOfVisitedPages() {
195         return numberOfVisitedPages;
196     }
197
198     /**
199      * @param numberOfVisitedPages
200      */

201     public void setNumberOfVisitedPages(int numberOfVisitedPages) {
202         this.numberOfVisitedPages = numberOfVisitedPages;
203     }
204
205     public String JavaDoc toString() {
206         return "<a HREF=\"" + pageUrl + "\" title=\"" + pageUrl + "\">"
207                 + StringUtils.abbreviate(pageUrl, 25) + " (" + numberOfVisitedPages + ")</a>";
208     }
209 }
Popular Tags