00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
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
00058 public DefaultSynchroAtomicObject(String id, String sum) {
00059 this(id, sum, 0, SynchroAtomicObject.ADD, 0);
00060 }
00061
00062 public DefaultSynchroAtomicObject(String id, long syncnumber) {
00063 this(id, "", syncnumber, SynchroAtomicObject.ADD, 0);
00064 }
00065
00066 public DefaultSynchroAtomicObject(String id, String sum, long syncnumber) {
00067 this(id, sum, syncnumber, SynchroAtomicObject.ADD, 0);
00068 }
00069
00070 public long getCreationDate() {
00071 return creationDate;
00072 }
00073
00074 public String getUID() {
00075 return uid;
00076 }
00077
00078 public String getCheckSum() {
00079 return checksum;
00080 }
00081 public void setCheckSum(String sum) {
00082 checksum = sum;
00083 }
00084
00085 public long getModifSyncNumber() {
00086 return syncnumber;
00087 }
00088 public void setModifSyncNumber(long ts) {
00089 syncnumber = ts;
00090 }
00091
00092 public short getModificationType() {
00093 return modificationType;
00094 }
00095
00096 public void setModificationType(short type) throws DatabaseException {
00097 if (this.syncnumber == 0) this.syncnumber = SyncNumberManager.getManager().getNextSynchroNumber().getSynchroNumber();
00098 modificationType = type;
00099 }
00100
00101 public boolean equals(Object obj) {
00102 if (obj instanceof SynchroAtomicObject) {
00103 if(((SynchroAtomicObject)obj).getUID().equals(uid)) {
00104 return true;
00105 }
00106 }
00107 return false;
00108 }
00109
00110 public int hashCode() {
00111 return uid.hashCode();
00112 }
00113 }