@PublicApi @ThreadSafe public final class AlluxioURI extends Object implements Comparable<AlluxioURI>, Serializable
AlluxioURI
can represent
resources in the Alluxio namespace, as well as UFS namespaces.
AlluxioURI
supports more than just strict URI
. Some examples:
* Windows paths
* C:\
* D:\path\to\file
* E:\path\to\skip\..\file
* URI with multiple scheme components
* scheme://host:123/path
* scheme:part2//host:123/path
* scheme:part2://host:123/path
* scheme:part2:part3//host:123/path
* scheme:part2:part3://host:123/path
Does not support fragment in the URI.Modifier and Type | Field and Description |
---|---|
static String |
CUR_DIR |
static AlluxioURI |
EMPTY_URI |
static String |
SEPARATOR |
static String |
WILDCARD |
Constructor and Description |
---|
AlluxioURI(AlluxioURI parent,
AlluxioURI child)
Resolves a child
AlluxioURI against a parent AlluxioURI . |
AlluxioURI(AlluxioURI baseURI,
String newPath,
boolean checkNormalization)
Constructs an
AlluxioURI from a base URI and a new path component. |
AlluxioURI(String pathStr)
Constructs an
AlluxioURI from a String. |
AlluxioURI(String scheme,
Authority authority,
String path)
Constructs an
AlluxioURI from components. |
AlluxioURI(String scheme,
Authority authority,
String path,
Map<String,String> queryMap)
Constructs an
AlluxioURI from components. |
Modifier and Type | Method and Description |
---|---|
int |
compareTo(AlluxioURI other) |
boolean |
containsWildcard()
Whether or not the
AlluxioURI contains wildcard(s). |
boolean |
equals(Object o) |
Authority |
getAuthority() |
int |
getDepth()
Returns the number of elements of the path component of the
AlluxioURI . |
String |
getLeadingPath(int n)
Gets the first n components of the
AlluxioURI path. |
String |
getName()
Gets the final component of the
AlluxioURI . |
AlluxioURI |
getParent()
Get the parent of this
AlluxioURI or null if at root. |
String |
getPath()
Gets the path component of the
AlluxioURI . |
Map<String,String> |
getQueryMap()
Gets the map of query parameters.
|
String |
getRootPath() |
String |
getScheme()
Gets the scheme of the
AlluxioURI . |
boolean |
hasAuthority()
Tells if the
AlluxioURI has authority or not. |
int |
hashCode() |
boolean |
hasScheme()
Tells if this
AlluxioURI has scheme or not. |
static boolean |
hasWindowsDrive(String path,
boolean slashed)
Checks if the path is a windows path.
|
boolean |
isAbsolute()
Tells whether or not the
AlluxioURI is absolute. |
boolean |
isAncestorOf(AlluxioURI alluxioURI)
Returns true if the current AlluxioURI is an ancestor of another AlluxioURI.
|
boolean |
isPathAbsolute()
Tells whether or not the path component of the
AlluxioURI is absolute. |
boolean |
isRoot()
Tells whether or not the
AlluxioURI is root. |
AlluxioURI |
join(AlluxioURI suffix)
Append additional path elements to the end of an
AlluxioURI . |
AlluxioURI |
join(String suffix)
Append additional path elements to the end of an
AlluxioURI . |
AlluxioURI |
joinUnsafe(String suffix)
Append additional path elements to the end of an
AlluxioURI . |
static String |
normalizePath(String path)
Normalize the path component of the
AlluxioURI , by replacing all "//" and "\\" with
"/", and trimming trailing slash from non-root path (ignoring windows drive). |
String |
toString()
Illegal characters unescaped in the string, for glob processing, etc.
|
public static final String SEPARATOR
public static final String CUR_DIR
public static final String WILDCARD
public static final AlluxioURI EMPTY_URI
public AlluxioURI(String pathStr)
AlluxioURI
from a String. Path strings are URIs, but with unescaped
elements and some additional normalization.pathStr
- path to construct the AlluxioURI
frompublic AlluxioURI(String scheme, Authority authority, String path)
AlluxioURI
from components.scheme
- the scheme of the path. e.g. alluxio, hdfs, s3, file, null, etcauthority
- the authority of the pathpath
- the path component of the URI. e.g. /abc/c.txt, /a b/c/c.txtpublic AlluxioURI(String scheme, Authority authority, String path, Map<String,String> queryMap)
AlluxioURI
from components.scheme
- the scheme of the path. e.g. alluxio, hdfs, s3, file, null, etcauthority
- the authority of the pathpath
- the path component of the URI. e.g. /abc/c.txt, /a b/c/c.txtqueryMap
- the (nullable) map of key/value pairs for the query component of the URIpublic AlluxioURI(AlluxioURI parent, AlluxioURI child)
AlluxioURI
against a parent AlluxioURI
.parent
- the parentchild
- the childpublic AlluxioURI(AlluxioURI baseURI, String newPath, boolean checkNormalization)
AlluxioURI
from a base URI and a new path component.baseURI
- the base urinewPath
- the new path componentcheckNormalization
- if true, will check if the path requires normalizationpublic int compareTo(AlluxioURI other)
compareTo
in interface Comparable<AlluxioURI>
public Authority getAuthority()
AlluxioURI
public int getDepth()
AlluxioURI
.
/ = 0 . = 0 /a = 1 /a/b/c.txt = 3 /a/b/ = 3 a/b = 2 a\b = 2 alluxio://localhost:19998/ = 0 alluxio://localhost:19998/a = 1 alluxio://localhost:19998/a/b.txt = 2 C:\a = 1 C: = 0
@Nullable public String getLeadingPath(int n)
AlluxioURI
path. There is no trailing separator as
the path will be normalized by normalizePath().
/a/b/c, 0 = / /a/b/c, 1 = /a /a/b/c, 2 = /a/b /a/b/c, 3 = /a/b/c /a/b/c, 4 = null
n
- identifies the number of path components to getpublic boolean containsWildcard()
AlluxioURI
contains wildcard(s).boolean
that indicates whether the AlluxioURI
contains wildcard(s)public String getName()
AlluxioURI
.AlluxioURI
@Nullable public AlluxioURI getParent()
AlluxioURI
or null if at root.AlluxioURI
or null if at rootpublic String getPath()
AlluxioURI
.public Map<String,String> getQueryMap()
@Nullable public String getScheme()
AlluxioURI
.public String getRootPath()
public boolean hasAuthority()
AlluxioURI
has authority or not.public boolean hasScheme()
AlluxioURI
has scheme or not.public static boolean hasWindowsDrive(String path, boolean slashed)
path
- the path to checkslashed
- if the path starts with a slashpublic boolean isAbsolute()
AlluxioURI
is absolute.
An AlluxioURI
is absolute if, and only if, it has a scheme component.
AlluxioURI
is absolutepublic boolean isPathAbsolute()
AlluxioURI
is absolute.
A path is absolute if, and only if, it starts with root.
AlluxioURI
's path component is absolutepublic boolean isRoot()
AlluxioURI
is root.
A URI is root if its path equals to "/"
public AlluxioURI join(String suffix)
AlluxioURI
.suffix
- the suffix to addAlluxioURI
public AlluxioURI join(AlluxioURI suffix)
AlluxioURI
.suffix
- the suffix to addAlluxioURI
public AlluxioURI joinUnsafe(String suffix)
AlluxioURI
. This does not check if
the new path needs normalization, and is less CPU intensive than join(String)
.suffix
- the suffix to addAlluxioURI
public static String normalizePath(String path)
AlluxioURI
, by replacing all "//" and "\\" with
"/", and trimming trailing slash from non-root path (ignoring windows drive).path
- the path to normalizepublic boolean isAncestorOf(AlluxioURI alluxioURI) throws InvalidPathException
alluxioURI
- potential children to checkInvalidPathException
public String toString()
toString
in class Object
AlluxioURI
Copyright © 2023. All Rights Reserved.