Package org.rapidcontext.core.storage
Class Metadata
java.lang.Object
org.rapidcontext.core.storage.StorableObject
org.rapidcontext.core.storage.Metadata
An object metadata container. Used for basic introspection of
objects inside storages.
- Version:
- 1.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
The binary category value.static final String
The index category value.static final String
The object category value.static final String
The dictionary key for the object category, i.e.static final String
The dictionary key for the Java class of the object.static final String
The dictionary key for the object MIME type.static final String
The dictionary key for the last modified date.static final String
The dictionary key for the object path.static final String
The dictionary key for the size (in bytes) of the stored data.static final String
The dictionary key for the storage paths.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 TypeMethodDescriptioncategory()
Returns the category for the object.static String
Returns the object category based on the class.Class
<?> Returns the class for the object.Returns the class name for the object.boolean
isBinary()
Checks if the object category is binary.boolean
isIndex()
Checks if the object category is an index.boolean
isObject()
Checks if the object category is an object.boolean
Checks if the object category is an object of the specified class (or a subclass).static Metadata
Merges two metadata containers.mimeType()
Returns the MIME type for the object.protected Metadata
Sets the MIME type for the object.modified()
Returns the last modified date for the object.protected Metadata
Sets the last modified date for the object.path()
Returns the absolute object path.Returns a serialized representation of this object.long
size()
Returns the size (in bytes) of the object.protected Metadata
size
(long size) Sets the size (in bytes) of the object.storages()
Returns an array with the root paths to all storages containing this object.Methods inherited from class org.rapidcontext.core.storage.StorableObject
activate, activatedTime, destroy, id, init, isActive, isModified, passivate, sterilize, toString, type
-
Field Details
-
KEY_CATEGORY
The dictionary key for the object category, i.e. the type of object being described. The value stored is a string, using one of the predefined constant type values.- See Also:
-
KEY_CLASS
The dictionary key for the Java class of the object. The value stored is the actual Class of the object.- See Also:
-
KEY_PATH
The dictionary key for the object path. The value stored is a path object.- See Also:
-
KEY_STORAGES
The dictionary key for the storage paths. The value is an array with path objects for all storages containing the path.- See Also:
-
KEY_MIMETYPE
The dictionary key for the object MIME type. The value stored is the MIME type of the object (prior to loading) if known.- See Also:
-
KEY_MODIFIED
The dictionary key for the last modified date. The value stored is a Date object.- See Also:
-
KEY_SIZE
The dictionary key for the size (in bytes) of the stored data. The value stored is a Long value.- See Also:
-
CATEGORY_INDEX
The index category value.- See Also:
-
CATEGORY_OBJECT
The object category value.- See Also:
-
CATEGORY_BINARY
The binary category value.- See Also:
-
-
Constructor Details
-
Metadata
Creates a new metadata container with modified path information.- Parameters:
path
- the absolute object pathmeta
- the metadata container to copy
-
Metadata
Creates a new metadata container.- Parameters:
clazz
- the object classpath
- the absolute object pathstoragePath
- the absolute storage pathmodified
- the last modified date, or null for unknown
-
-
Method Details
-
category
Returns the object category based on the class. This method checks if the class inherits from the Index or Binary classes, otherwise it returns the object class.- Parameters:
clazz
- the object class- Returns:
- the object category
-
merge
Merges two metadata containers. If either of the two values is null, the other will be returned. Otherwise, a new metadata container is created as a merged copy of two. The first will serve as the base, adding additional storage paths from the second as needed. For index objects, the last modified date will be adjusted to the maximum of the two objects.- Parameters:
meta1
- the first metadata objectmeta2
- the second metadata object- Returns:
- the merged metadata container
-
isIndex
public boolean isIndex()Checks if the object category is an index.- Returns:
- true if the object category is an index, or false otherwise
-
isObject
public boolean isObject()Checks if the object category is an object.- Returns:
- true if the object category is an object, or false otherwise
-
isObject
Checks if the object category is an object of the specified class (or a subclass).- Parameters:
clazz
- the object class- Returns:
- true if the object category is a matching object, or false otherwise
-
isBinary
public boolean isBinary()Checks if the object category is binary.- Returns:
- true if the object category is binary, or false otherwise
-
category
Returns the category for the object.- Returns:
- the category for the object
- See Also:
-
classInstance
Returns the class for the object.- Returns:
- the class for the object
-
className
Returns the class name for the object.- Returns:
- the class name for the object
-
path
Returns the absolute object path.- Overrides:
path
in classStorableObject
- Returns:
- the absolute object path
-
storages
Returns an array with the root paths to all storages containing this object.- Returns:
- an array with path objects for storage roots
-
mimeType
Returns the MIME type for the object.- Returns:
- the MIME type for the object, or null
-
mimeType
Sets the MIME type for the object.- Parameters:
mime
- the MIME type, or null for unknown- Returns:
- this metadata object (for chaining)
-
modified
Returns the last modified date for the object.- Returns:
- the last modified date for the object, or null if unknown
-
modified
Sets the last modified date for the object.- Parameters:
date
- the date to set, or null for unknown- Returns:
- this metadata object (for chaining)
-
size
public long size()Returns the size (in bytes) of the object.- Returns:
- the size (in bytes) of the object, or zero (0) if unknown
-
size
Sets the size (in bytes) of the object.- Parameters:
size
- the size to set- Returns:
- this metadata object (for chaining)
-
serialize
Returns a serialized representation of this object. Used when persisting to permanent storage or when accessing the object from outside pure Java. Returns a shallow copy of the contained dictionary.- Overrides:
serialize
in classStorableObject
- Returns:
- the serialized representation of this object
-