jSyncManager

org.jSyncManager.API.Protocol.Util
Class DLPDatabase

java.lang.Object
  |
  +--org.jSyncManager.API.Protocol.Util.DLPDatabase
All Implemented Interfaces:
java.io.Serializable

public class DLPDatabase
extends java.lang.Object
implements java.io.Serializable

A class representing an entire handheld database. This class holds a single database. Note that this construct is not directly readable or writable to or from a handheld device -- instead it's a container class that can hold all of the other elements that can be read or written to the handheld device.

Version:
$Revision: 1.11 $
Author:
Brad BARCLAY <bbarclay@jsyncmanager.org>
Last modified by: $Author: dingodave $ on $Date: 2003/06/18 05:32:16 $.
See Also:
Serialized Form

Field Summary
static char APP_INFO_DIRTY
          A flag to denote that the app info block is dirty (modified).
static char BACKUP_FLAG
          A flag to denote that this database should be backed up at sync time.
static char COPY_PREVENTION
          A flag to denote that this database should employ copy protection.
static char DB_OPEN
          A flag to denote that the database is open.
static byte EXCLUSIVE_MODE
          A flag to denote that the database should be opened in exclusive mode.
static char INSTALL_NEWER
          A flag to denote that it's okay to write a newer version of this database with a different name if this database is currently open.
static byte RAM_BASED_DB_FLAG
          A flag to denate that this is a RAM-based database.
static byte READ_MODE
          A flag to denote that the database should be opened in read mode.
static byte READ_MULTI_FLAG
          A flag to denote that during a call to read the database list, multiple entries are allowed in the response.
static char READ_ONLY
          A flag to denote that this database is flagged as read-only.
static char RESET_AFTER_INSTALL
          A flag to denote that the handheld should be reset after the installation of this database.
static char RESOURCE_DATABASE
          A flag to denote that this is a resource (application) database.
static byte ROM_BASED_DB_FLAG
          A flag to denate that this is a ROM-based database.
static byte SHOW_SECRET
          A flag to denote that secret records should be shown.
static byte WRITE_MODE
          A flag to denote that the database should be opened in write mode.
 
Constructor Summary
DLPDatabase(boolean flag, DLPDatabaseInfo dlpdatabaseinfo)
          DLPDatabase constructor, with a flag denoting whether this is a resource DB or not, and the DLPDatabaseInfo block.
 
Method Summary
 void addElement(DLPRecord dlprecord)
          Add an element in the form of a DLPRecord to the database.
 void addElement(DLPResource dlpresource)
          Add an element in the form of a DLPResource to the database.
 void exportDatabase(java.lang.String s)
          Export this database to a File.
 DLPBlock getApplicationBlock()
          Get this databases application block.
 DLPDatabaseInfo getDatabaseInfo()
          Get this database information object.
 java.lang.Object getElement(int i)
          Get an element from the database by index.
 int getElements()
          Get the number of elements in the database.
 DLPBlock getSortBlock()
          Get the sort block for this database.
(package private)  java.lang.String getUniqueDBID()
          Get the unique DB ID for this database.
static DLPDatabase importFromFile(java.io.File filename)
          Import a database from the specified File object.
static DLPDatabase importFromFile(java.lang.String filename)
          Import a database from the specified file.
static DLPDatabase importFromURL(java.net.URL url)
          Import a database from the specified URL.
 boolean isResourceDB()
          Return boolean denoting whether this is a Resource DB or not.
 void setApplicationBlock(DLPBlock dlpblock)
          Set the ApplicationBlock for this database.
 void setSortBlock(DLPBlock dlpblock)
          Set the Sort Block for this database.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RAM_BASED_DB_FLAG

public static final byte RAM_BASED_DB_FLAG
A flag to denate that this is a RAM-based database.

ROM_BASED_DB_FLAG

public static final byte ROM_BASED_DB_FLAG
A flag to denate that this is a ROM-based database.

READ_MULTI_FLAG

public static final byte READ_MULTI_FLAG
A flag to denote that during a call to read the database list, multiple entries are allowed in the response.

RESOURCE_DATABASE

public static final char RESOURCE_DATABASE
A flag to denote that this is a resource (application) database.

READ_ONLY

public static final char READ_ONLY
A flag to denote that this database is flagged as read-only.

APP_INFO_DIRTY

public static final char APP_INFO_DIRTY
A flag to denote that the app info block is dirty (modified).

BACKUP_FLAG

