Class PortalFilePath

  • All Implemented Interfaces:
    java.io.Serializable

    @StableMinor(version="16.0",
                 sinceVersion="4.1")
    public final class PortalFilePath
    extends java.lang.Object
    implements java.io.Serializable
    Represents a path to a portal file. It is internally stored as a PortalBaseFolder and a relative path to that folder.
    Since:
    4.1.0
    Version:
    $Revision: 25808 $ $Date: 2023-07-04 15:20:55 -0300 (Tue, 04 Jul 2023) $
    See Also:
    Serialized Form
    • Constructor Detail

      • PortalFilePath

        public PortalFilePath​(PortalBaseFolder baseFolder,
                              java.lang.String relativePath)
        Creates a portal file path from a base folder and a relative path.

        This constructor is equivalent to PortalFilePath(IPortalBaseFolder, String), but is kept for binary backwards compatibility.

        Parameters:
        baseFolder - the base folder.
        relativePath - the relative path, relative to the base folder.
        Since:
        4.1.0
      • PortalFilePath

        public PortalFilePath​(IPortalBaseFolder baseFolder,
                              java.lang.String relativePath)
        Creates a portal file path from a base folder and a relative path.
        Parameters:
        baseFolder - the base folder.
        relativePath - the relative path, relative to the base folder.
        Throws:
        java.lang.IllegalArgumentException - if a PortalFilePath could not be created due to invalid argument values.
        Since:
        6.2.0
      • PortalFilePath

        public PortalFilePath​(java.lang.String absolutePath)
        Creates a portal file path from an absolute path.
        Parameters:
        absolutePath - the absolute path.
        Throws:
        java.lang.IllegalArgumentException - if the given absolute path is invalid or does not belongs to an area that may be mapped using a portal file path.
        Since:
        4.1.0
    • Method Detail

      • getAbsolutePath

        @Deprecated
        public java.lang.String getAbsolutePath()
        Deprecated.
        since 8.0.0 it is not recommended to be used anymore due to the filesystem abstraction layer. Every file operation should use the IFile interface, that can be obtained from IFileSystemManager.getFile(PortalFilePath). The direct usage of Java file API can produce unpredictable portal behavior. The new filesystem API is highly recommended to be used instead.
        Returns the absolute path this instance corresponds to.
        Returns:
        the absolute path this instance corresponds to.
        Since:
        4.1.0
      • getRelativePath

        public java.lang.String getRelativePath()
        Returns the relative path to getBaseFolder().
        Returns:
        the relative path relative to the base folder.
        Since:
        4.1.0
      • getBaseFolder

        @Deprecated
        public PortalBaseFolder getBaseFolder()
        Deprecated.
        Since 6.2.0 replaced by getPortalBaseFolder() due to the deprecation of PortalBaseFolder.WWW. This deprecated implementation works if this PortalFilePath is based on one of the enum PortalBaseFolder options, otherwise it throws a ClassCastException. This works on a full legacy code, since only the those enum options exist in such case.
        Returns the base folder for this path.
        Returns:
        the base folder for this path.
        Since:
        4.1.0
      • getPortalBaseFolder

        public IPortalBaseFolder getPortalBaseFolder()
        Returns the base folder for this path.
        Returns:
        the base folder for this path.
        Since:
        6.2.0
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • resolve

        public PortalFilePath resolve​(java.lang.String path)
        Resolves the given path against this PortalFilePath.
        The path must not be an absolute path. In other words, it cannot begin with a / .

        The path is composed by elements separated by /. The resolve process consists in create a new portal file path using this path's relative path concatenated with a / and the given relative path. If the given relative path contains an element .. it means this .. and the previous element will be eliminated (for example my/folder/../file.txt will become my/file.txt).

        Parameters:
        path - the relative path to be resolved.
        Returns:
        the resolved PortalFilePath.
        Throws:
        java.lang.IllegalArgumentException - if path is null or it starts with a /.
        Since:
        8.0.0
      • getParent

        public PortalFilePath getParent()
        Returns the parent PortalFilePath or null if this is already the root of base folder.
        Returns:
        the parent PortalFilePath or null if this is already the root of base folder.
        Since:
        8.0.0
      • getName

        public java.lang.String getName()
        Returns the name of this PortalFilePath or an empty String if this PortalFilePath is the root of base folder. The name is the last part of the path sequence.
        Returns:
        the name of this PortalFilePath or an empty String if this PortalFilePath is the root of base
        Since:
        8.0.0
      • isRoot

        public boolean isRoot()
        Returns whether this PortalFilePath is the root of base folder.
        Returns:
        whether this PortalFilePath is the root of base folder.
        Since:
        8.0.0
      • isDescendentOf

        public boolean isDescendentOf​(PortalFilePath path)
        Returns whether the given PortalFilePath is descendent of this.
        Parameters:
        path - the path to be tested.
        Returns:
        whether the given PortalFilePath is descendent of this.
        Since:
        8.0.0
      • relativize

        public java.lang.String relativize​(PortalFilePath other)
        Relativizes the given path against this one. Returns the relativized path or null if the given path couldn't be relativized. The given path can only be relativized against this one if it is descendent of this path.
        Parameters:
        other - the path to be relativized
        Returns:
        the relativized path or null if it couldn't be relativized.
        Since:
        8.0.0
        See Also:
        relativize(PortalFilePath)
      • getRoot

        public PortalFilePath getRoot()
        Returns the root of this path.
        Returns:
        the root of this path.
        Since:
        8.0.0