Package lumis.portal.filesystem
Class PortalFilePath
- java.lang.Object
-
- lumis.portal.filesystem.PortalFilePath
-
- All Implemented Interfaces:
java.io.Serializable
@StableMinor(version="16.1", 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 aPortalBaseFolder
and a relative path to that folder.- Since:
- 4.1.0
- Version:
- $Revision: 26156 $ $Date: 2024-01-13 10:26:46 -0300 (Sat, 13 Jan 2024) $
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description PortalFilePath(java.lang.String absolutePath)
Creates a portal file path from an absolute path.PortalFilePath(IPortalBaseFolder baseFolder, java.lang.String relativePath)
Creates a portal file path from a base folder and a relative path.PortalFilePath(PortalBaseFolder baseFolder, java.lang.String relativePath)
Creates a portal file path from a base folder and a relative path.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description boolean
equals(java.lang.Object obj)
java.lang.String
getAbsolutePath()
Deprecated.since 8.0.0 it is not recommended to be used anymore due to the filesystem abstraction layer.PortalBaseFolder
getBaseFolder()
Deprecated.Since 6.2.0 replaced bygetPortalBaseFolder()
due to the deprecation ofPortalBaseFolder.WWW
.java.lang.String
getName()
Returns the name of this PortalFilePath or an emptyString
if this PortalFilePath is the root of base folder.PortalFilePath
getParent()
Returns the parent PortalFilePath ornull
if this is already the root of base folder.IPortalBaseFolder
getPortalBaseFolder()
Returns the base folder for this path.java.lang.String
getRelativePath()
Returns the relative path togetBaseFolder()
.PortalFilePath
getRoot()
Returns the root of this path.int
hashCode()
boolean
isDescendentOf(PortalFilePath path)
Returns whether the given PortalFilePath is descendent of this.boolean
isRoot()
Returns whether this PortalFilePath is the root of base folder.java.lang.String
relativize(PortalFilePath other)
Relativizes the given path against this one.PortalFilePath
resolve(java.lang.String path)
Resolves the given path against this PortalFilePath.
Thepath
must not be an absolute path.IFile
toFile()
Returns anIFile
constructed with this PortalFilePath.java.lang.String
toString()
-
-
-
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 theIFile
interface, that can be obtained fromIFileSystemManager.getFile(PortalFilePath)
. The direct usage of Java file API can produce unpredictable portal behavior. The newfilesystem
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 togetBaseFolder()
.- Returns:
- the relative path relative to the base folder.
- Since:
- 4.1.0
-
getBaseFolder
@Deprecated public PortalBaseFolder getBaseFolder()
Deprecated.Since 6.2.0 replaced bygetPortalBaseFolder()
due to the deprecation ofPortalBaseFolder.WWW
. This deprecated implementation works if thisPortalFilePath
is based on one of the enumPortalBaseFolder
options, otherwise it throws aClassCastException
. 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 classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
resolve
public PortalFilePath resolve(java.lang.String path)
Resolves the given path against this PortalFilePath.
Thepath
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 examplemy/folder/../file.txt
will becomemy/file.txt
).- Parameters:
path
- the relative path to be resolved.- Returns:
- the resolved PortalFilePath.
- Throws:
java.lang.IllegalArgumentException
- ifpath
isnull
or it starts with a/
.- Since:
- 8.0.0
-
getParent
public PortalFilePath getParent()
Returns the parent PortalFilePath ornull
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 emptyString
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
-
toFile
public IFile toFile()
Returns anIFile
constructed with this PortalFilePath.- Returns:
- an
IFile
constructed with this PortalFilePath. - Since:
- 8.0.0
- See Also:
IFileSystem.getFile(PortalFilePath)
,IFileSystemManager.getFile(PortalFilePath)
-
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 ornull
if the given path couldn't be relativized. The given path can only be relativized against this one if itis 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
-
-