org.jSyncManager.API.Protocol.Util

Class DLPDatabaseSet


public class DLPDatabaseSet
extends java.lang.Object

A class for the storage and halndling of multiple DLPDatabase objects. This class holds several databases, and allows for their manipulation, including serialization and deserialization as a set. This class does not represent any structure on the handheld. It is a utility class designed to make it easier to store and query databases.

Constructor Summary

DLPDatabaseSet()
Create a new empty database set object.
DLPDatabaseSet(String filename)
Create a new database set object based on the provided serialization directory.

Method Summary

void
addDatabase(DLPDatabase db)
Add the specified database to the set.
int
databaseCount()
Return the number of databases in this set.
DLPDatabase
getDatabase(String s)
Gets the database specified by name.
DLPDatabase
getDatabase(int i)
Retreives the specified database.
DLPDatabaseInfo
getDatabaseInfo(String s)
Gets the database info object for the database with the specified name.
DLPDatabaseInfo
getDatabaseInfo(int dbNum)
Gets the database info object from the specified index.
boolean
hasDatabase(String s)
Checks to see if this set contains the specified database.
boolean
isModified()
Tests to see if this set has been modified.
void
removeDatabase(String s)
Removes the database with the specified name from this set.
void
removeDatabase(int i)
Removes the database at the specified index from this set.
void
writeToFile(String directory)
Write this database set to the specified directory.

Constructor Details

DLPDatabaseSet

public DLPDatabaseSet()
Create a new empty database set object.

DLPDatabaseSet

public DLPDatabaseSet(String filename)
            throws Exception
Create a new database set object based on the provided serialization directory.
Parameters:
filename - the directory contanining the serialized database information.

Method Details

addDatabase

public void addDatabase(DLPDatabase db)
Add the specified database to the set.
Parameters:
db - the database to be added to the set.

databaseCount

public int databaseCount()
Return the number of databases in this set.
Returns:
the number of databases in this set.

getDatabase

public DLPDatabase getDatabase(String s)
Gets the database specified by name. If this database isn't currently present in memory, it will first be loaded from storage.
Parameters:
s - the name of the database to retreive.
Returns:
the DLPDatabase object requested.

getDatabase

public DLPDatabase getDatabase(int i)
Retreives the specified database. If the database hasn't been loaded yet, it will be loaded and deserialized first.
Parameters:
i - the database index to be retreived.
Returns:
the DLPDatabase object from the requested index.

getDatabaseInfo

public DLPDatabaseInfo getDatabaseInfo(String s)
Gets the database info object for the database with the specified name.
Parameters:
s - the name of the database to retrieve the info object for.
Returns:
the database info object from the specified database.

getDatabaseInfo

public DLPDatabaseInfo getDatabaseInfo(int dbNum)
Gets the database info object from the specified index.
Parameters:
dbNum - the index of the db info object to retrieve.
Returns:
the database info object from the specified index.

hasDatabase

public boolean hasDatabase(String s)
Checks to see if this set contains the specified database.
Parameters:
s - the name of the database to check for.
Returns:
true if the database is in this set, false otherwise.

isModified

public boolean isModified()
Tests to see if this set has been modified.
Returns:
true if this set has been modified, false otherwise.

removeDatabase

public void removeDatabase(String s)
Removes the database with the specified name from this set.
Parameters:
s - the name of the database to remove.

removeDatabase

public void removeDatabase(int i)
Removes the database at the specified index from this set.
Parameters:
i - the index of the database to remove.

writeToFile

public void writeToFile(String directory)
            throws IOException
Write this database set to the specified directory. If the specified directory doesn't exist, this method will attempt to create it first.
Parameters:
directory - the fully qualified path of the directory to write tha databes set to.