Package gw.fs

Class ResourcePath


  • public class ResourcePath
    extends Object
    • Method Detail

      • getName

        public String getName()
        Returns the leaf name of this resource path. If this path object represents the path "/usr/local/bin", then the getName() method will return the String "bin". In the case of the root path element, this method will return the empty string for the unix filesystem root and a windows drive letter, normalized to upper case, with no trailing path separator for a windows path root. This method will never return a null value.
        Returns:
        the name of the last element of the path.
      • getParent

        public ResourcePath getParent()
        Returns the parent of this resource path. If this path object represents the root of the filesystem, this method will return null.
        Returns:
        the parent of this ResourcePath
      • getPathString

        public String getPathString()
        Returns the path string for this path using the / path separator.
        Returns:
        the path string for this path using the / path separator.
        See Also:
        getPathString(String)
      • getFileSystemPathString

        public String getFileSystemPathString()
        Returns the path string for this path using the default file system separator, as defined by the File.separator property.
        Returns:
        the path string for this path using the default file system separator
        See Also:
        getPathString(String)
      • getPathString

        public String getPathString​(String separator)
        Returns the path string for this path using the specified path separator. The path constructed will begin with the root of the path, which will be one of:
        • A windows drive letter, normalized to upper case, followed by : and the separator
        • The windows network path start \\
        • Just the separator, in the case of the unix root
        After the path root will follow all path components, separated with the given separator. The separator will not be appended to the end of the path. Some example paths returned by this method are:
        • C:\temp\downloads
        • /
        • \\files\documents
          Parameters:
          separator - the separator to use when constructing the path
          Returns:
          the path string for this path using the specified path separator
        • join

          public ResourcePath join​(String otherPath)
          Takes the specified path fragment and joins it with this ResourcePath to create a new ResourcePath. The specified path can use either \ or / separator characters (or a mix of the two), and it can include . or .. elements in the path, which will be traversed appropriately. The path can start and/or end with a separator character, but it should not start with a windows drive letter or network root. The resulting path will have the same root as this path. Some examples:
          • "/usr/local".join("lib/java") -> "/usr/local/lib/java"
          • "/usr/local".join("/..") -> "/usr"
          • "/usr/local".join("/.") -> "/usr/local
          If .. path elements would lead to traversing backwards past the root element, an IllegalArgumentException will be thrown. An IllegalArgumentException will also be thrown if otherPath is null.
          Parameters:
          otherPath - the path to join with this one
          Returns:
          a ResourcePath that results from appending otherPath to this path and then normalizing the result
        • equals

          public boolean equals​(Object obj)
          Two ResourcePath objects are considered to be equal if they represent the same leaf path and if their parents are equal. Note that currently the name matching is case-sensitive, even when this is being called on a case-insensitive file system.
          Overrides:
          equals in class Object
          Parameters:
          obj - the other object
          Returns:
          true if the objects are equal, false otherwise
        • hashCode

          public int hashCode()
          Overrides:
          hashCode in class Object
        • isDescendant

          public boolean isDescendant​(ResourcePath path)