Package org.rapidcontext.core.storage
Class Index
java.lang.Object
org.rapidcontext.core.storage.Index
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
Adds a sub-index name.boolean
Adds an object name.boolean
Checks if a specified sub-index name is present.boolean
Checks if a specified object name is present.indices
(boolean hidden) Returns an array of sub-index names.boolean
isEmpty()
Checks if this index is empty.static Index
Merges two index dictionaries.modified()
Returns the last modified date.objects
(boolean hidden) Returns an array of object names.Returns a stream of paths corresponding to all indices and objects in this index.boolean
removeIndex
(String name) Removes a sub-index name.boolean
removeObject
(String name) Removes an object name.void
setModified
(Date date) Updates the last modified date.
-
Constructor Details
-
Index
Creates a new empty index.- Parameters:
modified
- the last modified date, or null for unknown
-
Index
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 copynormalize
- the normalize object names flag
-
-
Method Details
-
merge
Merges two index dictionaries. Note that this may modify one of the two directories.- Parameters:
one
- the first index dictionarytwo
- 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
Returns the last modified date.- Returns:
- the last modified date, or null if unknown
-
setModified
Updates the last modified date.- Parameters:
date
- the date to set, or null for now
-
hasIndex
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
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
Returns an array of sub-index names.- Parameters:
hidden
- include hidden paths- Returns:
- an array of sub-index names
-
objects
Returns an array of object names.- Parameters:
hidden
- include hidden paths- Returns:
- an array of object names
-
paths
Returns a stream of paths corresponding to all indices and objects in this index.- Parameters:
basePath
- the path of this indexhidden
- include hidden paths- Returns:
- a stream path objects
-
addIndex
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
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
Removes a sub-index name.- Parameters:
name
- the index name- Returns:
- true if the name was removed from the index, or false otherwise
-
removeObject
Removes an object name.- Parameters:
name
- the object name- Returns:
- true if the name was removed from the index, or false otherwise
-