|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
waba.lang.Object | +--waba.io.Stream | +--waba.io.Catalog
Catalog is a collection of records commonly referred to as a database on small devices.
Here is an example showing data being read from records in a catalog:
Catalog c = new Catalog("MyCatalog", Catalog.READ_ONLY); if (!c.isOpen()) return; int count = c.getRecordCount(); byte b[] = new byte[10]; for (int i = 0; i < count; i++) { c.setRecord(i); c.readBytes(b, 0, 10); ... } c.close();
Field Summary | |
static int |
CREATE
Create open mode. |
static int |
READ_ONLY
Read-only open mode. |
static int |
READ_WRITE
Read-write open mode. |
static int |
WRITE_ONLY
Write-only open mode. |
Constructor Summary | |
Catalog(String name,
int mode)
Opens a catalog with the given name and mode. |
Method Summary | |
int |
addRecord(int size)
Adds a record to the end of the catalog. |
boolean |
close()
Closes the catalog. |
boolean |
delete()
Deletes the catalog. |
boolean |
deleteRecord()
Deletes the current record and sets the current record position to -1. |
int |
getRecordCount()
Returns the number of records in the catalog or -1 if the catalog is not open. |
int |
getRecordSize()
Returns the size of the current record in bytes or -1 if there is no current record. |
boolean |
isOpen()
Returns true if the catalog is open and false otherwise. |
static String[] |
listCatalogs()
Returns the complete list of existing catalogs. |
int |
readBytes(byte[] buf,
int start,
int count)
Reads bytes from the current record into a byte array. |
boolean |
resizeRecord(int size)
Resizes a record. |
boolean |
setRecordPos(int pos)
Sets the current record position and locks the given record. |
int |
skipBytes(int count)
Advances the cursor in the current record a number of bytes. |
int |
writeBytes(byte[] buf,
int start,
int count)
Writes to the current record. |
Methods inherited from class waba.lang.Object |
toString |
Field Detail |
public static final int READ_ONLY
public static final int WRITE_ONLY
public static final int READ_WRITE
public static final int CREATE
Constructor Detail |
public Catalog(String name, int mode)
For PalmOS: A PalmOS creator id and type can be specified by appending a 4 character creator id and 4 character type to the name seperated by periods. For example:
Catalog c = new Catalog("MyCatalog.CRTR.TYPE", Catalog.CREATE);Will create a PalmOS database with the name "MyCatalog", creator id of "CRTR" and type of "TYPE".
If no creator id and type is specified, the creator id will default to the creator id of current waba program and the type will default to "DATA".
Under PalmOS, the name of the catalog must be 31 characters or less, not including the creator id and type. Windows CE supports a 32 character catalog name but to maintain compatibility with PalmOS, you should use 31 characters maximum for the name of the catalog.
name
- catalog namemode
- one of READ_ONLY, WRITE_ONLY, READ_WRITE or CREATEMethod Detail |
public int addRecord(int size)
size
- the size in bytes of the record to addpublic boolean resizeRecord(int size)
size
- the new size of the recordpublic boolean close()
public boolean delete()
public static String[] listCatalogs()
public boolean deleteRecord()
public int getRecordCount()
public int getRecordSize()
public boolean isOpen()
public boolean setRecordPos(int pos)
public int readBytes(byte[] buf, int start, int count)
buf
- the byte array to read data intostart
- the start position in the arraycount
- the number of bytes to readpublic int skipBytes(int count)
count
- the number of bytes to skippublic int writeBytes(byte[] buf, int start, int count)
buf
- the byte array to write data fromstart
- the start position in the byte arraycount
- the number of bytes to write
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |