Class Index

java.lang.Object
org.rapidcontext.core.storage.Index

public class Index extends Object
An index dictionary. An index is an object containing the names of objects and sub-indices.

IMPORTANT: The index objects shouldn't be modified directly by outside the owning storage implementation.

Version:
1.0
  • Constructor Details

    • Index

      public Index()
      Creates a new empty index modified right now.
    • Index

      public Index(Date modified)
      Creates a new empty index.
      Parameters:
      modified - the last modified date
    • Index

      public Index(Index src, boolean normalize)
      Creates a new index that is a copy of another one. Optionally, all object names can be normalized with Storage.objectName().
      Parameters:
      src - the source index to copy
      normalize - the normalize object names flag
  • Method Details

    • merge

      public static Index merge(Index one, Index two)
      Merges two index dictionaries. Note that this may modify one of the two directories.
      Parameters:
      one - the first index dictionary
      two - the second index dictionary
      Returns:
      the merged index
    • isEmpty

      public boolean isEmpty()
      Checks if this index is empty.
      Returns:
      true if the index is empty, or false otherwise
    • modified

      public Date modified()
      Returns the last modified date.
      Returns:
      the last modified date
    • setModified

      public void setModified(Date date)
      Updates the last modified date.
      Parameters:
      date - the date to set, or null for now
    • hasIndex

      public boolean hasIndex(String name)
      Checks if a specified sub-index name is present.
      Parameters:
      name - the sub-index name to check
      Returns:
      true if the name is found, or false otherwise
    • hasObject

      public boolean hasObject(String name)
      Checks if a specified object name is present.
      Parameters:
      name - the object name to check
      Returns:
      true if the name is found, or false otherwise
    • indices

      public Stream<String> indices(boolean hidden)
      Returns an array of sub-index names.
      Parameters:
      hidden - include hidden paths
      Returns:
      an array of sub-index names
    • objects

      public Stream<String> objects(boolean hidden)
      Returns an array of object names.
      Parameters:
      hidden - include hidden paths
      Returns:
      an array of object names
    • paths

      public Stream<Path> paths(Path basePath, boolean hidden)
      Returns a stream of paths corresponding to all indices and objects in this index.
      Parameters:
      basePath - the path of this index
      hidden - include hidden paths
      Returns:
      a stream path objects
    • addIndex

      public boolean addIndex(String name)
      Adds a sub-index name. The name will only be added only if not already in the index.
      Parameters:
      name - the index name
      Returns:
      true if the name was added to the index, or false otherwise
    • addObject

      public boolean addObject(String name)
      Adds an object name. The name will only be added only if not already in the index.
      Parameters:
      name - the object name
      Returns:
      true if the name was added to the index, or false otherwise
    • removeIndex

      public boolean removeIndex(String name)
      Removes a sub-index name.
      Parameters:
      name - the index name
      Returns:
      true if the name was removed from the index, or false otherwise
    • removeObject

      public boolean removeObject(String name)
      Removes an object name.
      Parameters:
      name - the object name
      Returns:
      true if the name was removed from the index, or false otherwise