TrueZIP Kernel 7.0-rc2

de.schlichtherle.truezip.fs
Class FsMountPoint

java.lang.Object
  extended by de.schlichtherle.truezip.fs.FsMountPoint
All Implemented Interfaces:
Serializable, Comparable<FsMountPoint>

@Immutable
@DefaultAnnotation(value=edu.umd.cs.findbugs.annotations.NonNull.class)
public final class FsMountPoint
extends Object
implements Serializable, Comparable<FsMountPoint>

Addresses the mount point of a file system. A mount point is usually constructed from a Uniform Resource Identifier in order to assert the following additional syntax constraints:

  1. The URI must be absolute.
  2. The URI must not have a fragment.
  3. If the URI is opaque, its scheme specific part must end with the mount point separator "!/". The scheme specific part before this mount point separator is parsed according the syntax constraints for a FsPath and the following additional syntax constraints: The path must be absolute. If its opaque, it's entry name must not be empty.
  4. If the URI is hierarchical, its path must be in normal form and end with a "/".

Examples for valid mount point URIs are:

Examples for invalid mount point URIs are:

This class supports serialization with both ObjectOutputStream and XMLEncoder.

Author:
Christian Schlichtherle
See Also:
FsPath, Serialized Form

Field Summary
private  FsMountPoint hierarchical
           
private  FsPath path
           
private  FsScheme scheme
           
private static long serialVersionUID
           
private  URI uri
           
 
Constructor Summary
FsMountPoint(FsScheme scheme, FsPath path)
          Constructs a new mount point by synthesizing its URI from the given scheme and path.
FsMountPoint(String uri)
          Equivalent to new FsMountPoint(uri, FsUriModifier.NULL).
FsMountPoint(String uri, FsUriModifier modifier)
          Constructs a new path by calling new URI(uri) and parsing the resulting URI.
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.
 
Method Summary
 int compareTo(FsMountPoint that)
          Implements a natural ordering which is consistent with equals(Object).
static FsMountPoint create(FsScheme scheme, FsPath path)
          Constructs a new mount point by synthesizing its URI from the given scheme and path.
static FsMountPoint create(String uri)
          Equivalent to create(uri, FsUriModifier.NULL).
static FsMountPoint create(String uri, FsUriModifier modifier)
          Constructs a new mount point by constructing a new URI from the given string representation and parsing the result.
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 nullable parent mount point, i.e. the mount point of the parent file system or null iff this mount point's URI doesn't name a parent mount point, i.e. if it's hierarchical.
 FsPath getPath()
          Returns the path or null iff this mount point's URI doesn't name a parent mount point, i.e. if it's hierarchical.
 FsScheme getScheme()
          Returns the URI scheme.
 URI getUri()
          Returns the non-null URI.
 int hashCode()
          Returns a hash code which is consistent with equals(Object).
 FsMountPoint hierarchicalize()
          Returns a mount point which has its URI converted from the URI of this mount point so that it's absolute and hierarchical.
private  boolean invariants()
           
private  void parse(URI uri, FsUriModifier modifier)
           
private static String quote(Object s)
           
private  void readObject(ObjectInputStream in)
           
 FsPath resolve(FsEntryName entryName)
          Resolves the given entry name against this mount point.
 String toString()
          Equivalent to calling URI.toString() on getUri().
private  void writeObject(ObjectOutputStream out)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

uri

private URI uri

path

@Nullable
private transient FsPath path

scheme

@Nullable
private transient volatile FsScheme scheme

hierarchical

@Nullable
private transient volatile FsMountPoint hierarchical
Constructor Detail

FsMountPoint

public FsMountPoint(String uri)
             throws URISyntaxException
Equivalent to new FsMountPoint(uri, FsUriModifier.NULL).

Throws:
URISyntaxException

FsMountPoint

public FsMountPoint(String uri,
                    FsUriModifier modifier)
             throws URISyntaxException
Constructs a new path by calling new URI(uri) and parsing the resulting URI.

Parameters:
uri - the URI string representation.
modifier - the URI modifier.
Throws:
URISyntaxException - if uri does not conform to the syntax constraints for mount points.

FsMountPoint

public FsMountPoint(URI uri)
             throws URISyntaxException
Equivalent to new FsMountPoint(uri, FsUriModifier.NULL).

Throws:
URISyntaxException

FsMountPoint

public FsMountPoint(URI uri,
                    FsUriModifier modifier)
             throws URISyntaxException
Constructs a new mount point by parsing the given URI.

Parameters:
uri - the URI.
modifier - the URI modifier.
Throws:
URISyntaxException - if uri does not conform to the syntax constraints for mount points.

