Class CoreMemory

java.lang.Object
me.neurodock.core.memory.CoreMemory

public class CoreMemory extends Object
CoreMemory is a class that provides a way to store and retrieve strings from a file.
This is meant to be used as a way to store and retrieve strings from a file.
  • Field Details

    • VERSION

      public static final int VERSION
      See Also:
    • MAPPED_MEMORY

      public static final String MAPPED_MEMORY
      Memory type identifier for key-value mapped memory storage.
      See Also:
    • ARRAYED_MEMORY

      public static final String ARRAYED_MEMORY
      Memory type identifier for sequential/array-based memory storage.
      See Also:
  • Constructor Details

    • CoreMemory

      public CoreMemory(String memoryFile)
      Creates a new instance of CoreMemory.
      Parameters:
      memoryFile - The file to store the memory in
  • Method Details

    • getInstance

      public static CoreMemory getInstance()
      Gets the singleton instance of CoreMemory.
      Returns:
      The singleton instance of CoreMemory
    • getMemoriesIdentity

      public String[] getMemoriesIdentity()
      Gets the memory.
      Returns:
      A list of memory identifies/names
    • getMemory

      public Optional<String> getMemory(String name)
    • addMemory

      public void addMemory(String name, String memory)
      Sets the memory.
      Parameters:
      name - The name/identity of the memory
      memory - The memory
    • removeMemory

      public void removeMemory(String name)
      Removes the memory.
      Parameters:
      name - The memory to remove
    • addMemory

      public void addMemory(String memory)
      Add an array-based memory
      Parameters:
      memory - The memory to remember
    • addMemory

      public void addMemory(String memory, int index)
      Add an array-based memory
      Parameters:
      memory - The memory to remember
      index - The index to put it at
    • getArrayMemories

      public org.json.JSONArray getArrayMemories()
      Get all array-stored memories
      Returns:
      An array of all array-based memories
    • getMemory

      public Optional<String> getMemory(int index)
      Get the array-based memory at index
      Parameters:
      index - The memory to retrieve
      Returns:
      The memory stored at index
    • getMappedMemories

      public String getMappedMemories()
      Gets all memories as a JSON string.
      Returns:
      A JSON string of all memories
    • getMemoriesArray

      public ArrayList<String> getMemoriesArray()