marf.Storage
Class Database

java.lang.Object
  |
  +--marf.Storage.StorageManager
        |
        +--marf.Storage.Database
All Implemented Interfaces:
IDatabase, IStorageManager, java.io.Serializable

public class Database
extends StorageManager
implements IDatabase

Subject database. To be used by an application to contain information about known subjects (speakers, instruments, languages, etc).

Since:
0.3.0
Version:
$Revision: 1.5 $
Author:
Serguei Mokhov
See Also:
Serialized Form

Field Summary
protected  boolean bConnected
          Indicates whether we are connected or not.
 
Fields inherited from class marf.Storage.StorageManager
iCurrentDumpMode, oObjectToSerialize, strFilename
 
Fields inherited from interface marf.Storage.IDatabase
INTERFACE_CODE_REVISION
 
Fields inherited from interface marf.Storage.IStorageManager
DUMP_BINARY, DUMP_CSV_TEXT, DUMP_GZIP_BINARY, DUMP_HTML, DUMP_SQL, DUMP_XML, INTERFACE_CODE_REVISION, sastrExtensionsMap
 
Constructor Summary
Database()
          Default constructor with the StorageManager.
 
Method Summary
 void close()
          Closes (file) database connection.
 void connect()
          Connects to the database of subjects.
 int getIDByFilename(java.lang.String pstrFileName, boolean pbTraining)
          Given ID, fetches the corresponding filename.
 java.lang.String getName(int piID)
          Retrieves subject's name by their ID.
static java.lang.String getRevision()
          Returns source code revision information.
 void query()
          Retrieves subject's data from the database and populates internal data structures.
 
Methods inherited from class marf.Storage.StorageManager
backSynchronizeObject, dump, dumpBinary, dumpCSV, dumpGzipBinary, dumpHTML, dumpSQL, dumpXML, getDefaultExtension, getDefaultExtension, getDumpMode, getFilename, restore, restoreBinary, restoreCSV, restoreGzipBinary, restoreHTML, restoreSQL, restoreXML, setDumpMode, setFilename
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

bConnected

protected boolean bConnected
Indicates whether we are connected or not.

Constructor Detail

Database

public Database()
Default constructor with the StorageManager.

See Also:
StorageManager
Method Detail

getIDByFilename

public int getIDByFilename(java.lang.String pstrFileName,
                           boolean pbTraining)
                    throws StorageException
Given ID, fetches the corresponding filename. Retrieves Speaker's ID by a sample filename.

Specified by:
getIDByFilename in interface IDatabase
Parameters:
pstrFileName - Name of a .wav file for which ID must be returned
pbTraining - indicates whether the filename is a training (true) sample or testing (false)
Returns:
int ID, -1 if not found
Throws:
StorageException

getName

public java.lang.String getName(int piID)
                         throws StorageException
Retrieves subject's name by their ID.

Specified by:
getName in interface IDatabase
Parameters:
piID - ID of a subject in the DB to return a name for
Returns:
name string
Throws:
StorageException

connect

public void connect()
             throws StorageException
Connects to the database of subjects.

Specified by:
connect in interface IDatabase
Throws:
StorageException

query

public void query()
           throws StorageException
Retrieves subject's data from the database and populates internal data structures.

Specified by:
query in interface IDatabase
Throws:
StorageException

close

public void close()
           throws StorageException
Closes (file) database connection.

Specified by:
close in interface IDatabase
Throws:
StorageException

getRevision

public static java.lang.String getRevision()
Returns source code revision information.

Returns:
revision string