jgnash.engine
Class EngineFactory

java.lang.Object
  extended by jgnash.engine.EngineFactory

public class EngineFactory
extends java.lang.Object

Factory class for obtaining an engine instance The filename of the database or remote server must be explicitly set before an Engine instance will be returned

Version:
$Id$
Author:
Craig Cavanaugh

Field Summary
private static java.util.Map<java.lang.String,DataStore> dataStoreMap
           
static java.lang.String DEFAULT
           
private static java.lang.String DEFAULT_DIR
          Default directory for jGnash data.
private static java.util.Map<java.lang.String,Engine> engineMap
           
private static java.lang.String EXPORT_XML_ON_CLOSE
           
private static java.lang.String LAST_DATABASE
           
private static java.lang.String LAST_HOST
           
private static java.lang.String LAST_PASSWORD
           
private static java.lang.String LAST_PORT
           
private static java.lang.String LAST_REMOTE
           
private static java.lang.String LAST_USEDPASSWORD
           
private static java.lang.String LAST_USER
           
private static java.util.logging.Logger logger
           
private static java.lang.String MAX_BACKUPS
           
private static java.lang.String OPEN_LAST
           
private static java.lang.String REMOVE_BACKUPS
           
 
Constructor Summary
private EngineFactory()
           
 
Method Summary
static Engine bootClientEngine(java.lang.String host, int port, java.lang.String user, java.lang.String password, java.lang.String engineName, boolean savePassword)
           
private static Engine bootClientEngine(java.lang.String host, int port, java.lang.String user, java.lang.String password, java.lang.String engineName, boolean savePassword, DataStoreType type)
           
static Engine bootLocalEngine(java.lang.String fileName, java.lang.String engineName)
          Boots a local Engine for a preexisting file.
static Engine bootLocalEngine(java.lang.String fileName, java.lang.String engineName, DataStoreType type)
          Boots a local Engine for a file.
static void closeEngine(java.lang.String engineName)
           
static boolean deleteDatabase(java.lang.String database)
           
static boolean doesDatabaseExist(java.lang.String database)
           
static boolean doesDatabaseExist(java.lang.String database, DataStoreType type)
           
private static void exportCompressedXML(java.lang.String engineName)
           
static void exportCompressedXML(java.lang.String fileName, java.util.Collection<StoredObject> objects)
           
static boolean exportXMLOnClose()
           
static java.lang.String getActiveDatabase()
           
private static DataStoreType getDataStoreByType(java.io.File file)
           
static java.lang.String getDefaultDatabase()
          Returns the default path to the database without a file extension.
static Engine getEngine(java.lang.String name)
           
static java.lang.String getLastDatabase()
          Returns the last open database.
static java.lang.String getLastHost()
          Returns the host of the last remote database connection.
static java.lang.String getLastPassword()
          Returns the password of the last open database.
static int getLastPort()
          Returns the port of the last remote database connection.
static boolean getLastRemote()
          Returns true if the last connection was made to a remote host.
static java.lang.String getLastUser()
          Returns the user of the last open database.
static int maximumBackups()
           
static boolean openLastOnStartup()
           
static boolean removeOldBackups()
           
static void removeOldCompressedXML(java.lang.String fileName)
           
static void setExportXMLOnClose(boolean export)
           
static void setMaximumBackups(int max)
           
static void setOpenLastOnStartup(boolean last)
           
static void setRemoveOldBackups(boolean backup)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LAST_DATABASE

private static final java.lang.String LAST_DATABASE
See Also:
Constant Field Values

LAST_HOST

private static final java.lang.String LAST_HOST
See Also:
Constant Field Values

LAST_USER

private static final java.lang.String LAST_USER
See Also:
Constant Field Values

LAST_PORT

private static final java.lang.String LAST_PORT
See Also:
Constant Field Values

LAST_PASSWORD

private static final java.lang.String LAST_PASSWORD
See Also:
Constant Field Values

LAST_USEDPASSWORD

private static final java.lang.String LAST_USEDPASSWORD
See Also:
Constant Field Values

LAST_REMOTE

private static final java.lang.String LAST_REMOTE
See Also:
Constant Field Values

EXPORT_XML_ON_CLOSE

private static final java.lang.String EXPORT_XML_ON_CLOSE
See Also:
Constant Field Values

MAX_BACKUPS

private static final java.lang.String MAX_BACKUPS
See Also:
Constant Field Values

REMOVE_BACKUPS

private static final java.lang.String REMOVE_BACKUPS
See Also:
Constant Field Values

