com.syncbuilder.storage
Class MemoryDatabase

java.lang.Object
  |
  +--com.syncbuilder.storage.DatabaseBase
        |
        +--com.syncbuilder.storage.MemoryDatabase

public class MemoryDatabase
extends DatabaseBase

A representation of an in-memory database.

MemoryDatabase supports all the functionality that is specified in the Database interface.

See Also:
Database, DatabaseBase

Fields inherited from class com.syncbuilder.storage.DatabaseBase
_creator, _dbimpl, _dbmode, _dbname
 
Constructor Summary
MemoryDatabase(Char4 creator, java.lang.String dbname, int dbmode)
          Construct an empty MemoryDatabase object.
This constructor tries to figure out the proper version of DatabaseImpl by querying the DatabaseImplFactory.
MemoryDatabase(DatabaseImpl dbimpl, int dbmode)
          Construct an empty MemoryDatabase object.
 
Method Summary
 void close()
          Closes the database.
 void deleteAllRecords()
          Delete ALL records in the database.
 void deleteAllResources()
          Delete ALL resources.
 void deleteCategory(int category)
          Delete all records from a specified category
 void deleteRecord(RecordID uid)
          Delete the record with the specified UID from the database.
 void deleteResource(Char4 type, int id)
           
 AppBlock getAppBlock()
           
 DBInfo getDBInfo()
          Return meta-information about the Database Caution!
 Record getNextModifiedRecord()
           
 Record getNextModifiedRecord(int category)
           
 Record getNextRecord(int category)
           
 Pref getPref(int id, boolean backed_up)
          Get one of the preferences which are associated with the same app as the database.
 Record getRecord(int index)
           
 Record getRecord(RecordID uid)
           
 int getRecordCount()
          Return the number of records in the Database
 RecordID[] getRecordIDs(boolean sort, int start, int max)
          Return the UIDs of selected records in the DB.
 Resource getResource(Char4 type, int id)
           
 Resource getResource(int index)
           
 SortBlock getSortBlock()
           
 void moveCategory(int from, int to)
           
 void moveRecord(int from, int to)
          Move a record from one position to another.
 void purgeRecords()
          Deletes all records which are marked as archived or deleted
 void putRecord(Record record)
          Writes a record to the database.
 void putResource(Resource resource)
           
 void resetFlags()
          For record databases, reset all dirty flags.
 void resetNext()
          Resets the "next record" index to the beginning
 void setAppBlock(AppBlock appblock)
           
 void setDBInfo(DBInfo dbinfo)
          Associate a complete set of meta-information with the Database.
 void setPref(Pref pref)
          Store a Pref which is associated with the same app as the database to the database.
 void setSortBlock(SortBlock sortblock)
           
 
Methods inherited from class com.syncbuilder.storage.DatabaseBase
createAppBlock, createPref, createPref, createRecord, createRecord, createRecord, createResource, createResource, createResource, createSortBlock, finalize, getPref, getRecordIDs, getRecordIDs, getRecordIDs
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MemoryDatabase

public MemoryDatabase(Char4 creator,
                      java.lang.String dbname,
                      int dbmode)
Construct an empty MemoryDatabase object.
This constructor tries to figure out the proper version of DatabaseImpl by querying the DatabaseImplFactory.
Parameters:
creator - the creator ID of the database
dbname - the name of the database
dbmode - the mode of the database, use the Database.OPEN_XXX-flags

MemoryDatabase

public MemoryDatabase(DatabaseImpl dbimpl,
                      int dbmode)
Construct an empty MemoryDatabase object.
Parameters:
dbimpl - the DatabaseImpl to be used
dbmode - the mode of the database, use the Database.OPEN_XXX-flags
Method Detail

getAppBlock

public AppBlock getAppBlock()
                     throws DatabaseException
Overrides:
getAppBlock in class DatabaseBase

setAppBlock

public void setAppBlock(AppBlock appblock)
                 throws DatabaseException
Overrides:
setAppBlock in class DatabaseBase

getSortBlock

public SortBlock getSortBlock()
                       throws DatabaseException
Overrides:
getSortBlock in class DatabaseBase

setSortBlock

public void setSortBlock(SortBlock sortblock)
                  throws DatabaseException
Overrides:
setSortBlock in class DatabaseBase

getRecord

public Record getRecord(int index)
                 throws DatabaseException
Overrides:
getRecord in class DatabaseBase

getRecord

