FileBriefcase

Overview

The FileBriefcase class provides support for persisting client data stored in a file and placed somewhere in the file system of the client. It can be useful in different scenarios, for example: *You can use briefcase for saving client data including uncommitted changes between restarts of your application *You can store some quite constant dictionary tables into briefcase and load them during application start, and thus avoid having to reload the same data from the server *You can implement requesting only changed records for some huge table from the server side and then merge the delta with the client table loaded from the local briefcase.

A briefcase can hold one or more DataTables with original data and pending Delta Changes that have not been applied yet. Also briefcase can hold one or more custom application-specific string properties. This can be useful, for example, for keeping data format version, to ensure that your application can read the data correctly.

All data in the FileBriefcase are stored using the Bin2DataStreamer streamer.

File of the FileBriefcase usually has .daBriefcase extension. The related file should be passed to the constructor on briefcase creation.

The Briefcase Explorer tool can be used to load and inspect data in the briefcase.

Location

 

constructor  protected    (declared in Briefcase)

Creates a new instance of the Briefcase class. Cannot be called directly.

 

constructor

 

FileBriefcase()

constructor (String, Boolean)

Creates an instance of the briefcase related to the file with the given name and reading mode. If second parameter is true, then an atempt of loading data from the given file will be performed on briefcase creation. If the given file name doesn't end with default file extension, i.e. '.daBriefcase', it will be appended to the given name before reading the file.

 

constructor(aFileName: String; aForReading: Boolean)

 

FileBriefcase(String aFileName, Boolean aForReading)

Parameters:

  • aFileName: A name of the file that will be related to the newly created Briefcase.
  • aForReading: Defines, wheter to try reading from file on briefcase creation. Set it to load data from existing briefcase file.

constructor <clinit>  External

 

class method constructor <clinit>

 

static void constructor <clinit>()

addTable    (declared in Briefcase)

Adds a data table to the Briefcase.

Table name should be unique for the given Briefcase.

 

method addTable(aTable: DataTable)

 

void addTable(DataTable aTable)

Parameters:

  • aTable: Data Table to add to the Briefcase

addTables    (declared in Briefcase)

Adds several data tables to the Briefcase.

Table name should be unique for the given Briefcase.

 

method addTables(aTables: array of DataTable)

 

void addTables(DataTable[] aTables)

Parameters:

  • aTables: An array of tables to add.

Count    (declared in Briefcase)

 

property Count: Integer read;

 

Integer Count { __get; }

doFill  protected

This method fills the fiven table with the data from related file.

 

method doFill(aTables: array of DataTable)

 

void doFill(DataTable[] aTables)

Parameters:

  • aTables: A set of data tables to fill. All tables should be named.

FileName    (declared in Briefcase)

 

property FileName: String read;

 

String FileName { __get; }

fillTable    (declared in Briefcase)

Fills the given named data table instance with the data from briefcase. Any further data changes in the given table won't be reflected in the briefcase, therefore use Briefcase method for this.

 

method fillTable(aTable: DataTable)

 

void fillTable(DataTable aTable)

Parameters:

  • aTable: Instantiated and named table instance to fill with data.

fillTables    (declared in Briefcase)

Fills the given named data tables instances with the data from briefcase. Any further data changes in the given tables won't be reflected in the briefcase, therefore use Briefcase method for this.

 

method fillTables(aTables: array of DataTable)

 

void fillTables(DataTable[] aTables)

Parameters:

  • aTables: Instantiated and named table instances to fill with data.

Properties    (declared in Briefcase)

 

property Properties: Map<String, String> read;

 

Map<String, String> Properties { __get; }

tableNamed (String): DataTable    (declared in Briefcase)

Returns a copy of the data table stored in the Briefcase.

Note: DataTable instance returned by this method is a clone of the original Data Table stored in the Briefcase. So any changes made to this DataTable won't affect data actually stored in the Briefcase.

 

method tableNamed(aTableName: String): DataTable

 

DataTable tableNamed(String aTableName)

Parameters:

  • aTableName: A name of the table, that should be returned.

tableNamed (String, Boolean): DataTable

Returns the filled table with the given name. The table instance with requested name could be already in the internal list of previously read tables, so the method first tries to return cached table.

 

method tableNamed(aTableName: String; aReload: Boolean): DataTable

 

DataTable tableNamed(String aTableName, Boolean aReload)