OPEN_LAST

private static final java.lang.String OPEN_LAST
See Also:
Constant Field Values

DEFAULT_DIR

private static final java.lang.String DEFAULT_DIR
Default directory for jGnash data. To be located in the default user directory

See Also:
Constant Field Values

logger

private static java.util.logging.Logger logger

DEFAULT

public static final java.lang.String DEFAULT
See Also:
Constant Field Values

engineMap

private static java.util.Map<java.lang.String,Engine> engineMap

dataStoreMap

private static java.util.Map<java.lang.String,DataStore> dataStoreMap
Constructor Detail

EngineFactory

private EngineFactory()
Method Detail

doesDatabaseExist

public static boolean doesDatabaseExist(java.lang.String database,
                                        DataStoreType type)

doesDatabaseExist

public static boolean doesDatabaseExist(java.lang.String database)

deleteDatabase

public static boolean deleteDatabase(java.lang.String database)

getEngine

public static Engine getEngine(java.lang.String name)

exportCompressedXML

private static void exportCompressedXML(java.lang.String engineName)

exportCompressedXML

public static void exportCompressedXML(java.lang.String fileName,
                                       java.util.Collection<StoredObject> objects)

removeOldCompressedXML

public static void removeOldCompressedXML(java.lang.String fileName)

closeEngine

public static void closeEngine(java.lang.String engineName)

bootLocalEngine

public static Engine bootLocalEngine(java.lang.String fileName,
                                     java.lang.String engineName)
Boots a local Engine for a preexisting file. The API determines the correct file type and uses the correct DataStoreType for engine initialization. If successful, a new Engine instance will be returned.

Parameters:
fileName - filename to load
engineName - engine identifier
Returns:
new Engine instance if successful, null otherwise
See Also:
Engine

bootLocalEngine

public static Engine bootLocalEngine(java.lang.String fileName,
                                     java.lang.String engineName,
                                     DataStoreType type)
Boots a local Engine for a file. If the file does not exist, it will be created. Otherwise it will be loaded. If successful, a new Engine instance will be returned.

Parameters:
fileName - filename to load or create
engineName - engine identifier
type - DataStoreType type to use for storage
Returns:
new Engine instance if successful
See Also:
Engine, DataStoreType

bootClientEngine

public static Engine bootClientEngine(java.lang.String host,
                                      int port,
                                      java.lang.String user,
                                      java.lang.String password,
                                      java.lang.String engineName,
                                      boolean savePassword)

bootClientEngine

private static Engine bootClientEngine(java.lang.String host,
                                       int port,
                                       java.lang.String user,
                                       java.lang.String password,
                                       java.lang.String engineName,
                                       boolean savePassword,
                                       DataStoreType type)

getDataStoreByType

private static DataStoreType getDataStoreByType(java.io.File file)

getDefaultDatabase

public static java.lang.String getDefaultDatabase()
Returns the default path to the database without a file extension.

Returns:
Default path to the database

getLastDatabase

public static java.lang.String getLastDatabase()
Returns the last open database. If a database has not been opened, then the default database will be returned.

Returns:
Last open or default database

getActiveDatabase

public static java.lang.String getActiveDatabase()

getLastUser

public static java.lang.String getLastUser()
Returns the user of the last open database. If a database has not been opened, then the default user will be returned.

Returns:
Last database user or default

getLastHost

public static java.lang.String getLastHost()
Returns the host of the last remote database connection. If a remote database has not been opened, then the default host will be returned.

Returns:
Last remote database host or default

getLastPort

public static int getLastPort()
Returns the port of the last remote database connection. If a remote database has not been opened, then the default port will be returned.

Returns:
Last remote database port or default

getLastRemote

public static boolean getLastRemote()
Returns true if the last connection was made to a remote host.

Returns:
true if the last connection was made to a remote host

getLastPassword

public static java.lang.String getLastPassword()
Returns the password of the last open database. If a database has not been opened, then the default password will be returned.

Returns:
Last database user or default

setExportXMLOnClose

public static void setExportXMLOnClose(boolean export)

setOpenLastOnStartup

public static void setOpenLastOnStartup(boolean last)

openLastOnStartup

public static boolean openLastOnStartup()

exportXMLOnClose

public static boolean exportXMLOnClose()

maximumBackups

public static int maximumBackups()

setMaximumBackups

public static void setMaximumBackups(int max)

removeOldBackups

public static boolean removeOldBackups()

setRemoveOldBackups

public static void setRemoveOldBackups(boolean backup)