FsMountPoint

public FsMountPoint(FsScheme scheme,
                    FsPath path)
             throws URISyntaxException
Constructs a new mount point by synthesizing its URI from the given scheme and path.

Parameters:
scheme - the non-null scheme.
path - the non-null path.
Throws:
URISyntaxException - if the synthesized mount point URI would not conform to the syntax constraints for mount points.
Method Detail

create

public static FsMountPoint create(String uri)
Equivalent to create(uri, FsUriModifier.NULL).


create

public static FsMountPoint create(String uri,
                                  FsUriModifier modifier)
Constructs a new mount point by constructing a new URI from the given string representation and parsing the result. This static factory method calls new FsMountPoint(uri, modifier) and wraps any thrown URISyntaxException in an IllegalArgumentException.

Parameters:
uri - the URI string representation.
modifier - the URI modifier.
Returns:
A new mount point.
Throws:
IllegalArgumentException - if uri does not conform to the syntax constraints for mount points.

create

public static FsMountPoint create(URI uri)
Equivalent to create(uri, FsUriModifier.NULL).


create

public static FsMountPoint create(URI uri,
                                  FsUriModifier modifier)
Constructs a new mount point by parsing the given URI. This static factory method calls new FsMountPoint(uri, modifier) and wraps any thrown URISyntaxException in an IllegalArgumentException.

Parameters:
uri - the URI.
modifier - the URI modifier.
Returns:
A new mount point.
Throws:
IllegalArgumentException - if uri does not conform to the syntax constraints for mount points.

create

public static FsMountPoint create(FsScheme scheme,
                                  FsPath path)
Constructs a new mount point by synthesizing its URI from the given scheme and path. This static factory method calls new FsMountPoint(scheme, path) and wraps any thrown URISyntaxException in an IllegalArgumentException.

Parameters:
scheme - the scheme.
path - the path.
Returns:
A new mount point.
Throws:
IllegalArgumentException - if the synthesized mount point URI would not conform to the syntax constraints for mount points.

writeObject

private void writeObject(ObjectOutputStream out)
                  throws IOException
Throws:
IOException

readObject

private void readObject(ObjectInputStream in)
                 throws IOException,
                        ClassNotFoundException
Throws:
IOException
ClassNotFoundException

parse

private void parse(URI uri,
                   FsUriModifier modifier)
            throws URISyntaxException
Throws:
URISyntaxException

quote

private static String quote(Object s)

invariants

private boolean invariants()

getScheme

public FsScheme getScheme()
Returns the URI scheme.

Returns:
The URI scheme.

getPath

@Nullable
public FsPath getPath()
Returns the path or null iff this mount point's URI doesn't name a parent mount point, i.e. if it's hierarchical.

Returns:
The nullable path.

getUri

public URI getUri()
Returns the non-null URI.

Returns:
The non-null URI.

getParent

@Nullable
public FsMountPoint getParent()
Returns the nullable parent mount point, i.e. the mount point of the parent file system or null iff this mount point's URI doesn't name a parent mount point, i.e. if it's hierarchical.

Returns:
The nullable parent mount point.

resolve

public FsPath resolve(FsEntryName entryName)
Resolves the given entry name against this mount point.

Parameters:
entryName - an entry name relative to this mount point.
Returns:
A new path with an absolute URI.

hierarchicalize

public FsMountPoint hierarchicalize()
Returns a mount point which has its URI converted from the URI of this mount point so that it's absolute and hierarchical. If this mount point is already in hierarchical form, it's returned.

Note that this function is idempotent, so calling it repeatedly will produce the same result again. However, this function is not injective, so two different mount points may produce equal results. For example, the mount point URIs zip:file:/archive!/ and tar:file:/archive!/ will both produce an equal mount point with the absolute, hierarchical URI file:/archive/.

Returns:
A mount point which has its URI converted from the URI of this mount point so that it's absolute and hierarchical.

equals

public boolean equals(@CheckForNull
                      Object that)
Returns 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.

Overrides:
equals in class Object

compareTo

public int compareTo(FsMountPoint that)
Implements a natural ordering which is consistent with equals(Object).

Specified by:
compareTo in interface Comparable<FsMountPoint>

hashCode

public int hashCode()
Returns a hash code which is consistent with equals(Object).

Overrides:
hashCode in class Object

toString

public String toString()
Equivalent to calling URI.toString() on getUri().

Overrides:
toString in class Object

TrueZIP Kernel 7.0-rc2

Copyright © 2005-2011 Schlichtherle IT Services. All Rights Reserved.