D - is the type of the generic data. For simple usage just Void.public class ResourcePathNode<D> extends Object implements ResourcePath, Serializable
| Modifier and Type | Class and Description |
|---|---|
static class |
ResourcePathNode.ResourcePathRootAbsolute<D>
Implementation of Unix/Linux absolute root.
|
static class |
ResourcePathNode.ResourcePathRootHome<D>
Implementation of home absolute root (~ or ~login).
|
static class |
ResourcePathNode.ResourcePathRootRelative<D>
Implementation of relative root.
|
static class |
ResourcePathNode.ResourcePathRootUnc<D>
Implementation of UNC absolute root.
|
static class |
ResourcePathNode.ResourcePathRootUrl<D>
Implementation of Unix/Linux absolute root.
|
static class |
ResourcePathNode.ResourcePathRootWindows<D>
Implementation of Windows absolute root drive.
|
| Modifier and Type | Field and Description |
|---|---|
private D |
data |
private static Function<ResourcePathNode<Pattern>,Pattern> |
GLOB_PATTERN_FUNCTION
The
Void data function. |
private String |
name |
private ResourcePathNode<D> |
parent |
static ResourcePathNode<Void> |
ROOT_ABSOLUTE
|
static ResourcePathNode<Void> |
ROOT_HOME
|
static ResourcePathNode<Void> |
ROOT_RELATIVE
|
private static long |
serialVersionUID |
private static Function<ResourcePathNode<Void>,Void> |
VOID_FUNCTION
The
Void data function. |
private static char |
WINDOWS_DRIVE_LETTER_SUFFIX
The suffix of a Windows drive letter.
|
HOME_PATH_CHAR, PATH_SEGMENT_CURRENT_DIRECTORY, PATH_SEGMENT_PARENT_DIRECTORY, PATH_SEGMENT_SEPARATOR, PATH_SEGMENT_SEPARATOR_CHAR, UNC_PATH_PREFIX, URL_SCHEME_AUTHORITY_SEPARATOR| Modifier | Constructor and Description |
|---|---|
protected |
ResourcePathNode(ResourcePathNode<D> parent,
String name,
D data)
The constructor.
|
protected |
ResourcePathNode(ResourcePathNode<D> parent,
String name,
Function<ResourcePathNode<D>,D> dataFunction)
The constructor.
|
protected |
ResourcePathNode(String name,
Function<ResourcePathNode<D>,D> dataFunction)
The constructor for a root
ResourcePathNode. |
private static final long serialVersionUID
private static final char WINDOWS_DRIVE_LETTER_SUFFIX
private static final Function<ResourcePathNode<Void>,Void> VOID_FUNCTION
Void data function.private static final Function<ResourcePathNode<Pattern>,Pattern> GLOB_PATTERN_FUNCTION
Void data function.public static final ResourcePathNode<Void> ROOT_ABSOLUTE
public static final ResourcePathNode<Void> ROOT_RELATIVE
public static final ResourcePathNode<Void> ROOT_HOME
private final ResourcePathNode<D> parent
private final String name
private final D data
protected ResourcePathNode(String name, Function<ResourcePathNode<D>,D> dataFunction)
ResourcePathNode.protected ResourcePathNode(ResourcePathNode<D> parent, String name, D data)
parent - - see getParent().name - - see getName().data - - see getData().protected ResourcePathNode(ResourcePathNode<D> parent, String name, Function<ResourcePathNode<D>,D> dataFunction)
parent - - see getParent().name - - see getName().dataFunction - - the Function to create the data.public ResourcePathNode<D> getParent()
getParent in interface ResourcePathResourcePathNode or null if this is the ResourcePath.isRoot() segment.public ResourcePathNode<D> getRoot()
getRoot in interface ResourcePathroot ancestor of this ResourcePathNode.public String getName()
getName in interface ResourcePathResourcePathNode as segment (this "folder" or "file").public boolean isAbsolute()
isAbsolute in interface ResourcePathtrue if this path is absolute, false if it is relative.public boolean isParentDirectory()
true if name is "..", false otherwise.public boolean isRoot()
isRoot in interface ResourcePathtrue if this is the root ResourcePathNode, false otherwise.protected boolean isAppendSeparator()
true if toString(StringBuilder, char) needs to append a separator after this segment,
false otherwise.public boolean matches(ResourcePathNode<Pattern> patternPath)
ResourcePathNode matches to the given pattern path.patternPath - the pattern path to match.true if this path matches the given the given patternPath.public void collectFromRoot(Collection<ResourcePathNode<D>> nodes)
nodes - is the Collection where to add the nodes.public List<ResourcePathNode<D>> asList()
List with all nodes from the root down to
this node.collectFromRoot(Collection)public ResourcePathNode<D> navigateTo(ResourcePathNode<D> path)
path - is the path to navigate to from this path.path if absolute, otherwise the normalized path of this
path with the given path appended.private ResourcePathNode<D> navigateUp()
this instance if this is the root or is ResourcePath.PATH_SEGMENT_PARENT_DIRECTORY,
the parent otherwise.private ResourcePathNode<D> navigateFrom(ResourcePathNode<D> resourcePath)
navigateTo(ResourcePathNode).resourcePath - is the ResourcePathNode to navigate from.ResourcePathNode.protected void toString(StringBuilder buffer, char separator)
buffer - is the StringBuilder where to append the string representation to.separator - is the character to separate the ResourcePathNode segments. Typically
.public String toString(char separator)
separator - is the character to separate the ResourcePathNode segments. Typically
.string representation.public static ResourcePathNode<Void> create(String path)
ResourcePathNode. Here are some examples:
path |
ResourcePathNode.create(path) |
||
|---|---|---|---|
toString() |
isAbsolute() |
getName() |
|
| "/foo//bar/" | "/foo/bar" | true | "bar" |
| "/foo/bar" | "/foo/bar" | true | "bar" |
| "a/../b/./c" | "b/c" | false | "c" |
| "a/../../" | ".." | false | ".." |
| "a/.." | "" | false | "" |
| "../a" | "../a" | false | "a" |
| "/../a" | "/a" | true | "a" |
| "~/.ssh" | "~/.ssh" | true | ".ssh" |
| "~admin/../" | "~admin/.." | true | ".." |
| "/" | "" | true | "/" |
| "" | "" | false | "" |
| null | - (null) | - (null) | - (null) |
path - is the path to parse (e.g. "/foo/bar.txt" or "a/../b/./c").path as ResourcePathNode or null if empty.public static ResourcePathNode<Pattern> createPattern(String path)
path - - see create(String).ResourcePathNode.create(String),
matches(ResourcePathNode)public static <D> ResourcePathNode<D> create(String path, Function<ResourcePathNode<D>,D> dataFunction)
create(String) to custom data function.D - is the type of the generic data. For simple usage just Void.path - is the path to parse.dataFunction - - the Function to create the data.path.private static <D> ResourcePathNode<D> createRootPathSegment(CharSequenceScanner scanner, String originalPath, Function<ResourcePathNode<D>,D> dataFunction)
D - is the type of the generic data. For simple usage just Void.scanner - the fresh CharSequenceScanner for the entire path (normalized from of originalPath).
Only the root segment shall be consumed.originalPath - is the original path without normalization of slashed (may contain backslashes).dataFunction - - the Function to create the data.root path segment.create(String),
isRoot()Copyright © 2001–2016 mmm-Team. All rights reserved.