public interface IOPath
Modifier and Type | Method and Description |
---|---|
default java.util.Optional<java.lang.String> |
getBaseName() |
default java.util.Optional<java.lang.String> |
getExtension() |
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 that was provided to the constructor.
|
default java.lang.String |
getScheme()
Return the scheme for this
IOPath . |
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 IOPath . |
java.lang.String |
getURIString()
Returns the string from which this
IOPath was originally created. |
default boolean |
hasExtension(java.lang.String extension)
Return true if the path component (the hierarchical part of the scheme specific part of the underlying URI)
ends with the provided
extension string. |
boolean |
hasFileSystemProvider() |
default boolean |
isBam()
Returns true if the file's extension is ".bam"".
|
default boolean |
isCram()
Returns true if the GATKPath's extension is ".cram".
|
default boolean |
isFasta() |
boolean |
isPath()
Return true if this {code IOPath} can be resolved to an
java.nio Path. |
default boolean |
isSam()
Returns true if the file's extension is ".sam"".
|
java.nio.file.Path |
toPath()
Resolve this
IOPath to an NIO java.nio.file.Path . |
java.net.URI getURI()
java.net.URI
object for this IOPath
. Will not be null.URI
object for this IOPath
.java.lang.String getURIString()
IOPath
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 IOPath
.java.lang.String getRawInputString()
boolean hasFileSystemProvider()
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.boolean isPath()
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).java.nio.file.Path toPath()
IOPath
to an NIO java.nio.file.Path
. Can be safely called only if #isPath()
returns true.java.lang.String getToPathFailureReason()
java.nio.file.Path
(#isPath()
returns false).default java.lang.String getScheme()
IOPath
. For file URIs (URIs that have no explicit scheme), this will return
the scheme "file".default java.util.Optional<java.lang.String> getExtension()
Optional
containing the extension of the last component of the hierarchical part of the
scheme-specific part of the URI, if any, including the ".", or Optional.empty() if the hierarchical name ends
with the default file system separator, (i.e. "/"), or if the hierarchical name ends with a last component
that does not contain a ".".
Note that this only returns the part of the last component after the last ".", ie. it will return ".gz" for
a name that ends in ".fasta.gz" (the hasExtension(String)
method can be used to test for the presence
of multi-part extensions
such as this).default boolean hasExtension(java.lang.String extension)
extension
string. This method can be used to test for both single and
multi-part extensions (ie. for a name that ends in ".fasta.gz", it will return true for both ".gz" and
".fasta.gz".extension
- the target extension to test, INCLUDING the leading ".". May not be null.default java.util.Optional<java.lang.String> getBaseName()
Optional
containing the base name (the last component of the hierarchical part of the
scheme-specific part of the URI, after the last "/"), up to but not including the extension (the last "."),
or Optional.empty() if the last component is empty (ie, the component ends in "/"), or the last component
exists but starts with "."default boolean isSam()
default boolean isBam()
default boolean isCram()
default boolean isFasta()
java.io.InputStream getInputStream()
InputStream
for this URI if a provider is for the URI's scheme is available.InputStream
for this URI.java.io.OutputStream getOutputStream()
OutputStream
for this URI if a provider is for the URI's scheme.OutputStream
for this URI.