ewe.database
Class DatabaseManager

java.lang.Object
  extended byewe.database.DatabaseManager

public class DatabaseManager
extends Object


Constructor Summary
DatabaseManager()
           
 
Method Summary
static void closeLog(PrintWriter log)
           
static boolean databaseExists(DatabaseMaker maker, String name)
           
static boolean databaseIsValid(DatabaseMaker maker, String name)
           
static DatabaseMaker getDefaultDatabaseMaker()
           
static String getVersion()
           
static Database initializeDatabase(DatabaseMaker maker, String name, Object initializer)
          This is used to initialize a database if it has not yet been initialized.
static Database initializeDatabase(DatabaseMaker maker, String name, Object initializer, DataProcessor decryptor, DataProcessor encryptor)
          This is used to initialize a database if it has not yet been initialized.
static boolean logError(String toLog)
           
static Database openDatabase(DatabaseMaker maker, String name, String mode)
          Open a Database given the database name.
static Database openDatabase(DatabaseMaker maker, String name, String mode, Object initializer)
          Open a Database given the database name.
static Database openDatabase(DatabaseMaker maker, String name, String mode, Object initializer, DataProcessor decryptor, DataProcessor encryptor)
          Open a Database given the database name.
static PrintWriter openLog()
           
static void setDefaultDatabaseMaker(DatabaseMaker maker)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, toString
 

Constructor Detail

DatabaseManager

public DatabaseManager()
Method Detail

getVersion

public static String getVersion()

openLog

public static PrintWriter openLog()
                           throws IOException
Throws:
IOException

closeLog

public static void closeLog(PrintWriter log)
                     throws IOException
Throws:
IOException

logError

public static boolean logError(String toLog)

getDefaultDatabaseMaker

public static DatabaseMaker getDefaultDatabaseMaker()

setDefaultDatabaseMaker

public static void setDefaultDatabaseMaker(DatabaseMaker maker)

openDatabase

public static Database openDatabase(DatabaseMaker maker,
                                    String name,
                                    String mode,
                                    Object initializer,
                                    DataProcessor decryptor,
                                    DataProcessor encryptor)
                             throws IOException,
                                    IllegalArgumentException
Open a Database given the database name. This method assumes that a single database exists within a single stored entity on the device - which is the most portable assumption to make. On systems that support a file system (e.g. Win32/WinCE/Linux) the stored entity will be a DataStorage formatted file with a DataTable stored in it. On systems that do not (e.g. PalmOS) the stored entity will be a standard Palm database file (".pdb" file).

Parameters:
name - A name for the database. Avoid using fully qualified paths and extensions. On simple OSes like the PalmOS, the database name will be mapped to the appropriate database on the device. On devices with a file system a ".dat" extension will be added (if it is not already present in the name) and the file will be searched for as a file or resource.
mode - A string that should be "r" or "rw".
initializer - An optional object that can be used to initialize the fields and sorts of the database, if the database is being opened and created for the first time. If it is null then no initialization of a new database is done.
decryptor - An optional decryptor used to decode the database if it is encrypted.
encryptor - An optional encryptor used to encoded the database - used only when writing.
Returns:
An open Database object.
Throws:
IOException - If there is an error opening the file.
IllegalArgumentException

openDatabase

public static Database openDatabase(DatabaseMaker maker,
                                    String name,
                                    String mode)
                             throws IOException,
                                    IllegalArgumentException
Open a Database given the database name. This method assumes that a single database exists within a single stored entity on the device - which is the most portable assumption to make. On systems that support a file system (e.g. Win32/WinCE/Linux) the stored entity will be a DataStorage formatted file with a DataTable stored in it. On systems that do not (e.g. PalmOS) the stored entity will be a standard Palm database file (".pdb" file).

Parameters:
name - A name for the database. Avoid using fully qualified paths and extensions. On simple OSes like the PalmOS, the database name will be mapped to the appropriate database on the device. On devices with a file system a ".dat" extension will be added (if it is not already present in the name) and the file will be searched for as a file or resource.
mode - A string that should be "r" or "rw".
Returns:
An open Database object.
Throws:
IOException - If there is an error opening the file.
IllegalArgumentException

openDatabase

public static Database openDatabase(DatabaseMaker maker,
                                    String name,
                                    String mode,
                                    Object initializer)
                             throws IOException,
                                    IllegalArgumentException
Open a Database given the database name. This method assumes that a single database exists within a single stored entity on the device - which is the most portable assumption to make. On systems that support a file system (e.g. Win32/WinCE/Linux) the stored entity will be a DataStorage formatted file with a DataTable stored in it. On systems that do not (e.g. PalmOS) the stored entity will be a standard Palm database file (".pdb" file).

Parameters:
name - A name for the database. Avoid using fully qualified paths and extensions. On simple OSes like the PalmOS, the database name will be mapped to the appropriate database on the device. On devices with a file system a ".dat" extension will be added (if it is not already present in the name) and the file will be searched for as a file or resource.
mode - A string that should be "r" or "rw".
Returns:
An open Database object.
Throws:
IOException - If there is an error opening the file.
IllegalArgumentException

initializeDatabase

public static Database initializeDatabase(DatabaseMaker maker,
                                          String name,
                                          Object initializer,
                                          DataProcessor decryptor,
                                          DataProcessor encryptor)
                                   throws IOException
This is used to initialize a database if it has not yet been initialized. If the database already exists it will return null, otherwise it will attempt to create the database and return it so that you can initialize it.

Parameters:
name - A name for the database. Avoid using fully qualified paths and extensions. On simple OSes like the PalmOS, the database name will be mapped to the appropriate database on the device. On devices with a file system a ".dat" extension will be added (if it is not already present in the name) and the file will be searched for as a file or resource.
initializer - An optional object that can be used to initialize the fields and sorts of the database.
decryptor - An optional decryptor used to decode the database if it is encrypted.
encryptor - An optional encryptor used to encoded the database - used only when writing.
Returns:
If the database is already initialized it will return null, otherwise it will create the storage for the database and return the database uninitialized except for fields and sorts as specified by the optional intializer object. You should then setup the database and then call save() on it.
Throws:
IOException - If the database cannot be created, or is improperly formatted.

initializeDatabase

public static Database initializeDatabase(DatabaseMaker maker,
                                          String name,
                                          Object initializer)
                                   throws IOException
This is used to initialize a database if it has not yet been initialized. If the database already exists it will return null, otherwise it will attempt to create the database and return it so that you can initialize it.

Parameters:
name - A name for the database. Avoid using fully qualified paths and extensions. On simple OSes like the PalmOS, the database name will be mapped to the appropriate database on the device. On devices with a file system a ".dat" extension will be added (if it is not already present in the name) and the file will be searched for as a file or resource.
initializer - An optional object that can be used to initialize the fields and sorts of the database.
Returns:
If the database is already initialized it will return null, otherwise it will create the storage for the database and return the database uninitialized except for fields and sorts as specified by the optional intializer object. You should then setup the database and then call save() on it.
Throws:
IOException - If the database cannot be created, or is improperly formatted.

databaseExists

public static boolean databaseExists(DatabaseMaker maker,
                                     String name)

databaseIsValid

public static boolean databaseIsValid(DatabaseMaker maker,
                                      String name)