KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > sync4j > framework > server > LastTimestamp


1 /**
2  * Copyright (C) 2003-2005 Funambol
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  */

18
19 package sync4j.framework.server;
20
21 import org.apache.commons.lang.builder.ToStringBuilder;
22
23 import sync4j.framework.server.SyncTimestamp;
24
25
26 /**
27  * This class specializes a <i>SyncTimestamp</i> to represent a last sync
28  * timestamp as retrieved from the database. It associates a sync timestamp with
29  * a particular principal and database.
30  *
31  * @author Stefano Fornari @ Funambol
32  * @version $Id: LastTimestamp.java,v 1.7 2005/03/02 20:57:38 harrie Exp $
33  */

34 public class LastTimestamp extends SyncTimestamp {
35     
36     // ------------------------------------------------------------- Public data
37

38     public String JavaDoc principal = null; // the id of the principal
39
public String JavaDoc database = null;
40     
41     // ------------------------------------------------------------ Constructors
42

43     /** Creates a new instance of LastTimestamp */
44     public LastTimestamp(final String JavaDoc principal, final String JavaDoc database) {
45         super();
46         this.principal = principal ;
47         this.database = database ;
48     }
49     
50     /**
51      * Creates a new instance of LastTimestamp.
52      * It is need to cache the next anchor of the server and the next anchor
53      * of the client.
54      *
55      * @param principal the principal id
56      * @param database the source for sync
57      * @param tagServer the last/next tag of the server
58      * @param tagClient the last/next tag of the client
59      * @param start the timestamp of when sync started
60      * @param end the timestamo of when sync ended
61      *
62      */

63     public LastTimestamp(final String JavaDoc principal,
64                          final String JavaDoc database,
65                          final String JavaDoc tagServer,
66                          final String JavaDoc tagClient,
67                          final long start,
68                          final long end) {
69         this(principal, database);
70         this.tagServer = tagServer;
71         this.tagClient = tagClient;
72         this.start = start ;
73         this.end = end ;
74     }
75     
76     // ---------------------------------------------------------- Public methods
77

78     public String JavaDoc toString() {
79         ToStringBuilder sb = new ToStringBuilder(this);
80         
81         sb.append("principal", principal).
82            append("database" , database).
83            append("tagServer", tagServer).
84            append("tagClient", tagClient).
85            append("start" , new java.sql.Timestamp JavaDoc(start)).
86            append("end" , new java.sql.Timestamp JavaDoc(end) );
87         
88         return sb.toString();
89     }
90 }
Popular Tags