public abstract class PathType extends Object
Modifier and Type | Class and Description |
---|---|
static class |
PathType.ParseResult
Simple result of parsing a path.
|
Modifier | Constructor and Description |
---|---|
protected |
PathType(boolean allowsMultipleRoots,
char separator,
char... otherSeparators) |
Modifier and Type | Method and Description |
---|---|
boolean |
allowsMultipleRoots()
Returns whether or not this type of path allows multiple root directories.
|
protected PathType.ParseResult |
emptyPath()
Returns an empty path.
|
PathType.ParseResult |
fromUri(URI uri)
Parses a path from the given URI.
|
String |
getOtherSeparators()
Returns the other separators that are recognized when parsing a path.
|
String |
getSeparator()
Returns the canonical separator for this path type.
|
com.google.common.base.Joiner |
joiner()
Returns the path joiner for this path type.
|
abstract PathType.ParseResult |
parsePath(String path)
Parses the given strings as a path.
|
protected abstract PathType.ParseResult |
parseUriPath(String uriPath)
Parses a path from the given URI path.
|
com.google.common.base.Splitter |
splitter()
Returns the path splitter for this path type.
|
abstract String |
toString(String root,
Iterable<String> names)
Returns the string form of the given path.
|
URI |
toUri(URI fileSystemUri,
String root,
Iterable<String> names,
boolean directory)
Creates a URI for the path with the given root and names in the file system with the given URI.
|
protected abstract String |
toUriPath(String root,
Iterable<String> names,
boolean directory)
Returns the string form of the given path for use in the path part of a URI.
|
static PathType |
unix()
Returns a Unix-style path type.
|
static PathType |
windows()
Returns a Windows-style path type.
|
protected PathType(boolean allowsMultipleRoots, char separator, char... otherSeparators)
public static PathType unix()
public static PathType windows()
As much as possible, this implementation follows the information provided in this article. Paths with drive-letter roots (e.g. "C:\") and paths with UNC roots (e.g. "\\host\share\") are supported.
Two Windows path features are not currently supported as they are too Windows-specific:
public final boolean allowsMultipleRoots()
public final String getSeparator()
public final String getOtherSeparators()
public final com.google.common.base.Joiner joiner()
public final com.google.common.base.Splitter splitter()
protected final PathType.ParseResult emptyPath()
public abstract PathType.ParseResult parsePath(String path)
InvalidPathException
- if the path isn't valid for this path typepublic abstract String toString(@Nullable String root, Iterable<String> names)
protected abstract String toUriPath(String root, Iterable<String> names, boolean directory)
directory
boolean indicates whether the file the URI is for is
known to be a directory.protected abstract PathType.ParseResult parseUriPath(String uriPath)
InvalidPathException
- if the given path isn't valid for this path typepublic final URI toUri(URI fileSystemUri, String root, Iterable<String> names, boolean directory)
public final PathType.ParseResult fromUri(URI uri)
Copyright © 2013–2018 Google Inc.. All rights reserved.