public class PathSpecifier extends java.lang.Object implements PathURI, java.io.Serializable
java.nio
file system provider that matches the URI scheme
3) isPath: syntactically valid URI that can be resolved to a java.io.Path by the associated provider
Definitions taken from RFC 2396 "Uniform Resource Identifiers (URI): Generic Syntax"
(https://www.ietf.org/rfc/rfc2396.txt):
"absolute" URI - specifies a scheme
"relative" URI - does not specify a scheme
"opaque" URI - an "absolute" URI whose scheme-specific part does not begin with a slash character
"hierarchical" URI - either an "absolute" URI whose scheme-specific part begins with a slash character,
or a "relative" URI (no scheme)
URIs that do not make use of the slash "/" character for separating hierarchical components are
considered "opaque" by the generic URI parser.
General syntax for an "absolute" URI:
Constructor and Description |
---|
PathSpecifier(java.lang.String rawInputString)
If the raw input string already contains a scheme (including a "file" scheme), assume its already
properly escape/encoded.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object o) |
protected java.nio.file.Path |
getCachedPath() |
java.io.InputStream |
getInputStream()
Get a
InputStream for this URI if a provider is for the URI's scheme is available. |
java.io.OutputStream |
getOutputStream()
Get an
OutputStream for this URI if a provider is for the URI's scheme. |
java.lang.String |
getRawInputString()
Return the raw input string provided to the constructor.
|
java.lang.String |
getToPathFailureReason()
Return a string message describing why this URI cannot be converted to a
java.nio.file.Path
(#isPath() returns false). |
java.net.URI |
getURI()
Get a
java.net.URI object for this PathURI . |
java.lang.String |
getURIString()
Returns the string from which this
PathURI was originally created. |
boolean |
hasFileSystemProvider() |
int |
hashCode() |
boolean |
isPath()
Return true if this {code PathURI} can be resolved to an
java.nio Path. |
protected void |
setCachedPath(java.nio.file.Path path) |
java.nio.file.Path |
toPath()
Resolve the URI to a
Path object. |
java.lang.String |
toString() |
public PathSpecifier(java.lang.String rawInputString)
rawInputString
- public java.net.URI getURI()
PathURI
java.net.URI
object for this PathURI
. Will not be null.public java.lang.String getURIString()
PathURI
PathURI
was originally created. This string may differ from
the normalized string returned from a java.nio.file.Path
that has been object resolved from this PathURI.getURIString
in interface PathURI
public java.lang.String getRawInputString()
getRawInputString
in interface PathURI
public boolean hasFileSystemProvider()
hasFileSystemProvider
in interface PathURI
java.nio
file system provider
(). This does not
guarantee the URI can be converted into a java.nio.file.Path
, since the URI can be syntactically
valid, and specify a valid file system provider, but still fail to be semantically meaningful.public boolean isPath()
PathURI
java.nio
Path. If true, #toPath()
can be
safely called.
There are cases where a valid URI with a valid scheme backed by an installed java.nio File System
still can't be turned into a {@code java.nio.file.Path}, i.e., the following specifies an invalid
authority "namenode":
hdfs://namenode/to/file
The current implementation returns false for these cases (toPath will fail, getInvalidPathReason
returns the reason code).public java.nio.file.Path toPath()
Path
object.toPath
in interface PathURI
Path
UserException
- if an I/O error occurs when creating the file systempublic java.lang.String getToPathFailureReason()
PathURI
java.nio.file.Path
(#isPath()
returns false).getToPathFailureReason
in interface PathURI
public java.io.InputStream getInputStream()
PathURI
InputStream
for this URI if a provider is for the URI's scheme is available.getInputStream
in interface PathURI
InputStream
for this URI.public java.io.OutputStream getOutputStream()
PathURI
OutputStream
for this URI if a provider is for the URI's scheme.getOutputStream
in interface PathURI
OutputStream
for this URI.protected java.nio.file.Path getCachedPath()
protected void setCachedPath(java.nio.file.Path path)
public java.lang.String toString()
toString
in class java.lang.Object
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object