Package gw.fs
Class ResourcePath
java.lang.Object
gw.fs.ResourcePath
- Direct Known Subclasses:
ResourcePath.ResourcePathHead
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final String
protected final ResourcePath
static final String
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static ResourcePath
private void
constructPathString
(StringBuilder sb, String separator) boolean
Two ResourcePath objects are considered to be equal if they represent the same leaf path and if their parents are equal.Returns the path string for this path using the default file system separator, as defined by the File.separator property.getName()
Returns the leaf name of this resource path.Returns the parent of this resource path.Returns the path string for this path using the / path separator.getPathString
(String separator) Returns the path string for this path using the specified path separator.int
hashCode()
boolean
isChild
(ResourcePath path) boolean
isDescendant
(ResourcePath path) Takes the specified path fragment and joins it with this ResourcePath to create a new ResourcePath.private static DynamicArray<String>
normalizePath
(DynamicArray<String> pathElements) static ResourcePath
relativePath
(ResourcePath other) relativePath
(ResourcePath other, String separator) private static DynamicArray<String>
tokenizePathFragment
(String pathString, int lastIndex)
-
Field Details
-
WINDOWS_NETWORK_ROOT
- See Also:
-
_parent
-
_name
-
-
Constructor Details
-
ResourcePath
-
-
Method Details
-
parse
-
tokenizePathFragment
-
normalizePath
-
construct
-
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
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
Returns the path string for this path using the / path separator.- Returns:
- the path string for this path using the / path separator.
- See Also:
-
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
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
- 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
-
constructPathString
-
join
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
- 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
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. -
hashCode
public int hashCode() -
isChild
-
isDescendant
-
relativePath
-
relativePath
-