com.sparsity.dex.gdb
Class Dex

java.lang.Object
  extended by com.sparsity.dex.gdb.Dex
All Implemented Interfaces:
java.io.Closeable

public class Dex
extends java.lang.Object
implements java.io.Closeable

Dex class.

All Dex programs must have one single Dex instance to manage one or more Database instances.

This class allows for the creation of new Databases or open an existing one.

Author:
Sparsity Technologies http://www.sparsity-technologies.com

Field Summary
static java.lang.String Version
          Dex version.
 
Constructor Summary
Dex(DexConfig config)
          Creates a new instance.
 
Method Summary
 void close()
          Closes the Dex instance.
 Database create(java.lang.String path, java.lang.String alias)
          Creates a new Database instance.
 boolean isClosed()
          Gets if Dex instance has been closed or not.
 Database open(java.lang.String path, boolean read)
          Opens an existing Database instance.
 Database restore(java.lang.String path, java.lang.String backupFile)
          Restores a Database from a backup file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

Version

public static java.lang.String Version
Dex version.

Constructor Detail

Dex

public Dex(DexConfig config)
Creates a new instance.

Parameters:
config - [in] Dex configuration.
Method Detail

create

public Database create(java.lang.String path,
                       java.lang.String alias)
                throws java.io.FileNotFoundException,
                       java.lang.RuntimeException
Creates a new Database instance.

Parameters:
path - [in] Database storage file.
alias - [in] Database alias name.
Returns:
A Database instance.
Throws:
java.io.FileNotFoundException - If the given file cannot be created.
java.lang.RuntimeException - null

restore

public Database restore(java.lang.String path,
                        java.lang.String backupFile)
                 throws java.io.FileNotFoundException,
                        java.lang.RuntimeException
Restores a Database from a backup file.

See Graph::Backup.

Parameters:
path - [in] Database storage file.
backupFile - [in] The Backup file to be restored.
Returns:
A Database instance.
Throws:
java.io.FileNotFoundException - If the given file cannot be created, or the exported data file does not exists.
java.lang.RuntimeException - null

isClosed

public boolean isClosed()
Gets if Dex instance has been closed or not.

Returns:
TRUE if the Dex instance has been closed, FALSE otherwise.
See Also:
close()

close

public void close()
Closes the Dex instance.

It must be called to ensure the integrity of all data.

Specified by:
close in interface java.io.Closeable

open

public Database open(java.lang.String path,
                     boolean read)
              throws java.io.FileNotFoundException,
                     java.lang.RuntimeException
Opens an existing Database instance.

Parameters:
path - [in] Database storage file.
read - [in] If TRUE, open Database in read-only mode.
Returns:
A Database instance.
Throws:
java.io.FileNotFoundException - If the given file does not exist.
java.lang.RuntimeException - null