KickJava   Java API By Example, From Geeks To Geeks.

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


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
24 /**
25  * Represents a synchronization timestamp for a particular database and principal.
26  * <i>tag</i> stores the next (when used as a next timestamp) or the last (when
27  * used as a last timstamp) value as it appears in <i>SyncAnchor</i>.
28  *
29  * @author Stefano Fornari @ Funambol
30  * @version $Id: SyncTimestamp.java,v 1.5 2005/03/02 20:57:38 harrie Exp $
31  */

32 public class SyncTimestamp {
33     
34     // ------------------------------------------------------------- Public data
35

36     public long start = -1 ; // timestamp of when sync started
37
public long end = -1 ; // timestamp of when sync ended
38
public String JavaDoc tagServer = null; // the last/next tag of the server
39
public String JavaDoc tagClient = null; // the last/next tag of the client
40

41     // ------------------------------------------------------------ Constructors
42

43     /** Creates a new instance of LastTimestamp */
44     public SyncTimestamp() { }
45     
46     /**
47      * Creates a new instance of LastTimestamp when the only starting timestamp
48      * is known. <i>end</i> is set to -1 and tag is set to the string value
49      * of the start.
50      *
51      * @param start the starting timestamp
52      */

53     public SyncTimestamp(final long start) {
54         this(String.valueOf(start), String.valueOf(start), start, -1);
55     }
56     
57     /**
58      * Creates a new instance of LastTimestamp.
59      * It is need to cache the next anchor of the server and the next anchor
60      * of the client.
61      *
62      * @param tagServer the last/next tag of the server
63      * @param tagClient the last/next tag of the client
64      * @param start the timestamp of when sync started
65      * @param end the timestamo of when sync ended
66      *
67      */

68     public SyncTimestamp(final String JavaDoc tagServer,
69                          final String JavaDoc tagClient,
70                          final long start ,
71                          final long end ) {
72         this.tagServer = tagServer;
73         this.tagClient = tagClient;
74         this.start = start ;
75         this.end = end ;
76     }
77     
78     // ---------------------------------------------------------- Public methods
79

80     public String JavaDoc toString() {
81         ToStringBuilder sb = new ToStringBuilder(this);
82         
83         sb.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         return sb.toString();
88     }
89 }
90
Popular Tags