Class HandleDatabase


  • public class HandleDatabase
    extends Object
    Keeps track of handles in memory, with support to load from and save to disk.
    • Constructor Detail

      • HandleDatabase

        public HandleDatabase()
    • Method Detail

      • load

        public void load​(InputStream inStream)
                  throws IOException
        Loads the handles database from disk
        Parameters:
        inStream - the input stream containing the handle records
        Throws:
        IOException - if errors occurs
      • store

        public void store​(OutputStream outStream)
                   throws IOException
        Stores handle database to disk
        Parameters:
        outStream - Output stream to write data to.
        Throws:
        IOException - if error occurs
      • get

        public Handle get​(String handleId)
        Gets the handle object by handle id.
        Parameters:
        handleId - The handle id.
        Returns:
        the handle object.
      • put

        public void put​(String handleId,
                        Handle handle)
        Puts the handle object in database (in memory).
        Parameters:
        handleId - The handle id.
        handle - The handle object
      • putIfAbsent

        public Handle putIfAbsent​(String handleId,
                                  Handle handle)
        Puts the handle object in database (in memory) if absent.
        Parameters:
        handleId - The handle id.
        handle - The handle object
        Returns:
        The previous handle instance or null
      • remove

        public void remove​(String handleId)
        Removes the handle from the database.
        Parameters:
        handleId - The handle id.