@Immutable public final class FsMountPoint extends Object implements Serializable, Comparable<FsMountPoint>
A mount point adds the following syntax constraints to a
Uniform Resource Identifier
:
"!/"
.
The scheme specific part before the mount point separator is
parsed according the syntax constraints for a FsNodePath
and the
following additional syntax constraints:
The path component must be absolute.
If its opaque, it's node name must not be empty.
Finally, its set as the value of the path
component
property.
"/"
.
The path
component property of the mount point is set
to null
in this case.
Examples for valid mount point URIs:
uri property |
scheme property |
path URI |
parent URI |
---|---|---|---|
"foo:/bar/" |
"foo" |
null |
null |
"foo:bar:/baz!/" |
"foo" |
"bar:/baz" |
"bar:/" |
"foo:bar:baz:/bang!/boom!/" |
"foo" |
"bar:baz:/bang!/boom" |
"baz:/bang" |
* the property is null
and hence its URI is not available.
Examples for invalid mount point URIs:
URI | Issue |
---|---|
/foo |
not an absolute URI |
foo:/bar |
missing slash at end of hierarchical URI |
foo:/bar/#baz |
fragment component defined |
foo:bar:/baz!/bang |
missing mount point separator "!/" at end |
foo:bar:baz:/bang!/!/ |
empty node name in path component after mount point "bar:baz:/bang!/" |
For any mount point m
, it's generally true that
new FsMountPoint(m.getUri()).equals(m)
.
For any mount point m
with an opaque URI, it's generally true that
new FsMountPoint(m.getScheme(), m.getPath()).equals(m)
.
This class supports serialization with both
ObjectOutputStream
and XMLEncoder
.
FsNodePath
,
FsNodeName
,
FsScheme
,
Serialized FormModifier and Type | Field and Description |
---|---|
static String |
SEPARATOR
The separator which is used to split opaque path names into
mount points and node names . |
Constructor and Description |
---|
FsMountPoint(FsScheme scheme,
FsNodePath path)
Constructs a new opaque mount point by composing its URI from the given
scheme and path.
|
FsMountPoint(URI uri)
Equivalent to
new FsMountPoint(uri, FsUriModifier.NULL) . |
FsMountPoint(URI uri,
FsUriModifier modifier)
Constructs a new mount point by parsing the given URI.
|
Modifier and Type | Method and Description |
---|---|
int |
compareTo(FsMountPoint that)
Implements a natural ordering which is consistent with
equals(Object) . |
static FsMountPoint |
create(FsScheme scheme,
FsNodePath path)
Constructs a new mount point by composing its URI from the given scheme
and path.
|
static FsMountPoint |
create(URI uri)
Equivalent to
create(uri, FsUriModifier.NULL) . |
static FsMountPoint |
create(URI uri,
FsUriModifier modifier)
Constructs a new mount point by parsing the given URI.
|
boolean |
equals(Object that)
Returns
true iff the given object is a mount point and its URI
equals the URI of this mount point. |
FsMountPoint |
getParent()
Returns the parent component, that is the mount point of the parent file
system,
or
null iff this mount point's URI doesn't name
a parent mount point, that is if and only if it's hierarchical. |
FsNodePath |
getPath()
Returns the path component
or
null iff this mount point's URI doesn't name
a parent mount point, that is if and only if it's hierarchical. |
FsScheme |
getScheme()
Returns the scheme component.
|
URI |
getUri()
Returns the URI for this mount point.
|
int |
hashCode()
Returns a hash code which is consistent with
equals(Object) . |
FsNodePath |
resolve(FsNodeName name)
Resolves the given node name against this mount point.
|
URI |
toHierarchicalUri()
Returns a URI which is recursively transformed from the URI of this
mount point so that it's absolute and hierarchical.
|
String |
toString()
Equivalent to calling
URI.toString() on getUri() . |
public static final String SEPARATOR
mount points
and node names
.
This is identical to the separator in the class
JarURLConnection
.public FsMountPoint(FsScheme scheme, FsNodePath path) throws URISyntaxException
scheme
- the non-null
scheme
.path
- the non-null
path
.URISyntaxException
- if the composed mount point URI would not
conform to the syntax constraints for mount points.@ConstructorProperties(value="uri") public FsMountPoint(URI uri) throws URISyntaxException
new FsMountPoint(uri, FsUriModifier.NULL)
.URISyntaxException
public FsMountPoint(URI uri, FsUriModifier modifier) throws URISyntaxException
uri
- the URI
.modifier
- the URI modifier.URISyntaxException
- if uri
does not conform to the
syntax constraints for mount points.public int compareTo(FsMountPoint that)
equals(Object)
.compareTo
in interface Comparable<FsMountPoint>
public static FsMountPoint create(FsScheme scheme, FsNodePath path)
new FsMountPoint(scheme, path)
and wraps any thrown URISyntaxException
in an
IllegalArgumentException
.scheme
- the scheme
.path
- the path
.IllegalArgumentException
- if the composed mount point URI would
not conform to the syntax constraints for mount points.public static FsMountPoint create(URI uri)
create(uri, FsUriModifier.NULL)
.public static FsMountPoint create(URI uri, FsUriModifier modifier)
new FsMountPoint(uri, modifier)
and wraps any thrown URISyntaxException
in an
IllegalArgumentException
.uri
- the URI
.modifier
- the URI modifier.IllegalArgumentException
- if uri
does not conform to the
syntax constraints for mount points.public boolean equals(@CheckForNull Object that)
true
iff the given object is a mount point and its URI
equals
the URI of this mount point.
Note that this ignores the scheme and path.@Nullable public FsMountPoint getParent()
null
iff this mount point's URI
doesn't name
a parent mount point, that is if and only if it's hierarchical.@Nullable public FsNodePath getPath()
null
iff this mount point's URI
doesn't name
a parent mount point, that is if and only if it's hierarchical.public FsScheme getScheme()
public URI getUri()
public int hashCode()
equals(Object)
.public FsNodePath resolve(FsNodeName name)
name
- a node name relative to this mount point.public URI toHierarchicalUri()
For example, the mount point URIs zip:file:/archive!/
and
tar:file:/archive!/
would both produce the hierarchical URI
file:/archive
.
public String toString()
URI.toString()
on getUri()
.Copyright © 2005–2018 Schlichtherle IT Services. All rights reserved.