public class RemoteMount
extends java.lang.Object
RB
into a local base directory LB
. Here,
RB
is a file URI having host and path components, whereas LB
is a local path. Now take a file URI with a prefix of RB
, f
= RB + p
where p
is the path following RB
in the URI.
Then f
corresponds to the local path of LB + p
. For example,
if RB = file://host-1/data/
and LB = /mnt/h1/data
, then
a URI of file://host-1/data/some/file
gets translated to a local
path of /mnt/h1/data/some/file
, but a URI of file://host-1/dataxxx/some/file
doesn't get translated because it doesn't
have a prefix of RB
.Constructor and Description |
---|
RemoteMount(java.net.URI remoteBasePath,
java.nio.file.Path localBasePath)
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
static boolean |
isRemoteFilePath(java.net.URI x)
Is the given URI that of a file path on a remote host?
|
java.util.Optional<java.nio.file.Path> |
toLocalPath(java.net.URI remotePath)
Tries to translate a remote path into a local one using the remote and
local base paths of this instance.
|
java.lang.String |
toString() |
public RemoteMount(java.net.URI remoteBasePath, java.nio.file.Path localBasePath)
remoteBasePath
- the remote base path.localBasePath
- the local base path. If not absolute, we make it
such. So in general you should probably pass in an absolute path!java.lang.NullPointerException
- if any argument is null
.java.lang.IllegalArgumentException
- if the remote base path is not that of
a remote file path
.public static boolean isRemoteFilePath(java.net.URI x)
x
- the URI to test.true
just in case the URI is not null
, has a
"file" scheme and a host part too.public java.util.Optional<java.nio.file.Path> toLocalPath(java.net.URI remotePath)
remotePath
- the remote path to translate.public java.lang.String toString()
toString
in class java.lang.Object