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 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 }