org.jSyncManager.API.Protocol.Util

Class DLPDatabase

Implemented Interfaces:
Serializable

public class DLPDatabase
extends java.lang.Object
implements 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.

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 char
NO_VERSION_CHANGE
A flag used when calling JHotSync.setDatabaseInfo() to denote that no version change should be made.
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
SEARCH_RAM_BASED_DB_FLAG
A flag to denate that we want to query RAM-based databases.
static byte
SEARCH_ROM_BASED_DB_FLAG
A flag to denate that we want to query ROM-based databases.
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.
protected Vector
data

Constructor Summary

DLPDatabase()
DLPDatabase default constructor
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(String s)
Export this database to a File.
DLPBlock
getApplicationBlock()
Get this databases application block.
DLPDatabaseInfo
getDatabaseInfo()
Get this database information object.
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.
static DLPDatabase
importFromFile(File filename)
Import a database from the specified File object.
static DLPDatabase
importFromFile(String filename)
Import a database from the specified file.
static DLPDatabase
importFromURL(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.
protected void
setDatabaseInfo(DLPDatabaseInfo dlpdatabaseinfo)
Set the Database Info object for this database.
protected void
setIsResourceDB(boolean flag)
Set the flag denoting whether this is a Resource DB or not.
void
setSortBlock(DLPBlock dlpblock)
Set the Sort Block for this database.
String
toString()
Displays the contents of this DLPDatabase object as human-readable Strings.

Field Details

APP_INFO_DIRTY

public static final char APP_INFO_DIRTY
A flag to denote that the app info block is dirty (modified).
Field Value:
'\u0004'

BACKUP_FLAG

public static final char BACKUP_FLAG
A flag to denote that this database should be backed up at sync time.
Field Value:
'\b'

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.
Field Value:
'@'

DB_OPEN

public static final char DB_OPEN
A flag to denote that the database is open.
Field Value:
'\u8000'

EXCLUSIVE_MODE

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

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.
Field Value:
'\u0010'

NO_VERSION_CHANGE

public static final char NO_VERSION_CHANGE
A flag used when calling JHotSync.setDatabaseInfo() to denote that no version change should be made.
Field Value:
'\uffff'

READ_MODE

public static final byte READ_MODE
A flag to denote that the database should be opened in read mode.
Field Value:
-128

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.
Field Value:
32

READ_ONLY

public static final char READ_ONLY
A flag to denote that this database is flagged as read-only.
Field Value:
'\u0002'

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.
Field Value:
' '

RESOURCE_DATABASE

public static final char RESOURCE_DATABASE
A flag to denote that this is a resource (application) database.
Field Value:
'\u0001'

SEARCH_RAM_BASED_DB_FLAG

public static final byte SEARCH_RAM_BASED_DB_FLAG
A flag to denate that we want to query RAM-based databases.
Field Value:
-128

SEARCH_ROM_BASED_DB_FLAG

public static final byte SEARCH_ROM_BASED_DB_FLAG
A flag to denate that we want to query ROM-based databases.
Field Value:
64

SHOW_SECRET

public static final byte SHOW_SECRET
A flag to denote that secret records should be shown.
Field Value:
16

WRITE_MODE

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

data

protected Vector data

Constructor Details

DLPDatabase

protected DLPDatabase()
DLPDatabase default constructor

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 Details

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(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 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.

importFromFile

public static DLPDatabase importFromFile(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.

importFromFile

public static DLPDatabase importFromFile(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.

importFromURL

public static DLPDatabase importFromURL(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.

setDatabaseInfo

protected void setDatabaseInfo(DLPDatabaseInfo dlpdatabaseinfo)
Set the Database Info object for this database.
Parameters:
dlpdatabaseinfo - the Database Info object for this database.

setIsResourceDB

protected void setIsResourceDB(boolean flag)
Set the flag denoting whether this is a Resource DB or not.
Parameters:
flag - true if this is a resource database, false otherwise.

setSortBlock

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

toString

public String toString()
Displays the contents of this DLPDatabase object as human-readable Strings. Note that the results of this method may differ depending on the source of the data it contains. A DLPDatabase object built in Java code using DLPBlock, DLPRecord, and/or DLPResource sub-classes will display the results of those classes toString() methods. Data read from the handheld or a PRC/PDB file in and of these generic types won't be up-casted to their parser types, and thus will be displayed in human-readable hex dump format.
Returns:
a human-readable String of the data contained within this DLPDatabase.