public static final char BACKUP_FLAG
A flag to denote that this database should be backed up at sync time.

INSTALL_NEWER

public static final char INSTALL_NEWER
A flag to denote that it's okay to write a newer version of this database with a different name if this database is currently open.

RESET_AFTER_INSTALL

public static final char RESET_AFTER_INSTALL
A flag to denote that the handheld should be reset after the installation of this database.

COPY_PREVENTION

public static final char COPY_PREVENTION
A flag to denote that this database should employ copy protection. Copy protection is typically used to prevent IR beaming of the database.

DB_OPEN

public static final char DB_OPEN
A flag to denote that the database is open.

READ_MODE

public static final byte READ_MODE
A flag to denote that the database should be opened in read mode.

WRITE_MODE

public static final byte WRITE_MODE
A flag to denote that the database should be opened in write mode.

EXCLUSIVE_MODE

public static final byte EXCLUSIVE_MODE
A flag to denote that the database should be opened in exclusive mode.

SHOW_SECRET

public static final byte SHOW_SECRET
A flag to denote that secret records should be shown.
Constructor Detail

DLPDatabase

public DLPDatabase(boolean flag,
                   DLPDatabaseInfo dlpdatabaseinfo)
DLPDatabase constructor, with a flag denoting whether this is a resource DB or not, and the DLPDatabaseInfo block.
Parameters:
flag - true if this is a resource (application) database, false otherwise.
dlpdatabaseinfo - DLPDatabaseInfo block.
Method Detail

addElement

public void addElement(DLPRecord dlprecord)
Add an element in the form of a DLPRecord to the database.
Parameters:
dlprecord - DLPRecord to be inserted.

addElement

public void addElement(DLPResource dlpresource)
Add an element in the form of a DLPResource to the database.
Parameters:
dlpresource - DLPResource to be inserted.

exportDatabase

public void exportDatabase(java.lang.String s)
Export this database to a File.
Parameters:
s - path and name of file to export to.

getApplicationBlock

public DLPBlock getApplicationBlock()
Get this databases application block.
Returns:
this databases application block, or null if one is not present.

getDatabaseInfo

public DLPDatabaseInfo getDatabaseInfo()
Get this database information object.
Returns:
this database information object.

getElement

public java.lang.Object getElement(int i)
Get an element from the database by index.
Parameters:
i - index of the element requested.
Returns:
the selected element of data.

getElements

public int getElements()
Get the number of elements in the database.
Returns:
the number of elements in the database.

getSortBlock

public DLPBlock getSortBlock()
Get the sort block for this database.
Returns:
the sort block for this database, or null if one isn't present.

getUniqueDBID

java.lang.String getUniqueDBID()
Get the unique DB ID for this database.
Returns:
the unique DB ID for this database.

importFromFile

public static DLPDatabase importFromFile(java.lang.String filename)
                                  throws DatabaseFormatException
Import a database from the specified file.
Parameters:
filename - filename to import from.
Returns:
DLPDatabase the database object contained in the specified file.
Throws:
DatabaseFormatException - if the file isn't a serialized database.

importFromFile

public static DLPDatabase importFromFile(java.io.File filename)
                                  throws DatabaseFormatException
Import a database from the specified File object.
Parameters:
filename - the File object to import from.
Returns:
DLPDatabase the database read from the specified File object.
Throws:
DatabaseFormatException - thrown if the file doesn't contain a parseable database.

importFromURL

public static DLPDatabase importFromURL(java.net.URL url)
                                 throws DatabaseFormatException
Import a database from the specified URL.
Parameters:
url - the URL object to read from.
Returns:
DLPDatabase the database read and parsed from the requested URL.
Throws:
DatabaseFormatException - thrown if the received data is not a parseable database.

isResourceDB

public boolean isResourceDB()
Return boolean denoting whether this is a Resource DB or not. Database on PalmOS-bassed systems are one of two types -- either they are application databases, comprising an executable program or library made up of resources, or they are information databases, containing data elements.
Returns:
true if this is a resource database, false otherwise.

setApplicationBlock

public void setApplicationBlock(DLPBlock dlpblock)
Set the ApplicationBlock for this database.
Parameters:
dlpblock - the ApplicationBlock for this database.

setSortBlock

public void setSortBlock(DLPBlock dlpblock)
Set the Sort Block for this database.
Parameters:
dlpblock - the Sort Block for this database.

jSyncManager

Copyright (c) 1999 - 2003 Brad BARCLAY and others. All Rights Reserved.