Module aeonics.core

Class 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[]) and Storage.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 a Data 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.

    See Also:
    normalize(String), resolve(String, String), relativize(String, String)
    • Constructor Detail

      • Storage

        public Storage()
    • 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 against
        path - 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 against
        path - 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 class Item<Storage.Type>
        Returns:
        the target entity category