public class PathUtils extends Object
Modifier and Type | Method and Description |
---|---|
static URI |
changePath(URI base,
String newPath)
Changes the path in base to newPath.
|
static URI |
concatenate(URI base,
String subPath)
If the sub path is
null , the base is returned; else a new
URI with the concatenated path is returned. |
static String |
duplicateName(String path,
int dupNum)
Constructs a duplicate file name from original plus given number tag.
|
static URI[] |
enumerateAncestorsExcludeSelf(URI uri) |
static String |
extractSymlink(String listLine)
Presumes listLine follows standard UNIX formatting, with 'l' as first
character on line, and symlink indicated by '->'.
|
static String[] |
findCommonPrefix(URI u0,
URI u1)
Tries to determine the path from root to the nearest common ancestor of
the two uri paths, if any.
|
static String |
getName(URI uri)
Derives name from uri.
|
static String |
getNormalizedPath(URI uri) |
static URI |
getParent(URI uri)
Derives parent uri from uri.
|
static String |
getRelativePath(URI base,
URI full)
Determines the relative path of the second URI with respect to the first.
|
static String |
getRelativePath(URI base,
URI full,
boolean strict)
Determines the relative path of the second URI with respect to the first.
|
static String |
getURIName(String forwardSlashPath)
Path is parsed using '/' as separator.
|
static String |
getURIName(URI uri)
Derives name from uri; calls overloaded method.
|
static String |
getURIParent(String forwardSlashPath) |
static String |
nextDuplicateName(String name,
Map duplicatePaths)
Retrieves the next duplicate id number from the map and modifies the name
accordingly.
|
public static URI changePath(URI base, String newPath) throws URISyntaxException
base
- uri to which to concatenate the subpath.newPath
- to replace the base path.URISyntaxException
public static URI concatenate(URI base, String subPath) throws URISyntaxException
null
, the base is returned; else a new
URI with the concatenated path is returned.
All backslashes (\) will be replaced by forward slashes (/) in the subpath before the path is given to the URI constructor.
base
- uri to which to concatenate the subpath.subPath
- to affix to the base.URISyntaxException
public static String duplicateName(String path, int dupNum) throws URISyntaxException
path
- for which to find the tag.dupNum
- tag to add.URISyntaxException
public static URI[] enumerateAncestorsExcludeSelf(URI uri) throws URISyntaxException
URISyntaxException
public static String extractSymlink(String listLine)
public static String[] findCommonPrefix(URI u0, URI u1)
u0
- file or directory uri.u1
- file or directory uri.public static String getName(URI uri)
uri
- whose path to get name of.public static String getNormalizedPath(URI uri)
public static URI getParent(URI uri) throws URISyntaxException
uri
- to get parent of.URISyntaxException
public static String getRelativePath(URI base, URI full) throws URISyntaxException
base
- to which the returned path is relative.full
- of which to find path relative to base.URISyntaxException
public static String getRelativePath(URI base, URI full, boolean strict) throws URISyntaxException
base
- to which the returned path is relative.full
- of which to find path relative to base.strict
- if true, schema, host and ports of the two uris must match.URISyntaxException
public static String getURIName(String forwardSlashPath)
forwardSlashPath
- whose path to get name of.public static String getURIName(URI uri)
uri
- whose path to get name of.public static String nextDuplicateName(String name, Map duplicatePaths)
name
- for which to find the tag.duplicatePaths
- in which to search for duplicate paths.Copyright © 2017. All rights reserved.