DefaultSynchroAtomicObject.java

00001 /*
00002  * OpenMobileIS - a free Java(TM) Framework for mobile applications Java(TM)
00003  * Copyright (C) 2004-2006 Philippe Delrieu
00004  * All rights reserved.
00005  * Contact: pdelrieu@openmobileis.org
00006  *
00007  * This library is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Lesser General Public
00009  * License as published by the Free Software Foundation; either
00010  * version 2.1 of the License, or any later version.
00011  *
00012  * This library is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * Lesser General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public
00018  * License along with this library; if not, write to the Free Software
00019  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
00020  * USA
00021  *
00022  *  
00023  *  Modifications :
00024  *  2006 Creation P.Delrieu
00025  * 
00026  */
00027 
00028 package org.openmobileis.synchro.algo.replication.utils;
00029 
00030 import org.openmobileis.common.util.exception.DatabaseException;
00031 import org.openmobileis.synchro.algo.replication.SynchroAtomicObject;
00032 import org.openmobileis.synchro.algo.syncnumber.SyncNumberManager;
00033 
00041 public class DefaultSynchroAtomicObject implements SynchroAtomicObject {
00042   static final long serialVersionUID = 5521257935120563452L;
00043 
00044   private String uid;
00045   private String checksum;
00046   private long syncnumber;
00047   private short modificationType;
00048   private long creationDate;
00049 
00050   public DefaultSynchroAtomicObject(String id, String sum, long syncnumber, short type, long creationdate) {
00051     uid = id;
00052     checksum=sum;
00053     this.syncnumber=syncnumber;
00054     modificationType = type;
00055     creationDate = creationdate;
00056   }
00057   public DefaultSynchroAtomicObject(String id, String sum) {
00058     uid = id;
00059     checksum=sum;
00060     syncnumber=0;
00061     creationDate = 0;
00062     modificationType = SynchroAtomicObject.ADD;
00063   }
00064 
00065   public long getCreationDate() {
00066     return creationDate;
00067   }
00068 
00069   public String getUID() {
00070     return uid;
00071   }
00072 
00073   public String getCheckSum() {
00074     return checksum;
00075   }
00076   public void setCheckSum(String sum) {
00077     checksum = sum;
00078   }
00079 
00080   public long getModifSyncNumber() {
00081     return syncnumber;
00082   }
00083   public void setModifSyncNumber(long ts)  {
00084     syncnumber = ts;
00085   }
00086 
00087   public short getModificationType() {
00088     return modificationType;
00089   }
00090 
00091   public void setModificationType(short type) throws DatabaseException {
00092     this.syncnumber = SyncNumberManager.getManager().getNextSynchroNumber().getSynchroNumber();
00093     modificationType = type;
00094   }
00095 
00096   public boolean equals(Object obj) {
00097     if (obj instanceof SynchroAtomicObject) {
00098       if(((SynchroAtomicObject)obj).getUID().equals(uid)) {
00099         return true;
00100       }
00101     }
00102     return false;
00103   }
00104 
00105   public int hashCode() {
00106     return uid.hashCode();
00107   }
00108 }

Generated on Mon Dec 4 11:03:25 2006 for OpenMobileIS by  doxygen 1.5.1-p1