Class SMBPath

  • 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

    public final class SMBPath
    extends java.lang.Object
    implements java.nio.file.Path
    A Path implementation that can be used with SMBNio
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int compareTo​(java.nio.file.Path other)
      Compares two abstract paths lexicographically.
      boolean endsWith​(java.lang.String other)
      Tests if this path ends with the provided string.
      boolean endsWith​(java.nio.file.Path other)
      Tests if this path ends with the given path.
      boolean equals​(java.lang.Object other)
      Tests this path for equality with the given object.
      java.nio.file.Path getFileName()
      Returns a new, relative SMBPath instance that just contains the last path component of the current SMBPath's path.
      java.nio.file.FileSystem getFileSystem()
      Getter for SMBFileSystem this SMBPath belongs to.
      java.nio.file.Path getName​(int index)
      Returns a name element of this SMBPath as a new SMBPath object.
      int getNameCount()
      Returns the number of path components in the current SMBPath's path.
      java.nio.file.Path getParent()
      Returns a new SMBPath that points to the parent of the current SMBPath.
      java.nio.file.Path getRoot()
      Returns the root component of this SMBPath or null, if the path is relative.
      boolean isAbsolute()
      SMBPath is always absolute!
      boolean isFolder()
      Checks whether the current SMBPath is a folder.
      java.util.Iterator<java.nio.file.Path> iterator()
      Returns an iterator over the name elements of this SMBPath.
      java.nio.file.Path normalize()
      Returns a path that is this path with redundant name elements, like "." or ".." eliminated.
      java.nio.file.WatchKey register​(java.nio.file.WatchService watcher, java.nio.file.WatchEvent.Kind<?>... events)  
      java.nio.file.WatchKey register​(java.nio.file.WatchService watcher, java.nio.file.WatchEvent.Kind<?>[] events, java.nio.file.WatchEvent.Modifier... modifiers)  
      java.nio.file.Path relativize​(java.nio.file.Path other)
      Constructs a relative path between this path and a given path.
      java.nio.file.Path resolve​(java.lang.String other)
      Resolve the given path string against this SMBPath.
      java.nio.file.Path resolve​(java.nio.file.Path other)
      Resolve the given path against this SMBPath.
      java.nio.file.Path resolveSibling​(java.lang.String other)
      Resolve the given path string against this SMBPath.
      java.nio.file.Path resolveSibling​(java.nio.file.Path other)
      Resolve the given path against this SMBPath's parent.
      boolean startsWith​(java.lang.String other)
      Tests if this path starts with the provided string.
      boolean startsWith​(java.nio.file.Path other)
      Tests if this path starts with the given path.
      java.nio.file.Path subpath​(int beginIndex, int endIndex)
      Returns a relative Path that is a subsequence of the name elements of this path.
      java.nio.file.Path toAbsolutePath()
      If this SMBPath is absolute then the method returns this.
      java.io.File toFile()  
      java.nio.file.Path toRealPath​(java.nio.file.LinkOption... options)  
      java.lang.String toString()
      Default toString() method.
      java.net.URI toUri()
      Returns a URI to represent this SMBPath.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.lang.Iterable

        forEach, spliterator
      • Methods inherited from interface java.nio.file.Path

        hashCode
    • Method Detail

      • getFileSystem

        public java.nio.file.FileSystem getFileSystem()
        Getter for SMBFileSystem this SMBPath belongs to.
        Specified by:
        getFileSystem in interface java.nio.file.Path
        Returns:
        SMBFileSystem
      • isAbsolute

        public boolean isAbsolute()
        SMBPath is always absolute!
        Specified by:
        isAbsolute in interface java.nio.file.Path
        Returns:
        true
      • getRoot

        public java.nio.file.Path getRoot()
        Returns the root component of this SMBPath or null, if the path is relative.
        Specified by:
        getRoot in interface java.nio.file.Path
        Returns:
        Root component of this SMBPath
      • getFileName

        public java.nio.file.Path getFileName()
        Returns a new, relative SMBPath instance that just contains the last path component of the current SMBPath's path.
        Specified by:
        getFileName in interface java.nio.file.Path
        Returns:
        SMBPath for the file name.
      • getParent

        public java.nio.file.Path getParent()
        Returns a new SMBPath that points to the parent of the current SMBPath. If the current SMBPath instance does not have a parent, this method returns null.
        Specified by:
        getParent in interface java.nio.file.Path
        Returns:
        Parent SMBPath.
      • getNameCount

        public int getNameCount()
        Returns the number of path components in the current SMBPath's path.
        Specified by:
        getNameCount in interface java.nio.file.Path
        Returns:
        Number of path components.
      • getName

        public java.nio.file.Path getName​(int index)
        Returns a name element of this SMBPath as a new SMBPath object. The index parameter is the index of the name element to return. The element that is closest to the root in the directory hierarchy has index 0. The element that is farthest from the root has index count-1.
        Specified by:
        getName in interface java.nio.file.Path
        Parameters:
        index - The index of the element
        Returns:
        The name element.
      • subpath

        public java.nio.file.Path subpath​(int beginIndex,
                                          int endIndex)
        Returns a relative Path that is a subsequence of the name elements of this path.
        Specified by:
        subpath in interface java.nio.file.Path
        Parameters:
        beginIndex - The index of the first element, inclusive
        endIndex - The index of the last element, exclusive
        Returns:
        The resulting subpath.
        Throws:
        java.lang.IllegalArgumentException - If beginIndex is negative, or greater than or equal to the number of elements. If endIndex is less than or equal to beginIndex, or larger than the number of elements.
      • startsWith

        public boolean startsWith​(java.nio.file.Path other)
        Tests if this path starts with the given path. If the two paths belong to a different FileSystem then this method always returns false. Otherwise, a string comparison is performed.
        Specified by:
        startsWith in interface java.nio.file.Path
        Parameters:
        other - The given path
        Returns:
        True if this path starts with the given path; otherwise false
      • startsWith

        public boolean startsWith​(java.lang.String other)
        Tests if this path starts with the provided string. The path separators will be taken into account.
        Specified by:
        startsWith in interface java.nio.file.Path
        Parameters:
        other - The given path
        Returns:
        True if this path starts with the given string; otherwise false
      • endsWith

        public boolean endsWith​(java.nio.file.Path other)
        Tests if this path ends with the given path. If the two paths belong to a different FileSystem then this method always returns false. Otherwise, a string comparison is performed.
        Specified by:
        endsWith in interface java.nio.file.Path
        Parameters:
        other - The given path
        Returns:
        True if this path starts with the given path; otherwise false
      • endsWith

        public boolean endsWith​(java.lang.String other)
        Tests if this path ends with the provided string. The path separators will be taken into account.
        Specified by:
        endsWith in interface java.nio.file.Path
        Parameters:
        other - The given path
        Returns:
        True if this path starts with the given string; otherwise false
      • normalize

        public java.nio.file.Path normalize()
        Returns a path that is this path with redundant name elements, like "." or ".." eliminated.
        Specified by:
        normalize in interface java.nio.file.Path
        Returns:
        Normalized SMBPath.
      • resolve

        public java.nio.file.Path resolve​(java.nio.file.Path other)
        Resolve the given path against this SMBPath. If the other parameter is an absolute path then this method trivially returns other. If other is an empty path then this method trivially returns this path.
        Specified by:
        resolve in interface java.nio.file.Path
        Parameters:
        other - The path to resolve against this path
        Returns:
        The resulting SMBPath
        Throws:
        java.lang.IllegalArgumentException - If other path is not a SMBPath OR does not belong to the same SMBFileSystem OR if this path points to a file.
      • resolve

        public java.nio.file.Path resolve​(java.lang.String other)
        Resolve the given path string against this SMBPath. If the other parameter is an absolute path then this method trivially returns other. If other is an empty path then this method trivially returns this path.
        Specified by:
        resolve in interface java.nio.file.Path
        Parameters:
        other - The path to resolve against this path
        Returns:
        The resulting SMBPath
        Throws:
        java.lang.IllegalArgumentException - If other path is not a SMBPath OR does not belong to the same SMBFileSystem OR if this path points to a file.
      • resolveSibling

        public java.nio.file.Path resolveSibling​(java.nio.file.Path other)
        Resolve the given path against this SMBPath's parent. If the other parameter is an absolute path then this method trivially returns other. If other is an empty path then this method trivially returns this path.
        Specified by:
        resolveSibling in interface java.nio.file.Path
        Parameters:
        other - The path to resolve against this path
        Returns:
        The resulting SMBPath
        Throws:
        java.lang.IllegalArgumentException - If other path is not a SMBPath OR does not belong to the same SMBFileSystem.
      • resolveSibling

        public java.nio.file.Path resolveSibling​(java.lang.String other)
        Resolve the given path string against this SMBPath. If the other parameter is an absolute path then this method trivially returns other. If other is an empty path then this method trivially returns this path.
        Specified by:
        resolveSibling in interface java.nio.file.Path
        Parameters:
        other - The path to resolve against this path
        Returns:
        The resulting SMBPath
        Throws:
        java.lang.IllegalArgumentException - If other path is not a SMBPath OR does not belong to the same SMBFileSystem OR if this path points to a file.
      • relativize

        public java.nio.file.Path relativize​(java.nio.file.Path other)
        Constructs a relative path between this path and a given path.
        Specified by:
        relativize in interface java.nio.file.Path
        Parameters:
        other - The other path.
        Throws:
        java.lang.IllegalArgumentException - If other path is not a SMBPath OR does not belong to the same SMBFileSystem OR if this path points to a file.
      • toUri

        public java.net.URI toUri()
        Returns a URI to represent this SMBPath.
        Specified by:
        toUri in interface java.nio.file.Path
        Returns:
        The URI representing this path
      • toAbsolutePath

        public java.nio.file.Path toAbsolutePath()
        If this SMBPath is absolute then the method returns this. Otherwise, the given path is resolved against the top-level directory.
        Specified by:
        toAbsolutePath in interface java.nio.file.Path
        Returns:
        Absolute SMBPath
      • iterator

        public java.util.Iterator<java.nio.file.Path> iterator()
        Returns an iterator over the name elements of this SMBPath. The first element returned by the iterator represents the name element that is closest to the root in the directory hierarchy, the second element is the next closest, and so on. The last element returned is the name of the file or directory denoted by this path. The root component, if present, is not returned by the iterator.
        Specified by:
        iterator in interface java.lang.Iterable<java.nio.file.Path>
        Specified by:
        iterator in interface java.nio.file.Path
        Returns:
        An iterator over the name elements of this path.
      • compareTo

        public int compareTo​(java.nio.file.Path other)
        Compares two abstract paths lexicographically. This method does not access the file system and neither file is required to exist.
        Specified by:
        compareTo in interface java.lang.Comparable<java.nio.file.Path>
        Specified by:
        compareTo in interface java.nio.file.Path
        Parameters:
        other - The path compared to this SMBPath.
        Returns:
        Zero if the argument is equal to this path, a value less than zero if this path is lexicographically less than the argument, or a value greater than zero if this path is lexicographically greater than the argument
      • toString

        public java.lang.String toString()
        Default toString() method.
        Specified by:
        toString in interface java.nio.file.Path
        Overrides:
        toString in class java.lang.Object
        Returns:
        String representation of SMBPath.
      • equals

        public boolean equals​(java.lang.Object other)
        Tests this path for equality with the given object. If the given object is not a SMBPath, or is a SMBPath associated with a different SMBFileSystem, then this method returns false.
        Specified by:
        equals in interface java.nio.file.Path
        Overrides:
        equals in class java.lang.Object
        Parameters:
        other - The object to which this object is to be compared
        Returns:
        If, and only if, the given object is a SMBPath that is identical to this SMBPath.
      • isFolder

        public boolean isFolder()
        Checks whether the current SMBPath is a folder.
        Returns:
        True if current SMBPath is a folder.
      • toFile

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

        public java.nio.file.Path toRealPath​(java.nio.file.LinkOption... options)
        Specified by:
        toRealPath in interface java.nio.file.Path
      • register

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

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