|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectewe.database.Synchronizer
This class provides utilities for synchronizing items in a mobile database with another. The methods in here only support synchronization with a single other database, you will have to implement more complex methods to support any other type of synchronization.
| Field Summary | |
static int |
ALWAYS
|
static int |
CANCELLED
|
boolean |
dontSynchronizeDeletedItems
If this is true, then deleting an item on one database will not cause the item to be deleted in the other. |
boolean |
dontSyncJustDebug
This goes through the motion of synchronization but does not actually make any changes to either database. |
protected int |
lastConflictCommand
|
static int |
LOCAL_TO_REMOTE
|
static int |
REMOTE_TO_LOCAL
|
boolean |
remoteToLocalOnly
If this is true then the local database will take entries from remote database but not vice versa. |
static int |
RESOLVE_LATER
|
Time |
syncTime
|
| Constructor Summary | |
Synchronizer(Database database)
|
|
| Method Summary | |
static void |
addOrReplace(DatabaseEntry entry,
FoundEntries myEntriesSortedByOID)
Given a remote entry, add or replace it in this database. |
protected static int |
checkSort(Database database,
String sortName)
|
void |
close()
This is called at the end of the syncrhonization. |
int |
countRemoteDeletedEntries()
|
int |
countRemoteUnsynchronizedEntries()
|
void |
erase(long oid,
FoundEntries myEntriesSortedByOID)
Given the OID of an entry in the remote database, erase it completely from this database. |
void |
eraseDeleted(long oid)
This is called after an OID marked as deleted on this database has been erased from the remote database. |
void |
eraseDeletedOnRemote(int index)
|
void |
eraseEntryOnRemote(long OID)
|
static int |
findByOID(FoundEntries entries,
long oid)
This locates the entry with the specified OID. |
FoundEntries |
getByOID(Handle h)
|
static FoundEntries |
getByOID(Handle h,
Database database)
|
protected String |
getDisplayString(DatabaseEntry entry)
|
static int |
getMatchingEntry(DatabaseEntry remoteEntry,
FoundEntries myEntriesSortedByOID)
|
static long |
getOID(DatabaseEntry entry)
Get the OID for an entry. |
long |
getRemoteDeletedEntry(int index)
|
byte[] |
getRemoteUnsynchronizedEntry(int index)
|
protected String |
getResolveString(DatabaseEntry remote,
DatabaseEntry local)
|
EntriesView |
getUnsynchronized(Handle h)
This gets all the unsynchronized entries, but not the deleted entries. |
static EntriesView |
getUnsynchronized(Handle h,
Database database)
|
boolean |
isSynchronized(DatabaseEntry entry)
Returns the state of the synchronized flag. |
static void |
markAsSynchronized(DatabaseEntry entry)
|
static void |
markAsSynchronized(EntriesView entries,
int index)
This marks the entry at the specified index as being synchronized. |
void |
markRemoteAsSynchronized(int index)
|
int |
resolveConflict(DatabaseEntry remote,
DatabaseEntry local)
This must resolve a conflict when an item has been modified on both databases. |
void |
sendEntryToRemote(DatabaseEntry de)
|
Handle |
synchronize()
|
boolean |
synchronize(Handle progress)
|
Handle |
synchronize(String title)
Start the synchronization and display an optional progress bar. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, toString |
| Field Detail |
public Time syncTime
protected int lastConflictCommand
public static final int REMOTE_TO_LOCAL
public static final int LOCAL_TO_REMOTE
public static final int RESOLVE_LATER
public static final int ALWAYS
public static final int CANCELLED
public boolean remoteToLocalOnly
public boolean dontSynchronizeDeletedItems
public boolean dontSyncJustDebug
| Constructor Detail |
public Synchronizer(Database database)
| Method Detail |
protected static int checkSort(Database database,
String sortName)
throws IllegalStateException
IllegalStateException
public static EntriesView getUnsynchronized(Handle h,
Database database)
throws IOException,
IllegalStateException
IOException
IllegalStateException
public EntriesView getUnsynchronized(Handle h)
throws IOException,
IllegalStateException
IOException
IllegalStateException - If the database does not have the "_SortBySync" sortpublic static void markAsSynchronized(DatabaseEntry entry)
public static void markAsSynchronized(EntriesView entries,
int index)
throws IOException
IOException
public static FoundEntries getByOID(Handle h,
Database database)
throws IOException,
IllegalStateException
IOException
IllegalStateException
public FoundEntries getByOID(Handle h)
throws IOException,
IllegalStateException
IOException
IllegalStateException
public static int findByOID(FoundEntries entries,
long oid)
throws IOException
entries - The FoundEntries of all the entries.oid - The oid looking for.
IOException
public static long getOID(DatabaseEntry entry)
throws IllegalStateException
entry - The entry to look for.
IllegalStateException - if the entry does not have an OID assigned.
public boolean isSynchronized(DatabaseEntry entry)
throws IllegalStateException
entry - The entry to check.
IllegalStateException - If synchronization data is not set in the entry.
public static int getMatchingEntry(DatabaseEntry remoteEntry,
FoundEntries myEntriesSortedByOID)
throws IOException,
IllegalStateException
IOException
IllegalStateException
public static void addOrReplace(DatabaseEntry entry,
FoundEntries myEntriesSortedByOID)
throws IOException,
IllegalStateException
IOException
IllegalStateException
public void eraseDeleted(long oid)
throws IOException
oid - The oid to erase.
IOException
public void erase(long oid,
FoundEntries myEntriesSortedByOID)
throws IOException
IOException
public int countRemoteUnsynchronizedEntries()
throws IOException
IOException
public int countRemoteDeletedEntries()
throws IOException
IOException
public long getRemoteDeletedEntry(int index)
throws IOException
IOException
public void eraseDeletedOnRemote(int index)
throws IOException
IOException
public void eraseEntryOnRemote(long OID)
throws IOException
IOException
public byte[] getRemoteUnsynchronizedEntry(int index)
throws IOException
IOException
public void markRemoteAsSynchronized(int index)
throws IOException
IOException
public void sendEntryToRemote(DatabaseEntry de)
throws IOException
IOExceptionprotected String getDisplayString(DatabaseEntry entry)
protected String getResolveString(DatabaseEntry remote,
DatabaseEntry local)
public int resolveConflict(DatabaseEntry remote,
DatabaseEntry local)
remote - The remote entry.local - The local entry.
public void close()
public Handle synchronize()
public Handle synchronize(String title)
title - if this is non-null a progress bar display will be shown.
public boolean synchronize(Handle progress)
throws IOException
IOException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||