Package de.xima.fc.gui.model.form_theme
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>
AnIFileSystemEntry
implementation forclient form theme files
. Thefile path
is a combination ofresource context
, followed by thefile 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:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static String
VOLUME_CLIENT_FORM_THEME_GROUP
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compareTo(FormThemeFileEntry o)
String
context()
Gets theClientFormThemeFile.getResourceContext()
resource context of this file key, i.e.boolean
equals(Object o)
String
fileExtension()
Gets the file extension, i.e.String
fileName()
Gets the last file part of the path, i.e.String
filePath()
Gets the file path after thecontext()
, i.e.int
hashCode()
boolean
isAnyParentOf(IFileSystemEntry<?> other)
Checks whether this file system entry is a direct or indirect parent of the given file system entry, i.e.boolean
isDirectory()
Whether this file system entry represents a directory.boolean
isImmediateParentOf(IFileSystemEntry<?> other)
Checks whether this file system entry is an immediate parent of the given file system entry, i.e.boolean
isVolumeGroup()
Whether this entry represents the volume group that is used to group all client form themes.boolean
isVolumeRoot()
Whether this file system entry represents the root (top-level directory) of the file system volume.static FormThemeFileEntry
ofClientFormThemeFile(ClientFormThemeFile file)
Creates a file key for the given client form theme file.static FormThemeFileEntry
ofClientFormThemeFile(ClientFormTheme theme, String context, String filePath)
Creates a file key for the givenresource context
andfile path
.static FormThemeFileEntry
ofClientFormThemeFile(UUID themeUuid, String context, String filePath)
Creates a file key for the givenresource context
andfile path
.static FormThemeFileEntry
ofVolumeAndPath(ClientFormTheme theme, String path)
Creates a file key for the given volume and path.static FormThemeFileEntry
ofVolumeAndPath(String volume, String path)
Creates a file key for the given volume and path.FormThemeFileEntry
parent()
Gets the file system entry representing the parent directory of this file system entry.Iterable<FormThemeFileEntry>
parents()
Gets all file system entries representing the parent directories of this file system entry.String
path()
Gets the path of this file system entry, which is the concatenation of all path parts separated by the path separator.String[]
pathParts()
Gets the path parts of this file system entry, i.e.FormThemeFileEntry
relativeTo(FormThemeFileEntry target)
Makes this entry relative to the given target.FormThemeFileEntry
resolve(FormThemeFileEntry entry)
Adds the given children to the list of path parts and returns a new file key representing the resulting path.FormThemeFileEntry
resolve(String child)
Adds the given child to the list of path parts and returns a new file key representing the resulting path.FormThemeFileEntry
resolve(String... children)
Adds the given children to the list of path parts and returns a new file key representing the resulting path.static FormThemeFileEntry
root(ClientFormTheme theme)
Get theroot
file key for the volume represented by the given client form theme.static FormThemeFileEntry
root(UUID themeUuid)
Get theroot
file key for the volume represented by the given client form theme UUID.static String
themeToVolumeId(ClientFormTheme theme)
Gets the volume ID for the given client form theme.UUID
themeUuid()
Gets the UUID of the client form theme from thevolume
.static String
themeUuidToVolumeId(UUID themeUuid)
Gets the volume ID for the client form theme wit the given UUID.String
toString()
<FileSystemEntry>
FileSystemEntryunwrap(Class<? extends FileSystemEntry> type)
Unwraps this file system entry to the given type.String
volume()
Gets the volume of this file system entry.static FormThemeFileEntry
volumeGroup()
Gets the file entry representing the volume group that is used to group all client form themes.static UUID
volumeIdToThemeUuid(String volumeId)
Converts a volume ID to a theme UUID.
-
-
-
Field Detail
-
VOLUME_CLIENT_FORM_THEME_GROUP
public static final String VOLUME_CLIENT_FORM_THEME_GROUP
- See Also:
- Constant Field Values
-
-
Method Detail
-
compareTo
public int compareTo(FormThemeFileEntry o)
- Specified by:
compareTo
in interfaceComparable<FormThemeFileEntry>
-
context
public String context()
Gets theClientFormThemeFile.getResourceContext()
resource context of this file key, i.e. the first path part. Returns empty for the root directory.- Returns:
- The resource context.
-
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 interfaceIFileSystemEntry<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 interfaceIFileSystemEntry<FormThemeFileEntry>
- Returns:
- The last file part.
-
filePath
public String filePath()
Gets the file path after thecontext()
, i.e. all path parts other than the first.- Returns:
- The file path.
-
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 interfaceIFileSystemEntry<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 interfaceIFileSystemEntry<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 interfaceIFileSystemEntry<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 interfaceIFileSystemEntry<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 thevolume root
.- Specified by:
parent
in interfaceIFileSystemEntry<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 interfaceIFileSystemEntry<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 interfaceIFileSystemEntry<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 interfaceIFileSystemEntry<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 interfaceIFileSystemEntry<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 interfaceIFileSystemEntry<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 interfaceIFileSystemEntry<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 interfaceIFileSystemEntry<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 thevolume
.- Returns:
- The UUID of the client form theme.
-
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 interfaceIFileSystemEntry<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 interfaceIFileSystemEntry<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 givenresource context
andfile 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 givenresource context
andfile 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 theroot
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 theroot
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 ofthemeToVolumeId(ClientFormTheme)
.- Parameters:
volumeId
- The volume ID.- Returns:
- The theme UUID, or null if the volume ID is not a valid volume ID.
-
-