Class RemotePDBFile


  • public final class RemotePDBFile
    extends java.lang.Object
    Allows you to access a pdb file on the device from the desktop during the conduit synchronization.
    On PalmOS it may only be used to handle files on the device's internal memory.
    • Constructor Summary

      Constructors 
      Constructor Description
      RemotePDBFile​(java.lang.String name)
      Opens a remote PDBFile in READ_WRITE mode.
      RemotePDBFile​(java.lang.String name, int mode)
      Opens a remote PDBFile in the given mode.
      RemotePDBFile​(java.lang.String name, int mode, int recordSize)
      Opens a remote PDBFile with the given name.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()
      Closes this PDBFile.
      void delete()
      Completely deletes this database, closing it first.
      void deleteRecord​(int index)
      Deletes the given record index.
      protected void finalize()  
      int getNextModifiedRecordIndex()
      Returns the next modified record index.
      int getRecordCount()
      Returns the number of records inside this database
      int getRecordPos()
      Returns the current record position or -1 if there is no current record.
      static java.lang.String[] listPDBs​(int crtr, int type)
      Lists the available PDBFiles on the device that has the given creator id and type.
      boolean readRecord​(int index, RemotePDBRecord rec)
      Fetches the given index, passing to the rec a DataStream to read the record information.
      int skipBytes​(int n)
      Moves the cursor n bytes from the current position, moving backwards if n is negative, or forward if n is positive.
      The cursor cannot be placed outside the stream limits, stopping at position 0 when moving backwards, or at the last position of the stream, when moving forward.
      boolean writeRecord​(int index, RemotePDBRecord rec)
      Write the record at the given index.
      • Methods inherited from class java.lang.Object

        clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • name

        protected java.lang.String name
      • mode

        protected int mode
      • open

        protected boolean open
      • recIndex

        protected int recIndex
      • wRecordSize

        protected int wRecordSize
      • lastSearchedRec

        protected int lastSearchedRec
      • RECORD_SIZE_AUTO

        public static int RECORD_SIZE_AUTO
    • Method Detail

      • delete

        public final void delete()
                          throws IOException
        Completely deletes this database, closing it first.
        Throws:
        IOException
      • getRecordCount

        public final int getRecordCount()
                                 throws IOException
        Returns the number of records inside this database
        Throws:
        IOException
      • writeRecord

        public boolean writeRecord​(int index,
                                   RemotePDBRecord rec)
                            throws IllegalArgumentIOException,
                                   IOException
        Write the record at the given index. IMPORTANT: if index is -1, the record is appended, otherwise, the given record is OVERWRITTEN. It is not possible to insert a record into a given position due to limitations of the native API. Also, passing a record index greater than the number of records may cause unexpected results.
        Throws:
        IOException
        IllegalArgumentIOException
      • getRecordPos

        public int getRecordPos()
        Returns the current record position or -1 if there is no current record.
      • deleteRecord

        public final void deleteRecord​(int index)
                                throws IllegalArgumentIOException,
                                       IOException
        Deletes the given record index. The record is immediately removed from the PDBFile and all subsequent records are moved up one position. IMPORTANT: due to this behaviour, if you plan to delete all records from a database, it is much faster if you delete them in REVERSE ORDER (from last to first). If you plan to delete all records, delete the whole database using delete and then create it again.
        Throws:
        IOException
        IllegalArgumentIOException
      • skipBytes

        public int skipBytes​(int n)
        Moves the cursor n bytes from the current position, moving backwards if n is negative, or forward if n is positive.
        The cursor cannot be placed outside the stream limits, stopping at position 0 when moving backwards, or at the last position of the stream, when moving forward.
        Parameters:
        n - the number of bytes to move.
        Returns:
        the number of bytes actually moved.
      • getNextModifiedRecordIndex

        public final int getNextModifiedRecordIndex()
                                             throws IOException
        Returns the next modified record index. Can be used with the readRecord to only retrieve the changed records since the last synchronization.
        Throws:
        IOException
      • listPDBs

        public static java.lang.String[] listPDBs​(int crtr,
                                                  int type)
        Lists the available PDBFiles on the device that has the given creator id and type. If you don't pass a creator id and/or a type, this method will return with NO RESULTS. Note that the Settings.dataPath, if set, is used by this method as the path to the PDBFiles.
        Returns:
        A String array with the answer, or null if no db was found that matched the criteria.
      • finalize

        protected void finalize()
        Overrides:
        finalize in class java.lang.Object