Class JimfsPath

  • All Implemented Interfaces:
    java.lang.Comparable<java.nio.file.Path>, java.lang.Iterable<java.nio.file.Path>, java.nio.file.Path, java.nio.file.Watchable

    final class JimfsPath
    extends java.lang.Object
    implements java.nio.file.Path
    Jimfs implementation of Path. Creation of new Path objects is delegated to the file system's PathService.
    • Field Detail

      • root

        private final @Nullable Name root
      • names

        private final com.google.common.collect.ImmutableList<Name> names
    • Constructor Detail

      • JimfsPath

        public JimfsPath​(PathService pathService,
                         @Nullable Name root,
                         java.lang.Iterable<Name> names)
    • Method Detail

      • root

        public @Nullable Name root()
        Returns the root name, or null if there is no root.
      • names

        public com.google.common.collect.ImmutableList<Name> names()
        Returns the list of name elements.
      • name

        public @Nullable Name name()
        Returns the file name of this path. Unlike getFileName(), this may return the name of the root if this is a root path.
      • isEmptyPath

        public boolean isEmptyPath()
        Returns whether or not this is the empty path, with no root and a single, empty string, name.
      • getFileSystem

        public java.nio.file.FileSystem getFileSystem()
        Specified by:
        getFileSystem in interface java.nio.file.Path
      • getJimfsFileSystem

        public JimfsFileSystem getJimfsFileSystem()
        Equivalent to getFileSystem() but with a return type of JimfsFileSystem. getFileSystem()'s return type is left as FileSystem to make testing paths easier (as long as methods that access the file system in some way are not called, the file system can be a fake file system instance).
      • isAbsolute

        public boolean isAbsolute()
        Specified by:
        isAbsolute in interface java.nio.file.Path
      • getRoot

        public @Nullable JimfsPath getRoot()
        Specified by:
        getRoot in interface java.nio.file.Path
      • getFileName

        public @Nullable JimfsPath getFileName()
        Specified by:
        getFileName in interface java.nio.file.Path
      • getParent

        public @Nullable JimfsPath getParent()
        Specified by:
        getParent in interface java.nio.file.Path
      • getNameCount

        public int getNameCount()
        Specified by:
        getNameCount in interface java.nio.file.Path
      • getName

        public JimfsPath getName​(int index)
        Specified by:
        getName in interface java.nio.file.Path
      • subpath

        public JimfsPath subpath​(int beginIndex,
                                 int endIndex)
        Specified by:
        subpath in interface java.nio.file.Path
      • startsWith

        private static boolean startsWith​(java.util.List<?> list,
                                          java.util.List<?> other)
        Returns true if list starts with all elements of other in the same order.
      • startsWith

        public boolean startsWith​(java.nio.file.Path other)
        Specified by:
        startsWith in interface java.nio.file.Path
      • startsWith

        public boolean startsWith​(java.lang.String other)
        Specified by:
        startsWith in interface java.nio.file.Path
      • endsWith

        public boolean endsWith​(java.nio.file.Path other)
        Specified by:
        endsWith in interface java.nio.file.Path
      • endsWith

        public boolean endsWith​(java.lang.String other)
        Specified by:
        endsWith in interface java.nio.file.Path
      • normalize

        public JimfsPath normalize()
        Specified by:
        normalize in interface java.nio.file.Path
      • isNormal

        private boolean isNormal()
        Returns whether or not this path is in a normalized form. It's normal if it both contains no "." names and contains no ".." names in a location other than the start of the path.
      • resolve

        JimfsPath resolve​(Name name)
        Resolves the given name against this path. The name is assumed not to be a root name.
      • resolve

        public JimfsPath resolve​(java.nio.file.Path other)
        Specified by:
        resolve in interface java.nio.file.Path
      • resolve

        public JimfsPath resolve​(java.lang.String other)
        Specified by:
        resolve in interface java.nio.file.Path
      • resolveSibling

        public JimfsPath resolveSibling​(java.nio.file.Path other)
        Specified by:
        resolveSibling in interface java.nio.file.Path
      • resolveSibling

        public JimfsPath resolveSibling​(java.lang.String other)
        Specified by:
        resolveSibling in interface java.nio.file.Path
      • relativize

        public JimfsPath relativize​(java.nio.file.Path other)
        Specified by:
        relativize in interface java.nio.file.Path
      • toAbsolutePath

        public JimfsPath toAbsolutePath()
        Specified by:
        toAbsolutePath in interface java.nio.file.Path
      • toRealPath

        public JimfsPath toRealPath​(java.nio.file.LinkOption... options)
                             throws java.io.IOException
        Specified by:
        toRealPath in interface java.nio.file.Path
        Throws:
        java.io.IOException
      • register

        public java.nio.file.WatchKey register​(java.nio.file.WatchService watcher,
                                               java.nio.file.WatchEvent.Kind<?>[] events,
                                               java.nio.file.WatchEvent.Modifier... modifiers)
                                        throws java.io.IOException
        Specified by:
        register in interface java.nio.file.Path
        Specified by:
        register in interface java.nio.file.Watchable
        Throws:
        java.io.IOException
      • register

        public java.nio.file.WatchKey register​(java.nio.file.WatchService watcher,
                                               java.nio.file.WatchEvent.Kind<?>... events)
                                        throws java.io.IOException
        Specified by:
        register in interface java.nio.file.Path
        Specified by:
        register in interface java.nio.file.Watchable
        Throws:
        java.io.IOException
      • toUri

        public java.net.URI toUri()
        Specified by:
        toUri in interface java.nio.file.Path
      • toFile

        public java.io.File toFile()
        Specified by:
        toFile in interface java.nio.file.Path
      • iterator

        public java.util.Iterator<java.nio.file.Path> iterator()
        Specified by:
        iterator in interface java.lang.Iterable<java.nio.file.Path>
        Specified by:
        iterator in interface java.nio.file.Path
      • asList

        private java.util.List<java.nio.file.Path> asList()
      • compareTo

        public int compareTo​(java.nio.file.Path other)
        Specified by:
        compareTo in interface java.lang.Comparable<java.nio.file.Path>
        Specified by:
        compareTo in interface java.nio.file.Path
      • equals

        public boolean equals​(@Nullable java.lang.Object obj)
        Specified by:
        equals in interface java.nio.file.Path
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Specified by:
        hashCode in interface java.nio.file.Path
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Specified by:
        toString in interface java.nio.file.Path
        Overrides:
        toString in class java.lang.Object
      • checkPath

        private @Nullable JimfsPath checkPath​(java.nio.file.Path other)