Parameters:

  • aTableName: A name of the table to return.
  • aReload: Defined wheter the method can return previuosly read table or it should reload table from the related file.

TableNames    (declared in Briefcase)

 

property TableNames: array of String read;

 

String[] TableNames { __get; }

writeBriefcase

Writes tables from internal cache back to the related file. If some tables weren't loaded, it first forces to read them from the file before rewriting it.

 

method writeBriefcase

 

void writeBriefcase()

 

Count    (declared in Briefcase)

 

property Count: Integer read;

 

Integer Count { __get; }

FileName    (declared in Briefcase)

 

property FileName: String read;

 

String FileName { __get; }

Properties    (declared in Briefcase)

 

property Properties: Map<String, String> read;

 

Map<String, String> Properties { __get; }

TableNames    (declared in Briefcase)

 

property TableNames: array of String read;

 

String[] TableNames { __get; }

 

constructor <clinit>  External

 

class method constructor <clinit>

 

static void constructor <clinit>()

 

constructor  protected    (declared in Briefcase)

Creates a new instance of the Briefcase class. Cannot be called directly.

 

constructor

 

FileBriefcase()

constructor (String, Boolean)

Creates an instance of the briefcase related to the file with the given name and reading mode. If second parameter is true, then an atempt of loading data from the given file will be performed on briefcase creation. If the given file name doesn't end with default file extension, i.e. '.daBriefcase', it will be appended to the given name before reading the file.

 

constructor(aFileName: String; aForReading: Boolean)

 

FileBriefcase(String aFileName, Boolean aForReading)

Parameters:

  • aFileName: A name of the file that will be related to the newly created Briefcase.
  • aForReading: Defines, wheter to try reading from file on briefcase creation. Set it to load data from existing briefcase file.

addTable    (declared in Briefcase)

Adds a data table to the Briefcase.

Table name should be unique for the given Briefcase.

 

method addTable(aTable: DataTable)

 

void addTable(DataTable aTable)

Parameters:

  • aTable: Data Table to add to the Briefcase

addTables    (declared in Briefcase)

Adds several data tables to the Briefcase.

Table name should be unique for the given Briefcase.

 

method addTables(aTables: array of DataTable)

 

void addTables(DataTable[] aTables)

Parameters:

  • aTables: An array of tables to add.

doFill  protected

This method fills the fiven table with the data from related file.

 

method doFill(aTables: array of DataTable)

 

void doFill(DataTable[] aTables)

Parameters:

  • aTables: A set of data tables to fill. All tables should be named.

fillTable    (declared in Briefcase)

Fills the given named data table instance with the data from briefcase. Any further data changes in the given table won't be reflected in the briefcase, therefore use Briefcase method for this.

 

method fillTable(aTable: DataTable)

 

void fillTable(DataTable aTable)

Parameters:

  • aTable: Instantiated and named table instance to fill with data.

fillTables    (declared in Briefcase)

Fills the given named data tables instances with the data from briefcase. Any further data changes in the given tables won't be reflected in the briefcase, therefore use Briefcase method for this.

 

method fillTables(aTables: array of DataTable)

 

void fillTables(DataTable[] aTables)

Parameters:

  • aTables: Instantiated and named table instances to fill with data.

tableNamed (String): DataTable    (declared in Briefcase)

Returns a copy of the data table stored in the Briefcase.

Note: DataTable instance returned by this method is a clone of the original Data Table stored in the Briefcase. So any changes made to this DataTable won't affect data actually stored in the Briefcase.

 

method tableNamed(aTableName: String): DataTable

 

DataTable tableNamed(String aTableName)

Parameters:

  • aTableName: A name of the table, that should be returned.

tableNamed (String, Boolean): DataTable

Returns the filled table with the given name. The table instance with requested name could be already in the internal list of previously read tables, so the method first tries to return cached table.

 

method tableNamed(aTableName: String; aReload: Boolean): DataTable

 

DataTable tableNamed(String aTableName, Boolean aReload)

Parameters:

  • aTableName: A name of the table to return.
  • aReload: Defined wheter the method can return previuosly read table or it should reload table from the related file.

writeBriefcase

Writes tables from internal cache back to the related file. If some tables weren't loaded, it first forces to read them from the file before rewriting it.

 

method writeBriefcase

 

void writeBriefcase()

See Also