Class FormThemeFileEntry

java.lang.Object
de.xima.fc.gui.model.form_theme.FormThemeFileEntry
All Implemented Interfaces:
IFileSystemEntry<FormThemeFileEntry>, Serializable, Comparable<FormThemeFileEntry>

public final class FormThemeFileEntry extends Object implements IFileSystemEntry<FormThemeFileEntry>
An IFileSystemEntry implementation for client form theme files. The file path is a combination of resource context, followed by the file name.

The file name may have slashes. Everything before the final slash is treated as a directory. The last file part is treated a file if it has any file extension (i.e. a dot followed by at least one character). Otherwise, it is treated as a directory.

Since:
8.3.0
Author:
XIMA MEDIA GmbH
See Also:
  • Field Details

  • Method Details

    • compareTo

      public int compareTo(FormThemeFileEntry o)
      Specified by:
      compareTo in interface Comparable<FormThemeFileEntry>
    • context

      public String context()
      Gets the ClientFormThemeFile.getResourceContext() resource context of this file key, i.e. the first path part. Returns empty for the root directory.
      Returns:
      The resource context.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • fileExtension

      public String fileExtension()
      Description copied from interface: IFileSystemEntry
      Gets the file extension, i.e. the part of the file name after the last '.'. Returns empty for directories.
      Specified by:
      fileExtension in interface IFileSystemEntry<FormThemeFileEntry>
      Returns:
      The file extension.
    • fileName

      public String fileName()
      Description copied from interface: IFileSystemEntry
      Gets the last file part of the path, i.e. the file name or directory name.
      Specified by:
      fileName in interface IFileSystemEntry<FormThemeFileEntry>
      Returns:
      The last file part.
    • filePath

      public String filePath()
      Gets the file path after the context(), i.e. all path parts other than the first.
      Returns:
      The file path.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • isAnyParentOf

      public boolean isAnyParentOf(IFileSystemEntry<?> other)
      Description copied from interface: IFileSystemEntry
      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.
      Specified by:
      isAnyParentOf in interface IFileSystemEntry<FormThemeFileEntry>
      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

      public boolean isDirectory()
      Description copied from interface: IFileSystemEntry
      Whether this file system entry represents a directory.
      Specified by:
      isDirectory in interface IFileSystemEntry<FormThemeFileEntry>
      Returns:
      true if this file system entry represents a directory, false otherwise.
    • isImmediateParentOf

      public boolean isImmediateParentOf(IFileSystemEntry<?> other)
      Description copied from interface: IFileSystemEntry
      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.
      Specified by:
      isImmediateParentOf in interface IFileSystemEntry<FormThemeFileEntry>
      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.
    • isVolumeGroup

      public boolean isVolumeGroup()
      Whether this entry represents the volume group that is used to group all client form themes.
      Returns:
      True if this entry represents the volume group.
    • isVolumeRoot

      public boolean isVolumeRoot()
      Description copied from interface: IFileSystemEntry
      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 IFileSystemEntry.parent() will return null for a volume root, and a non-null value for any other directory.

      Specified by:
      isVolumeRoot in interface IFileSystemEntry<FormThemeFileEntry>
      Returns:
      true if this file system entry represents the root directory, false otherwise.
    • parent

      public FormThemeFileEntry parent()
      Description copied from interface: IFileSystemEntry
      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.
      Specified by:
      parent in interface IFileSystemEntry<FormThemeFileEntry>
      Returns:
      The parent file system entry, or null if this file system entry does not have a parent directory.
    • parents

      public Iterable<FormThemeFileEntry> parents()
      Description copied from interface: IFileSystemEntry
      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.
      Specified by:
      parents in interface IFileSystemEntry<FormThemeFileEntry>
      Returns:
      The parent file system entries, or empty if this file system entry does not have any parent directories.
    • path

      public String path()
      Description copied from interface: IFileSystemEntry
      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.
      Specified by:
      path in interface IFileSystemEntry<FormThemeFileEntry>
      Returns:
      The file path.
    • pathParts

      public String[] pathParts()
      Description copied from interface: IFileSystemEntry
      Gets the path parts of this file system entry, i.e. the directory names and the file name.
      Specified by:
      pathParts in interface IFileSystemEntry<FormThemeFileEntry>
      Returns:
      The path parts.
    • relativeTo

      public FormThemeFileEntry relativeTo(FormThemeFileEntry target)
      Description copied from interface: IFileSystemEntry
      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.
      Specified by:
      relativeTo in interface IFileSystemEntry<FormThemeFileEntry>
      Parameters:
      target - The target to make this entry relative to.
      Returns:
      The relativized entry.
    • resolve

      public FormThemeFileEntry resolve(String child)
      Description copied from interface: IFileSystemEntry
      Adds the given child to the list of path parts and returns a new file key representing the resulting path.
      Specified by:
      resolve in interface IFileSystemEntry<FormThemeFileEntry>
      Parameters:
      child - The child path to add. May contain slashes.
      Returns:
      The new file key.
    • resolve

      public FormThemeFileEntry resolve(String... children)
      Description copied from interface: IFileSystemEntry
      Adds the given children to the list of path parts and returns a new file key representing the resulting path.
      Specified by:
      resolve in interface IFileSystemEntry<FormThemeFileEntry>
      Parameters:
      children - The child paths to add. May contain slashes.
      Returns:
      The new file key.
    • resolve

      public FormThemeFileEntry resolve(FormThemeFileEntry entry)
      Description copied from interface: IFileSystemEntry
      Adds the given children to the list of path parts and returns a new file key representing the resulting path.
      Specified by:
      resolve in interface IFileSystemEntry<FormThemeFileEntry>
      Parameters:
      entry - The child paths to add. May contain slashes.
      Returns:
      The new file key.
    • themeUuid

      public UUID themeUuid()
      Gets the UUID of the client form theme from the volume.
      Returns:
      The UUID of the client form theme.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • unwrap

      public <FileSystemEntry> FileSystemEntry unwrap(Class<? extends FileSystemEntry> type)
      Description copied from interface: IFileSystemEntry
      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.

      Specified by:
      unwrap in interface IFileSystemEntry<FormThemeFileEntry>
      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

      public String volume()
      Description copied from interface: IFileSystemEntry
      Gets the volume of this file system entry.
      Specified by:
      volume in interface IFileSystemEntry<FormThemeFileEntry>
      Returns:
      The name of this entry's volume.
    • ofClientFormThemeFile

      public static FormThemeFileEntry ofClientFormThemeFile(ClientFormThemeFile file)
      Creates a file key for the given client form theme file.
      Parameters:
      file - The client form theme file.
      Returns:
      The file key, or null if the file is null.
    • ofClientFormThemeFile

      public static FormThemeFileEntry ofClientFormThemeFile(ClientFormTheme theme, String context, String filePath)
      Creates a file key for the given resource context and file path.
      Parameters:
      theme - The form theme representing the file system volume.
      context - The resource context.
      filePath - The file path.
      Returns:
      The file key.
    • ofClientFormThemeFile

      public static FormThemeFileEntry ofClientFormThemeFile(UUID themeUuid, String context, String filePath)
      Creates a file key for the given resource context and file path.
      Parameters:
      themeUuid - The UUID of the form theme representing the file system volume.
      context - The resource context.
      filePath - The file path.
      Returns:
      The file key.
    • ofVolumeAndPath

      public static FormThemeFileEntry ofVolumeAndPath(ClientFormTheme theme, String path)
      Creates a file key for the given volume and path. The volume must be a valid UUID.
      Parameters:
      theme - The theme representing the volume.
      path - The path.
      Returns:
      The file key.
      Throws:
      IllegalArgumentException - If the volume is not the default volume ID.
    • ofVolumeAndPath

      public static FormThemeFileEntry ofVolumeAndPath(String volume, String path)
      Creates a file key for the given volume and path. The volume must be a valid UUID.
      Parameters:
      volume - The volume.
      path - The path.
      Returns:
      The file key.
      Throws:
      IllegalArgumentException - If the volume is not the default volume ID.
    • root

      public static FormThemeFileEntry root(ClientFormTheme theme)
      Get the root file key for the volume represented by the given client form theme.
      Parameters:
      theme - The client form theme representing the root.
      Returns:
      The root file key.
    • root

      public static FormThemeFileEntry root(UUID themeUuid)
      Get the root file key for the volume represented by the given client form theme UUID.
      Parameters:
      themeUuid - The UUID of the client form theme representing the root.
      Returns:
      The root file key.
    • themeToVolumeId

      public static String themeToVolumeId(ClientFormTheme theme)
      Gets the volume ID for the given client form theme.
      Parameters:
      theme - The client form theme.
      Returns:
      The volume ID.
    • themeUuidToVolumeId

      public static String themeUuidToVolumeId(UUID themeUuid)
      Gets the volume ID for the client form theme wit the given UUID.
      Parameters:
      themeUuid - The UUID of a client form theme.
      Returns:
      The volume ID.
    • volumeGroup

      public static FormThemeFileEntry volumeGroup()
      Gets the file entry representing the volume group that is used to group all client form themes.
      Returns:
      The file entry representing the volume group.
    • volumeIdToThemeUuid

      public static UUID volumeIdToThemeUuid(String volumeId)
      Converts a volume ID to a theme UUID. This is the inverse of themeToVolumeId(ClientFormTheme).
      Parameters:
      volumeId - The volume ID.
      Returns:
      The theme UUID, or null if the volume ID is not a valid volume ID.