OpenOffice.org
XMerge API

org.openoffice.xmerge.converter.palm
Class PalmDB

java.lang.Object
  |
  +--org.openoffice.xmerge.converter.palm.PalmDB

public final class PalmDB
extends java.lang.Object

This class contains data for a single Palm database for use during a conversion process.

It contains zero or more Record objects stored in an array. The index of the Record object in the array is the Record id or number for that specific Record object. Note that this class does not check for maximum number of Records allowable in an actual PDB.

This class also contains the PDB name associated with the Palm database it represents. A PDB name consists of 32 bytes of a certain encoding (extended ASCII in this case).

The non default constructors take in a name parameter which may not be the exact PDB name to be used. The name parameter in String or byte array are converted to an exact NAME_LENGTH byte array. If the length of the name is less than NAME_LENGTH, it is padded with '\0' characters. If it is more, it gets truncated. The last character in the resulting byte array is always a '\0' character. The resulting byte array is stored in bName, and a corresponding String object sName that contains characters without the '\0' characters.

The write method is called within the PalmDocument.write method for writing out its data to the OutputStream object.

The read method is called within the PalmDocument.read method for reading in its data from the InputStream object.

See Also:
PalmDocument, Record

Field Summary
static int NAME_LENGTH
          Number of bytes for the name field in the PDB.
static short PDB_HEADER_ATTR_BACKUP
           
 
Constructor Summary
PalmDB(byte[] name, int creatorID, int typeID, int version, short attribute, Record[] recs)
          Constructor to create object with Record objects.
PalmDB(int creatorID, int typeID, int version, short attribute)
          Default constructor.
PalmDB(java.lang.String name, int creatorID, int typeID, int version, short attribute, Record[] recs)
          Constructor to create PalmDB object with Record objects.
 
Method Summary
 boolean equals(java.lang.Object obj)
          Override equals method of Object.
 short getAttribute()
          Returns attribute flag.
 int getCreatorID()
          Returns creator ID.
 byte[] getPDBNameBytes()
          Return the PDB name associated with this object in byte array of exact length of 32 bytes.
 java.lang.String getPDBNameString()
          Return the PDB name associated with this object.
 Record getRecord(int index)
          Return the specific Record object associated with the Record number.
 int getRecordCount()
          Return the number of Records contained in this PDB PalmDB object.
 Record[] getRecords()
          Return the list of Record objects.
 int getTypeID()
          Returns type ID.
 int getVersion()
          Returns version.
 void read(java.io.InputStream is)
          Read the necessary data to create a PDB from the InputStream.
 void setAttributes(int creatorID, int typeID, int version, short attribute)
          Set the attributes for the PalmDB object.
 void write(java.io.OutputStream os)
          Write out the number of Records followed by what will be written out by each Record object.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NAME_LENGTH

public static final int NAME_LENGTH
Number of bytes for the name field in the PDB.

PDB_HEADER_ATTR_BACKUP

public static final short PDB_HEADER_ATTR_BACKUP
Constructor Detail

PalmDB

public PalmDB(byte[] name,
              int creatorID,
              int typeID,
              int version,
              short attribute,
              Record[] recs)
       throws java.io.UnsupportedEncodingException
Constructor to create object with Record objects. recs.length can be zero for an empty PDB.
Parameters:
name - Suggested PDB name in a byte array.
creatorID - The PDB Creator ID.
typeID - The PDB Type ID.
version - The PDB header version.
attribute - The PDB header attribute.
recs - Array of Record objects.
Throws:
java.io.UnsupportedEncodingException - If name is not properly encoded.
NullPointerException - If recs is null.

PalmDB

public PalmDB(int creatorID,
              int typeID,
              int version,
              short attribute)
Default constructor.
Parameters:
creatorID - The PDB Creator ID.
typeID - The PDB Type ID.
version - The PDB header version.
attribute - The PDB header attribute.

PalmDB

public PalmDB(java.lang.String name,
              int creatorID,
              int typeID,
              int version,
              short attribute,
              Record[] recs)
       throws java.io.UnsupportedEncodingException
Constructor to create PalmDB object with Record objects. recs.length can be zero for an empty PDB.
Parameters:
name - Suggested PDB name in a String.
creatorID - The PDB Creator ID.
typeID - The PDB Type ID.
version - The PDB header version.
attribute - The PDB header attribute.
recs - Array of Record objects.
Throws:
java.io.UnsupportedEncodingException - If name is not properly encoded.
NullPointerException - If recs is null.
Method Detail

equals

public boolean equals(java.lang.Object obj)
Override equals method of Object. Two PalmDB objects are equal if they contain the same information, i.e. PDB name and Records. This is used primarily for testing purposes only for now.
Overrides:
equals in class java.lang.Object
Parameters:
obj - A PalmDB Object to compare.
Returns:
true if obj is equal to this, otherwise false.

getAttribute

public short getAttribute()
Returns attribute flag.
Returns:
The attribute flag.

getCreatorID

public int getCreatorID()
Returns creator ID.
Returns:
The creator ID.

getPDBNameBytes

public byte[] getPDBNameBytes()
Return the PDB name associated with this object in byte array of exact length of 32 bytes.
Returns:
The PDB name in byte array of length 32.

getPDBNameString

public java.lang.String getPDBNameString()
Return the PDB name associated with this object.
Returns:
The PDB name.

getRecord

public Record getRecord(int index)
Return the specific Record object associated with the Record number.
Parameters:
index - Record index number.
Returns:
The Record object in the specified index
Throws:
java.lang.ArrayIndexOutOfBoundsException - If index is out of bounds.

getRecordCount

public int getRecordCount()
Return the number of Records contained in this PDB PalmDB object.
Returns:
Number of Record objects.

getRecords

public Record[] getRecords()
Return the list of Record objects.
Returns:
The array of Record objects.

getTypeID

public int getTypeID()
Returns type ID.
Returns:
The type ID.

getVersion

public int getVersion()
Returns version.
Returns:
The version.

read

public void read(java.io.InputStream is)
          throws java.io.IOException
Read the necessary data to create a PDB from the InputStream.
Parameters:
is - The InputStream to read data in order to restore the object.
Throws:
java.io.IOException - If any I/O error occurs.

setAttributes

public void setAttributes(int creatorID,
                          int typeID,
                          int version,
                          short attribute)
Set the attributes for the PalmDB object.
Parameters:
creatorID - The PDB Creator ID.
typeID - The PDB Type ID.
version - The PDB header version.
attribute - The PDB header attribute.

write

public void write(java.io.OutputStream os)
           throws java.io.IOException
Write out the number of Records followed by what will be written out by each Record object.
Parameters:
os - The OutputStream to write the object.
Throws:
java.io.IOException - If any I/O error occurs.

OpenOffice.org
XMerge API

Copyright © 2002 OpenOffice.org