Package io.delta.kernel.internal.fs
Class Path
Object
io.delta.kernel.internal.fs.Path
- All Implemented Interfaces:
ObjectInputValidation,Serializable,Comparable<Path>
Names a file or directory in a FileSystem.
Path strings use slash as the directory separator.
Taken from https://github.com/apache/hadoop/blob/branch-3.3 .4/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/Path.java
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreate a new Path based on the child path resolved against the parent path.Create a new Path based on the child path resolved against the parent path.Construct a path from a String.Create a new Path based on the child path resolved against the parent path.Create a new Path based on the child path resolved against the parent path.Construct a Path from components.Construct a path from a URI -
Method Summary
Modifier and TypeMethodDescriptionintintdepth()Returns the number of elements in this path.booleangetName()Returns the final component of this path.static StringReturns the parent of a path or null if at root.static PathReturn a version of the given Path without the scheme information.inthashCode()booleanReturns true if the path component (i.e.booleanReturns true if the path component (i.e.booleanisRoot()Returns true if and only if this path represents the root of a file system.booleanReturns true if the path component (i.e.static booleanisWindowsAbsolutePath(String pathString, boolean slashed) Determine whether a given path string represents an absolute path on Windows.makeQualified(URI defaultUri, Path workingDir) Returns a qualified path object.static PathmergePaths(Path path1, Path path2) Merge 2 paths such that the second path is appended relative to the first.Adds a suffix to the final name in the path.toString()toUri()Convert this Path to a URI.voidValidate the contents of a deserialized Path, so as to defend against malicious object streams.
-
Field Details
-
SEPARATOR
The directory separator, a slash.- See Also:
-
SEPARATOR_CHAR
public static final char SEPARATOR_CHARThe directory separator, a slash, as a character.- See Also:
-
CUR_DIR
The current directory, ".".- See Also:
-
WINDOWS
public static final boolean WINDOWSWhether the current host is a Windows machine.
-
-
Constructor Details
-
Path
Create a new Path based on the child path resolved against the parent path.- Parameters:
parent- the parent pathchild- the child path
-
Path
Create a new Path based on the child path resolved against the parent path.- Parameters:
parent- the parent pathchild- the child path
-
Path
Create a new Path based on the child path resolved against the parent path.- Parameters:
parent- the parent pathchild- the child path
-
Path
Create a new Path based on the child path resolved against the parent path.- Parameters:
parent- the parent pathchild- the child path
-
Path
Construct a path from a String. Path strings are URIs, but with unescaped elements and some additional normalization.- Parameters:
pathString- the path string- Throws:
IllegalArgumentException
-
Path
Construct a path from a URI- Parameters:
aUri- the source URI
-
Path
Construct a Path from components.- Parameters:
scheme- the schemeauthority- the authoritypath- the path
-
-
Method Details
-
getPathWithoutSchemeAndAuthority
Return a version of the given Path without the scheme information.- Parameters:
path- the source Path- Returns:
- a copy of this Path without the scheme information
-
mergePaths
Merge 2 paths such that the second path is appended relative to the first. The returned path has the scheme and authority of the first path. On Windows, the drive specification in the second path is discarded.- Parameters:
path1- the first pathpath2- the second path, to be appended relative to path1- Returns:
- the merged path
-
isWindowsAbsolutePath
Determine whether a given path string represents an absolute path on Windows. e.g. "C:/a/b" is an absolute path. "C:a/b" is not.- Parameters:
pathString- the path string to evaluateslashed- true if the given path is prefixed with "/"- Returns:
- true if the supplied path looks like an absolute path with a Windows drive-specifier
-
toUri
Convert this Path to a URI.- Returns:
- this Path as a URI
-
isAbsoluteAndSchemeAuthorityNull
public boolean isAbsoluteAndSchemeAuthorityNull()Returns true if the path component (i.e. directory) of this URI is absolute and the scheme is null, and the authority is null.- Returns:
- whether the path is absolute and the URI has no scheme nor authority parts
-
isUriPathAbsolute
public boolean isUriPathAbsolute()Returns true if the path component (i.e. directory) of this URI is absolute.- Returns:
- whether this URI's path is absolute
-
isAbsolute
public boolean isAbsolute()Returns true if the path component (i.e. directory) of this URI is absolute. This method is a wrapper forisUriPathAbsolute().- Returns:
- whether this URI's path is absolute
-
isRoot
public boolean isRoot()Returns true if and only if this path represents the root of a file system.- Returns:
- true if and only if this path represents the root of a file system
-
getName
Returns the final component of this path.- Returns:
- the final component of this path
-
getParent
Returns the parent of a path or null if at root.- Returns:
- the parent of a path or null if at root
-
suffix
Adds a suffix to the final name in the path.- Parameters:
suffix- the suffix to add- Returns:
- a new path with the suffix added
-
toString
-
equals
-
hashCode
public int hashCode() -
compareTo
- Specified by:
compareToin interfaceComparable<Path>
-
depth
public int depth()Returns the number of elements in this path.- Returns:
- the number of elements in this path
-
makeQualified
Returns a qualified path object.- Parameters:
defaultUri- if this path is missing the scheme or authority components, borrow them from this URIworkingDir- if this path isn't absolute, treat it as relative to this working directory- Returns:
- this path if it contains a scheme and authority and is absolute, or a new path that includes a path and authority and is fully qualified
-
validateObject
Validate the contents of a deserialized Path, so as to defend against malicious object streams.- Specified by:
validateObjectin interfaceObjectInputValidation- Throws:
InvalidObjectException- if there's no URI
-
getName
-