jSyncManager

org.jSyncManager.API.Protocol.Util
Class DLPDatabaseSet

java.lang.Object
  |
  +--org.jSyncManager.API.Protocol.Util.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.

Version:
$Revision: 1.6 $
Author:
Brad BARCLAY <bbarclay@jsyncmanager.org>
Last modified by: $Author: yaztromo $ on $Date: 2003/05/13 07:13:11 $.

Constructor Summary
DLPDatabaseSet()
          Create a new empty database set object.
DLPDatabaseSet(java.lang.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(int i)
          Retreives the specified database.
 DLPDatabase getDatabase(java.lang.String s)
          Gets the database specified by name.
 DLPDatabaseInfo getDatabaseInfo(int dbNum)
          Gets the database info object from the specified index.
 DLPDatabaseInfo getDatabaseInfo(java.lang.String s)
          Gets the database info object for the database with the specified name.
 boolean hasDatabase(java.lang.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(int i)
          Removes the database at the specified index from this set.
 void removeDatabase(java.lang.String s)
          Removes the database with the specified name from this set.
 void writeToFile(java.lang.String directory)
          Write this database set to the specified directory.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DLPDatabaseSet

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

DLPDatabaseSet

public DLPDatabaseSet(java.lang.String filename)
               throws java.lang.Exception
Create a new database set object based on the provided serialization directory.
Parameters:
filename - the directory contanining the serialized database information.
Throws:
java.lang.Exception - thrown if any exceptions are encountered.
Method Detail

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(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.

getDatabase

public DLPDatabase getDatabase(java.lang.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.

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.

getDatabaseInfo

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

hasDatabase

public boolean hasDatabase(java.lang.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(int i)
Removes the database at the specified index from this set.
Parameters:
i - the index of the database to remove.

removeDatabase

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

writeToFile

public void writeToFile(java.lang.String directory)
                 throws java.io.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.
Throws:
java.io.IOException - if any exceptions occur during write.

jSyncManager

Copyright (c) 1999 - 2003 Brad BARCLAY and others. All Rights Reserved.