Package org.rapidcontext.core.storage
Class DirStorage
java.lang.Object
org.rapidcontext.core.storage.StorableObject
org.rapidcontext.core.storage.Storage
org.rapidcontext.core.storage.DirStorage
- All Implemented Interfaces:
Comparable<Storage>
A persistent data storage and retrieval handler based on a file
system directory. This class will read and write both Java
property files and binary files depending on the object type
provided. The property files are used for all dictionary data
storage and retrieval.
- Version:
- 1.0
-
Field Summary
FieldsFields inherited from class org.rapidcontext.core.storage.Storage
EXT_ALL, EXT_JSON, EXT_PROPERTIES, EXT_XML, EXT_YAML, KEY_MOUNT_OVERLAY_PATH, KEY_MOUNT_OVERLAY_PRIO, KEY_MOUNT_PATH, KEY_MOUNT_TIME, KEY_READWRITE, PATH_STORAGEINFO
Fields inherited from class org.rapidcontext.core.storage.StorableObject
dict, KEY_ACTIVATED_TIME, KEY_CLASSNAME, KEY_ID, KEY_TYPE, PREFIX_COMPUTED, PREFIX_HIDDEN
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondir()
Returns the base directory for the storage data files.Loads an object from the specified location.Searches for an object at the specified location and returns metadata about the object if found.void
Removes an object or an index at the specified location.void
Stores an object at the specified location.Methods inherited from class org.rapidcontext.core.storage.Storage
compareTo, isReadWrite, load, localPath, mountOverlayPath, mountOverlayPrio, mountTime, objectName, objectPath, path, query, serialize, serializedPath, setMountInfo, unserialize
Methods inherited from class org.rapidcontext.core.storage.StorableObject
activate, activatedTime, destroy, id, init, isActive, isModified, passivate, serialize, sterilize, toString, type
-
Field Details
-
KEY_DIR
The dictionary key for the base directory. The value stored is a file object.- See Also:
-
-
Constructor Details
-
DirStorage
Creates a new directory storage.- Parameters:
dir
- the base data directory to usereadWrite
- the read write flag
-
-
Method Details
-
dir
Returns the base directory for the storage data files.- Returns:
- the base directory for data files
-
lookup
Searches for an object at the specified location and returns metadata about the object if found. The path may locate either an index or a specific object. -
load
Loads an object from the specified location. The path may locate either an index or a specific object. In case of an index, the data returned is an index dictionary listing of all objects in it. -
store
Stores an object at the specified location. The path must locate a particular object or file, since direct manipulation of indices is not supported. Any previous data at the specified path will be overwritten or removed. Note that only dictionaries and files can be stored in a file storage.- Specified by:
store
in classStorage
- Parameters:
path
- the storage locationdata
- the data to store- Throws:
StorageException
- if the data couldn't be written
-
remove
Removes an object or an index at the specified location. If the path refers to an index, all contained objects and indices will be removed recursively.- Specified by:
remove
in classStorage
- Parameters:
path
- the storage location- Throws:
StorageException
- if the data couldn't be removed
-