org.jSyncManager.API.Protocol.Util

Class DLPBlock

Implemented Interfaces:
Serializable
Known Direct Subclasses:
AbstractAppBlock

public class DLPBlock
extends java.lang.Object
implements Serializable

A class that represents database information blocks. This class stores a data block. This is typically used in Palm databases to store the application block and the sort block.

Field Summary

protected int
blockSize
Holds the size of the block.
protected byte[]
data
Holds the data array representing this block.

Constructor Summary

DLPBlock()
Creates an empty block, with size 0.
DLPBlock(inputData[] )
Creates a new block based on the input byte array.
DLPBlock(inputData[] , char blockSize)
Creates a new block based on the input byte array.

Method Summary

protected void
generateData()
Generates the data block from a set of class fields.
int
getBlockSize()
Returns the size of this block.
byte[]
getData()
Retreives the byte array containing the data in this block.
protected void
parseFields()
Parses the data block into a set of fields.
void
setData(data[] )
Sets the data byte array for this block.
String
toString()
Returns a human-readable hex representation of the block data.

Field Details

blockSize

protected int blockSize
Holds the size of the block.

data

protected byte[] data
Holds the data array representing this block.

Constructor Details

DLPBlock

public DLPBlock()
Creates an empty block, with size 0.

DLPBlock

public DLPBlock(inputData[] )
            throws DLPFunctionCallException
Creates a new block based on the input byte array. This construct is typically used when the block is read from the handheld via the DLP protocol, as it includes two extra bytes of sizing data that don't exist in PDB files.
Parameters:
Throws:
DLPFunctionCallException - thrown if any parsing problem is encountered.

DLPBlock

public DLPBlock(inputData[] ,
                char blockSize)
            throws DLPFunctionCallException
Creates a new block based on the input byte array. This constructor is best suited for uses where the input data does not contain the two-byte blocksize preceeding the data in the input byte array.
Parameters:
blockSize - the size of the input block.
Throws:
DLPFunctionCallException - thrown if any parsing problem is encountered.

Method Details

generateData

protected void generateData()
Generates the data block from a set of class fields. This method is called to take the input fields in the block class, and to form a byte array representation of the block. This method is intended for implementation by subclasses. In this class, its implementation is null.

getBlockSize

public int getBlockSize()
Returns the size of this block. This is the size of the block as reported by the Palm at generation time. To get the actual number of bytes in the current data array, you should instead use getData().length.
Returns:
the size of this block.

getData

public byte[] getData()
Retreives the byte array containing the data in this block.
Returns:
the byte array containing the data in this block.

parseFields

protected void parseFields()
            throws ParseException
Parses the data block into a set of fields. This method is called to take the input byte array in the block class, and to parse it into its representitive fields. This method is intended for implementation by subclasses. In this class, its implementation is null.
Throws:
ParseException - if an error is encountered while parsing the data fields.

setData

public void setData(data[] )
            throws ParseException
Sets the data byte array for this block.
Parameters:

toString

public String toString()
Returns a human-readable hex representation of the block data.
Returns:
java.lang.String