Class PathService

java.lang.Object
io.roastedroot.zerofs.PathService
All Implemented Interfaces:
Comparator<ZeroFsPath>

final class PathService extends Object implements Comparator<ZeroFsPath>
Service for creating ZeroFsPath instances and handling other path-related operations.
  • Field Details

    • DISPLAY_ROOT_COMPARATOR

      private static final Comparator<Name> DISPLAY_ROOT_COMPARATOR
    • DISPLAY_NAMES_COMPARATOR

      private static final Comparator<Iterable<Name>> DISPLAY_NAMES_COMPARATOR
    • CANONICAL_ROOT_COMPARATOR

      private static final Comparator<Name> CANONICAL_ROOT_COMPARATOR
    • CANONICAL_NAMES_COMPARATOR

      private static final Comparator<Iterable<Name>> CANONICAL_NAMES_COMPARATOR
    • type

      private final PathType type
    • displayNormalizations

      private final Set<PathNormalization> displayNormalizations
    • canonicalNormalizations

      private final Set<PathNormalization> canonicalNormalizations
    • equalityUsesCanonicalForm

      private final boolean equalityUsesCanonicalForm
    • rootComparator

      private final Comparator<Name> rootComparator
    • namesComparator

      private final Comparator<Iterable<Name>> namesComparator
    • fileSystem

      private volatile FileSystem fileSystem
    • emptyPath

      private volatile ZeroFsPath emptyPath
    • NOT_EMPTY

      private static final Predicate<Object> NOT_EMPTY
  • Constructor Details

  • Method Details

    • setFileSystem

      public void setFileSystem(FileSystem fileSystem)
      Sets the file system to use for created paths.
    • getFileSystem

      public FileSystem getFileSystem()
      Returns the file system this service is for.
    • getSeparator

      public String getSeparator()
      Returns the default path separator.
    • emptyPath

      public ZeroFsPath emptyPath()
      Returns an empty path which has a single name, the empty string.
    • name

      public Name name(String name)
      Returns the Name form of the given string.
    • names

      List<Name> names(String[] names)
      Returns the Name forms of the given strings.
    • createRoot

      public ZeroFsPath createRoot(Name root)
      Returns a root path with the given name.
    • createFileName

      public ZeroFsPath createFileName(Name name)
      Returns a single filename path with the given name.
    • createRelativePath

      public ZeroFsPath createRelativePath(Iterable<Name> names)
      Returns a relative path with the given names.
    • createPath

      public ZeroFsPath createPath(Name root, Iterable<Name> names)
      Returns a path with the given root (or no root, if null) and the given names.
    • createPathInternal

      protected final ZeroFsPath createPathInternal(Name root, Iterable<Name> names)
      Returns a path with the given root (or no root, if null) and the given names.
    • parsePath

      public ZeroFsPath parsePath(String first, String... more)
      Parses the given strings as a path.
    • toPath

      private ZeroFsPath toPath(PathType.ParseResult parsed)
    • toString

      public String toString(ZeroFsPath path)
      Returns the string form of the given path.
    • hash

      public int hash(ZeroFsPath path)
      Creates a hash code for the given path.
    • compare

      public int compare(ZeroFsPath a, ZeroFsPath b)
      Specified by:
      compare in interface Comparator<ZeroFsPath>
    • toUri

      public URI toUri(URI fileSystemUri, ZeroFsPath path)
      Returns the URI for the given path. The given file system URI is the base against which the path is resolved to create the returned URI.
    • fromUri

      public ZeroFsPath fromUri(URI uri)
      Converts the path of the given URI into a path for this file system.
    • createPathMatcher

      public PathMatcher createPathMatcher(String syntaxAndPattern)
      Returns a PathMatcher for the given syntax and pattern as specified by FileSystem.getPathMatcher(String).