brf.j2me.dynaworks.db
Class Record

java.lang.Object
  |
  +--brf.j2me.dynaworks.db.Record
All Implemented Interfaces:
Dataset
Direct Known Subclasses:
PalmRec

public class Record
extends java.lang.Object
implements Dataset

Abstract base class for database records.

Version:
1.0a1
Author:
Bernd R. Fix
See Also:
RecordField, Dataset

Field Summary
protected  byte[] content
          Record data representation.
protected  java.util.Hashtable fields
          List of fields in this record.
protected  java.util.Vector sequence
          vector holding the sequence of entries.
 
Constructor Summary
Record()
          constructor.
 
Method Summary
 boolean addField(java.lang.String name, RecordField field)
          add a record field into the list of attributes to process
 byte[] getBytes(java.lang.String name)
          get the byte array of an attribute.
 byte[] getContent()
          Get the byte array representing the record content.
 RecordField getField(java.lang.String name)
          retreives a named record field.
 int getInt(java.lang.String name)
          get an integer attribute
 short getShort(java.lang.String name)
          return a short attribute
 java.lang.String getString(java.lang.String name)
          get the string content of an attribute.
private  int readField(int pos, RecordField fld)
          Retreive the data from a record into a record field.
 void setBytes(java.lang.String name, byte[] data)
          set a byte array attribute
 boolean setContent(byte[] data)
          update the record with new data.
 void setField(java.lang.String name, RecordField data)
          set a named record field.
 void setInt(java.lang.String name, int data)
          set an integer attribute.
 void setShort(java.lang.String name, short data)
          Set a short attribute.
 void setString(java.lang.String name, java.lang.String data)
          set the string content of an attribute.
 int size()
          Get the 'byte' length of the record.
protected  void update(boolean tomem)
          Update all recordfields in the record.
private  int writeField(int pos, RecordField fld)
          Copy the data from a record field into the record content.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

content

protected byte[] content
Record data representation.


fields

protected java.util.Hashtable fields
List of fields in this record.


sequence

protected java.util.Vector sequence
vector holding the sequence of entries.

Constructor Detail

Record

public Record()
constructor.

Method Detail

size

public int size()
Get the 'byte' length of the record.

Specified by:
size in interface Dataset
Returns:
int - Length of the record (in bytes).

getContent

public final byte[] getContent()
Get the byte array representing the record content.

Specified by:
getContent in interface Dataset
Returns:
byte[] - Byte array holding record data.

setContent

public boolean setContent(byte[] data)
update the record with new data. The length of the array of bytes passed in must have the same length as the old record data.

Specified by:
setContent in interface Dataset
Parameters:
data - byte[] - array containing data.
Returns:
boolean - operation successful?

writeField

private final int writeField(int pos,
                             RecordField fld)
Copy the data from a record field into the record content.

Parameters:
pos - int - Starting position for field data.
fld - RecordField - field to be stored.
Returns:
int - Position of next field.

readField

private final int readField(int pos,
                            RecordField fld)
Retreive the data from a record into a record field.

Parameters:
pos - int - Starting position for field data.
fld - RecordField - field to be retreived.
Returns:
int - Position of next field.

update

protected void update(boolean tomem)
Update all recordfields in the record.

Parameters:
tomem - boolean - Store or retreive data?

addField

public boolean addField(java.lang.String name,
                        RecordField field)
add a record field into the list of attributes to process

Parameters:
field - RecordField - field to be added.
Returns:
boolean - status of operation

getBytes

public byte[] getBytes(java.lang.String name)
get the byte array of an attribute.

Parameters:
name - String - name of field.
Returns:
byte[] - byte content of field.

setBytes

public void setBytes(java.lang.String name,
                     byte[] data)
set a byte array attribute

Parameters:
name - String - name of the field.
data - byte[] - array of data.

getString

public java.lang.String getString(java.lang.String name)
get the string content of an attribute.

Parameters:
name - String - name of the field.
Returns:
String - content of field.

setString

public void setString(java.lang.String name,
                      java.lang.String data)
set the string content of an attribute.

Parameters:
name - String - name of the field.
data - String - content of field.

getInt

public int getInt(java.lang.String name)
get an integer attribute

Parameters:
name - String - name of the field.
Returns:
int - content of field.

setInt

public void setInt(java.lang.String name,
                   int data)
set an integer attribute.

Parameters:
name - String - name of the field.
data - int - content of field.

getShort

public short getShort(java.lang.String name)
return a short attribute

Parameters:
name - String - name of the field.
Returns:
short - content of field.

setShort

public void setShort(java.lang.String name,
                     short data)
Set a short attribute.

Parameters:
name - String - name of the field.
data - short - content of field.

getField

public RecordField getField(java.lang.String name)
retreives a named record field.

Parameters:
name - String - name of the field.
Returns:
RecordField - reference to recordfield.

setField

public void setField(java.lang.String name,
                     RecordField data)
set a named record field.

Parameters:
name - String - name of the field.
data - RecordField - reference to recordfield.