net.sourceforge.jpalm.mobiledb.record
Class AbstractRecord

java.lang.Object
  extended by net.sourceforge.jpalm.DataBlock
      extended by net.sourceforge.jpalm.mobiledb.record.AbstractRecord
All Implemented Interfaces:
Record
Direct Known Subclasses:
DataRecord, FieldDefinitionsRecord, FieldDisplaySizesRecord, FieldLabelsRecord, PreferencesRecord

public abstract class AbstractRecord
extends DataBlock
implements Record

Base class for MobileDB database records.


Field Summary
protected  byte[][] fields
          The data fields as byte arrays.
protected  RecordHeader header
          The record header.
protected static byte[] HEADER
          The data header in a record.
protected static int MAX_FIELD_WIDTH
          The maximum length a field can be.
protected static byte TERIMINATOR
          The field terminator in a record.
protected static byte TRAILER
          The data trailer in a record.
 
Method Summary
 void deserialize(byte[] data)
          Populate class properties from a byte array.
 boolean equals(java.lang.Object object)
           
 RecordHeader getHeader()
          Gets the header for this record.
protected  java.util.List<java.lang.String> getInternalFields()
          Gets the internal fields as a list of strings.
 byte[] serialize()
          Create a byte array of the class properties.
 void setHeader(RecordHeader header)
          Sets the header for this record.
protected  void setInternalFields(java.util.List<java.lang.String> fieldsList)
          Sets the internal fields from a list of strings.
protected  java.util.List<java.lang.String> trimOrFillList(int size, java.lang.String defaultValue)
          Trim or fill a list to the specified size.
 
Methods inherited from class net.sourceforge.jpalm.DataBlock
toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

header

protected RecordHeader header
The record header.


MAX_FIELD_WIDTH

protected static final int MAX_FIELD_WIDTH
The maximum length a field can be. 1024

See Also:
Constant Field Values

HEADER

protected static final byte[] HEADER
The data header in a record.


TERIMINATOR

protected static final byte TERIMINATOR
The field terminator in a record.

See Also:
Constant Field Values

TRAILER

protected static final byte TRAILER
The data trailer in a record.

See Also:
Constant Field Values

fields

protected byte[][] fields
The data fields as byte arrays.

Method Detail

getHeader

public RecordHeader getHeader()
Description copied from interface: Record
Gets the header for this record.

Specified by:
getHeader in interface Record
Returns:
the header
See Also:
RecordHeader

setHeader

public void setHeader(RecordHeader header)
Description copied from interface: Record
Sets the header for this record.

Specified by:
setHeader in interface Record
Parameters:
header - the header
See Also:
RecordHeader

deserialize

public void deserialize(byte[] data)
Description copied from class: DataBlock
Populate class properties from a byte array.

Specified by:
deserialize in interface Record
Specified by:
deserialize in class DataBlock
Parameters:
data - the byte array

serialize

public byte[] serialize()
Description copied from class: DataBlock
Create a byte array of the class properties.

Specified by:
serialize in interface Record
Specified by:
serialize in class DataBlock
Returns:
the byte array

getInternalFields

protected java.util.List<java.lang.String> getInternalFields()
Gets the internal fields as a list of strings.

Returns:
list of fields

setInternalFields

protected void setInternalFields(java.util.List<java.lang.String> fieldsList)
Sets the internal fields from a list of strings.

Parameters:
fieldsList - the list of strings

trimOrFillList

protected java.util.List<java.lang.String> trimOrFillList(int size,
                                                          java.lang.String defaultValue)
Trim or fill a list to the specified size.

If a list needs to be filled, it will have the defaultValue appended to it. If a list needs to be trimmed, it will be truncated at size.

Parameters:
size - the size the list should be
defaultValue - the value to use for filling
Returns:
a list of size

equals

public boolean equals(java.lang.Object object)
Overrides:
equals in class DataBlock