Class ZidFile


  • public class ZidFile
    extends Object
    Author:
    Werner Dittmann <Werner.Dittmann@t-online.de>
    • Method Detail

      • getInstance

        public static ZidFile getInstance()
        Get the an instance of ZIDFile. This method just creates an instance an store a pointer to it in a static variable. The ZIDFile is a singleton, thus only one ZID file can be open at one time.
        Returns:
        A pointer to the global ZIDFile singleton instance.
      • open

        public int open​(String name)
        Open the named ZID file and return a ZID file class. This static function either opens an existing ZID file or creates a new ZID file with the given name. The ZIDFile is a singleton, thus only one ZID file can be open at one time. To open another ZID file you must close the active ZID file first.
        Parameters:
        name - The name of the ZID file to open or create
        Returns:
        1 if file could be opened/created, 0 if the ZID instance already has an open file, -1 if open/creation of file failed.
      • isOpen

        public boolean isOpen()
        Check if ZIDFile has an active (open) file.
        Returns:
        True if ZIDFile has an active file, false otherwise
      • close

        public void close()
        Close the ZID file. Closes the ZID file, and prepares to open a new ZID file.
      • getRecord

        public ZidRecord getRecord​(byte[] zid)
        Get a ZID record from the active ZID file. The method get the identifier data from the ZID record parameter, locates the record in the ZID file and fills in the RS1, RS2, and other data. If no matching record exists in the ZID file the method creates it and fills it with default values.
        Parameters:
        zid - contains the identifier data. The method returns the record.
        Returns:
        The existing or created ZID record or null in case of I/O problems.
      • saveRecord

        public int saveRecord​(ZidRecord zidRecord)
        Save a ZID record into the active ZID file. This method saves the content of a ZID record into the ZID file. Before you can save the ZID record you must have performed a getRecord() first.
        Parameters:
        zidRecord - The ZID record to save.
        Returns:
        1 on success
      • getZid

        public byte[] getZid()
        Get the ZID associated with this ZID file.
        Returns:
        Pointer to the ZID