- java.lang.Object
-
- aeonics.template.Item<Storage.Type>
-
- aeonics.entity.Storage
-
- Direct Known Subclasses:
Storage.Database
,Storage.File
,Storage.Memory
public abstract class Storage extends Item<Storage.Type>
The Storage entity can be used to persist some content using a typical directory structure. The storage persistency may be temporary or long-lived, local or remote, file-based or any other implementation.The basic
Storage.Type.put(String, byte[])
andStorage.Type.get(String)
focus only on the content itself, not any metadata. If some metadata is necessary (file attributes or else) it is recommended to wrap the content and the matadata in aData
structure instead.The storage paths are case sensitive and use a forward slash separator
"/"
for path traversal.Within a storage, absolute or relative paths are treated equally, this means that the path
"foo/bar"
or"/foo/bar"
are considered equal. Implementations should always normalize the path and eventually resolve or relativize if needed.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Storage.Database
static class
Storage.File
static class
Storage.Memory
static class
Storage.Type
Superclass for all storage entities.
-
Constructor Summary
Constructors Constructor Description Storage()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.lang.Class<? extends Storage>
category()
Returns the target entity category.static java.lang.String
normalize(java.lang.String path)
Normalizes the provided path.static java.lang.String
relativize(java.lang.String root, java.lang.String path)
Relativizes the provided path against a root pathstatic java.lang.String
resolve(java.lang.String root, java.lang.String path)
Resolves the provided path against a root path-
Methods inherited from class aeonics.template.Item
creator, creator, defaultCreator, defaultTarget, defaultType, from, target, target, template, type, type
-
-
-
-
Method Detail
-
normalize
public static java.lang.String normalize(java.lang.String path)
Normalizes the provided path.- leading and trailing '/' are removed
- contiguous '/' are flattened as one
- current directory '.' are removed
- parent directory '..' are honored
- backslashes '\\' are converted to '/'
- blank or null is converted to ""
- Parameters:
path
- the requested path- Returns:
- the normalized path
-
resolve
public static java.lang.String resolve(java.lang.String root, java.lang.String path)
Resolves the provided path against a root path- Parameters:
root
- the root path to resolve againstpath
- the requested path- Returns:
- the normalized resolved path
-
relativize
public static java.lang.String relativize(java.lang.String root, java.lang.String path)
Relativizes the provided path against a root path- Parameters:
root
- the root path to relativize againstpath
- the requested path- Returns:
- the normalized relativized path
-
category
protected java.lang.Class<? extends Storage> category()
Description copied from class:Item
Returns the target entity category. This method should be implemented by subclasses to specify the entity category.- Specified by:
category
in classItem<Storage.Type>
- Returns:
- the target entity category
-
-