public Record getRecord(RecordID uid)
                 throws DatabaseException
Overrides:
getRecord in class DatabaseBase

getNextRecord

public Record getNextRecord(int category)
                     throws DatabaseException
Overrides:
getNextRecord in class DatabaseBase

getNextModifiedRecord

public Record getNextModifiedRecord()
                             throws DatabaseException
Overrides:
getNextModifiedRecord in class DatabaseBase

getNextModifiedRecord

public Record getNextModifiedRecord(int category)
                             throws DatabaseException
Overrides:
getNextModifiedRecord in class DatabaseBase

resetNext

public void resetNext()
               throws DatabaseException
Resets the "next record" index to the beginning
Overrides:
resetNext in class DatabaseBase

putRecord

public void putRecord(Record record)
               throws DatabaseException
Writes a record to the database. If the Record had an unspecified RecordID before, it will be assigned a valid RecordID.
Overrides:
putRecord in class DatabaseBase

deleteRecord

public void deleteRecord(RecordID uid)
                  throws DatabaseException
Delete the record with the specified UID from the database.
Parameters:
uid - the UID (not the index!) of the record
Overrides:
deleteRecord in class DatabaseBase

deleteAllRecords

public void deleteAllRecords()
                      throws DatabaseException
Delete ALL records in the database.
Use with caution!
Overrides:
deleteAllRecords in class DatabaseBase

deleteCategory

public void deleteCategory(int category)
                    throws DatabaseException
Delete all records from a specified category
Parameters:
category - the category
Overrides:
deleteCategory in class DatabaseBase

moveCategory

public void moveCategory(int from,
                         int to)
                  throws DatabaseException
Overrides:
moveCategory in class DatabaseBase

getRecordIDs

public RecordID[] getRecordIDs(boolean sort,
                               int start,
                               int max)
                        throws DatabaseException
Return the UIDs of selected records in the DB.
Parameters:
sort - will be ignored
start - the index of the first returned record
max - the maximum number of returned results
Overrides:
getRecordIDs in class DatabaseBase

purgeRecords

public void purgeRecords()
                  throws DatabaseException
Deletes all records which are marked as archived or deleted
Overrides:
purgeRecords in class DatabaseBase

moveRecord

public void moveRecord(int from,
                       int to)
                throws DatabaseException
Move a record from one position to another.
Overrides:
moveRecord in class DatabaseBase

getResource

public Resource getResource(int index)
                     throws DatabaseException
Overrides:
getResource in class DatabaseBase

getResource

public Resource getResource(Char4 type,
                            int id)
                     throws DatabaseException
Overrides:
getResource in class DatabaseBase

putResource

public void putResource(Resource resource)
                 throws DatabaseException
Overrides:
putResource in class DatabaseBase

deleteResource

public void deleteResource(Char4 type,
                           int id)
                    throws DatabaseException
Overrides:
deleteResource in class DatabaseBase

deleteAllResources

public void deleteAllResources()
                        throws DatabaseException
Delete ALL resources.
Use with caution!
Overrides:
deleteAllResources in class DatabaseBase

getPref

public Pref getPref(int id,
                    boolean backed_up)
             throws DatabaseException,
                    NoCreatorException
Get one of the preferences which are associated with the same app as the database.
Overrides:
getPref in class DatabaseBase

setPref

public void setPref(Pref pref)
             throws DatabaseException
Store a Pref which is associated with the same app as the database to the database.
Overrides:
setPref in class DatabaseBase

close

public void close()
           throws DatabaseException
Closes the database. The MemoryDatabase object shall no longer be used after the invocation of this method!
Overrides:
close in class DatabaseBase

resetFlags

public void resetFlags()
                throws DatabaseException
For record databases, reset all dirty flags. For both record and resource databases, set the last sync time to now.
Overrides:
resetFlags in class DatabaseBase

getRecordCount

public int getRecordCount()
                   throws DatabaseException
Return the number of records in the Database
Overrides:
getRecordCount in class DatabaseBase

getDBInfo

public DBInfo getDBInfo()
                 throws DatabaseException
Return meta-information about the Database Caution! This is an expensive operation on devices which are running Palm OS below version 3.0.
Overrides:
getDBInfo in class DatabaseBase

setDBInfo

public void setDBInfo(DBInfo dbinfo)
               throws DatabaseException
Associate a complete set of meta-information with the Database.


This material is Copyrighted (C) 1999 by Tilo Christ. All Rights Reserved.