Interface IFileSystemEntry<Entry extends IFileSystemEntry<Entry>>

  • Type Parameters:
    Entry - The type of the file system entry.
    All Superinterfaces:
    Comparable<Entry>, Serializable
    All Known Implementing Classes:
    FormThemeFileEntry

    public interface IFileSystemEntry<Entry extends IFileSystemEntry<Entry>>
    extends Serializable, Comparable<Entry>
    Represents an entry in a file system, i.e. a file or a directory. This interface is used to abstract from the actual file system implementation, e.g. a local file system or a remote file system.
    Since:
    8.3.0
    Author:
    XIMA MEDIA GmbH
    • Method Detail

      • fileExtension

        String fileExtension()
        Gets the file extension, i.e. the part of the file name after the last '.'. Returns empty for directories.
        Returns:
        The file extension.
      • fileName

        String fileName()
        Gets the last file part of the path, i.e. the file name or directory name.
        Returns:
        The last file part.
      • isAnyParentOf

        boolean isAnyParentOf​(IFileSystemEntry<?> other)
        Checks whether this file system entry is a direct or indirect parent of the given file system entry, i.e. whether this file system entry is a directory and the given file system entry is inside that directory.
        Parameters:
        other - The other file system entry.
        Returns:
        true if this file system entry is a direct or indirect parent of the given file system entry, false otherwise.
      • isDirectory

        boolean isDirectory()
        Whether this file system entry represents a directory.
        Returns:
        true if this file system entry represents a directory, false otherwise.
      • isImmediateParentOf

        boolean isImmediateParentOf​(IFileSystemEntry<?> other)
        Checks whether this file system entry is an immediate parent of the given file system entry, i.e. whether this file system entry is a directory and the given file system entry is directly inside that directory.
        Parameters:
        other - The other file system entry.
        Returns:
        true if this file system entry is an immediate parent of the given file system entry, false otherwise.
      • isVolumeRoot

        boolean isVolumeRoot()
        Whether this file system entry represents the root (top-level directory) of the file system volume. A volume directory is for example a Windows drive or the root of a network share such as FTP.

        Note that parent() will return null for a volume root, and a non-null value for any other directory.

        Returns:
        true if this file system entry represents the root directory, false otherwise.
      • parent

        Entry parent()
        Gets the file system entry representing the parent directory of this file system entry. Will return null if this file system entry represents the volume root.
        Returns:
        The parent file system entry, or null if this file system entry does not have a parent directory.
      • parents

        Iterable<Entry> parents()
        Gets all file system entries representing the parent directories of this file system entry. The entries are returned in the order parent, grandparent, great-grandparent etc. This entry is not included in the result. If this file system entry does not have any parent directories, returns an empty iterable.
        Returns:
        The parent file system entries, or empty if this file system entry does not have any parent directories.
      • path

        String path()
        Gets the path of this file system entry, which is the concatenation of all path parts separated by the path separator. Returns empty for the root directory. Does not include the volume.
        Returns:
        The file path.
      • pathParts

        String[] pathParts()
        Gets the path parts of this file system entry, i.e. the directory names and the file name.
        Returns:
        The path parts.
      • relativeTo

        Entry relativeTo​(Entry target)
        Makes this entry relative to the given target. I.e. remove the path parts of the target from the path parts of this entry. If this entry is not a sub-path of the target, returns this entry unchanged.
        Parameters:
        target - The target to make this entry relative to.
        Returns:
        The relativized entry.
      • resolve

        Entry resolve​(String child)
        Adds the given child to the list of path parts and returns a new file key representing the resulting path.
        Parameters:
        child - The child path to add. May contain slashes.
        Returns:
        The new file key.
      • resolve

        Entry resolve​(String... children)
        Adds the given children to the list of path parts and returns a new file key representing the resulting path.
        Parameters:
        children - The child paths to add. May contain slashes.
        Returns:
        The new file key.
      • resolve

        Entry resolve​(Entry entry)
        Adds the given children to the list of path parts and returns a new file key representing the resulting path.
        Parameters:
        entry - The child paths to add. May contain slashes.
        Returns:
        The new file key.
      • unwrap

        <FileSystemEntry> FileSystemEntry unwrap​(Class<? extends FileSystemEntry> type)
        Unwraps this file system entry to the given type. If this file system entry is an instance of the given type, it is returned. Otherwise, potential wrappers are unwrapped until the given type is reached. If the file system entry cannot be unwrapped to the given type, null is returned.

        If multiple wrappers are present, the first one that can be unwrapped to the given type is returned.

        Type Parameters:
        FileSystemEntry - The type of the desired file system entry.
        Parameters:
        type - The type to unwrap to.
        Returns:
        The unwrapped file system entry, or null if the file system entry cannot be unwrapped to the given type.
      • volume

        String volume()
        Gets the volume of this file system entry.
        Returns:
        The name of this entry's volume.
      • comparatorVolumeThenLengthThenNameFor

        static <E extends IFileSystemEntry<E>> Comparator<E> comparatorVolumeThenLengthThenNameFor​(Locale locale)
        Gets a comparator for file system entries. The file paths are compared by volume first, then by length, and finally by name, using the given locale for comparing file names.
        Type Parameters:
        E - The type of the file system entry.
        Parameters:
        locale - The locale to use for comparing file paths.
        Returns:
        A comparator for client file keys.
      • compareVolumeThenLengthThenName

        static int compareVolumeThenLengthThenName​(IFileSystemEntry<?> o1,
                                                   IFileSystemEntry<?> o2,
                                                   Collator collator)
        Compares file system entries. The file paths are compared by volume first, then by length, and finally by name, using the given locale for comparing file names.
        Parameters:
        o1 - The first file system entry.
        o2 - The second file system entry.
        collator - The collator to use for comparing file names.
        Returns:
        A comparator for client file keys.