Class MapStorage

java.lang.Object
passwordmanager.decoded.MapStorage
All Implemented Interfaces:
Cloneable, IStorage

public class MapStorage extends Object implements IStorage
Implementation of a data structure with decrypted records in the form of key-value
Since:
2023-12-14
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private String
    Name of an decrypted data structure
    Map of decrypted records
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructor initializing the map of encrypted records and the name of the structure
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Method for cleaning up the data structure
    Method for cloning a data structure with decrypted records
    void
    create(IRecord record)
    A method that creates a new entry in the repository
    void
    delete(int index)
    Method removing information about a record in the repository
    Method for filtering structure records
    getByIndex(int index)
    Method that reads an entry from the repository
    Method for getting the name of an decrypted data structure
    boolean
    Method for checking a structure for missing values
    void
    put(int index, IRecord record)
    Method for establishing a new mapping between a key and a value in a data structure
    void
    setName(String newName)
    Method for setting the name of an encrypted data structure
    int
    Method for getting the number of elements in a data structure
    void
    update(IRecord record)
    Method updating information about a record in the repository

    Methods inherited from class java.lang.Object

    equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • storage

      private Map<Integer,IRecord> storage
      Map of decrypted records
    • name

      private String name
      Name of an decrypted data structure
  • Constructor Details

    • MapStorage

      public MapStorage()
      Constructor initializing the map of encrypted records and the name of the structure
  • Method Details

    • create

      public void create(IRecord record)
      A method that creates a new entry in the repository
      Specified by:
      create in interface IStorage
      Parameters:
      record - decoded record
    • getByIndex

      public IRecord getByIndex(int index)
      Method that reads an entry from the repository
      Specified by:
      getByIndex in interface IStorage
      Parameters:
      index - Index of entry to read in structure
    • update

      public void update(IRecord record)
      Method updating information about a record in the repository
      Specified by:
      update in interface IStorage
      Parameters:
      record - decrypted record to be updated
    • delete

      public void delete(int index)
      Method removing information about a record in the repository
      Specified by:
      delete in interface IStorage
      Parameters:
      index - decrypted record index to be removed
    • isEmpty

      public boolean isEmpty()
      Method for checking a structure for missing values
      Specified by:
      isEmpty in interface IStorage
      Returns:
      whether the data structure is empty or not
    • clear

      public void clear()
      Method for cleaning up the data structure
      Specified by:
      clear in interface IStorage
    • size

      public int size()
      Method for getting the number of elements in a data structure
      Specified by:
      size in interface IStorage
      Returns:
      number of elements in a data structure
    • getName

      public String getName()
      Method for getting the name of an decrypted data structure
      Specified by:
      getName in interface IStorage
      Returns:
      data structure name
    • setName

      public void setName(String newName)
      Method for setting the name of an encrypted data structure
      Specified by:
      setName in interface IStorage
      Parameters:
      newName - new data structure name
    • clone

      public MapStorage clone()
      Method for cloning a data structure with decrypted records
      Specified by:
      clone in interface IStorage
      Overrides:
      clone in class Object
      Returns:
      cloned structure
    • put

      public void put(int index, IRecord record)
      Method for establishing a new mapping between a key and a value in a data structure
      Parameters:
      index - map key
      record - map value
    • filterByInfo

      public MapStorage filterByInfo(String query)
      Method for filtering structure records
      Specified by:
      filterByInfo in interface IStorage
      Parameters:
      query - filter string