@NotThreadSafe public static class Paths.Normalizer extends Object
| Modifier and Type | Field and Description |
|---|---|
private StringBuilder |
buffer |
private String |
path |
private char |
separatorChar |
| Constructor and Description |
|---|
Paths.Normalizer(char separatorChar) |
| Modifier and Type | Method and Description |
|---|---|
private int |
normalize(int collapse,
int end)
This is a recursive call: The top level call should provide
0 as the skip parameter, the length
of the path as the end parameter and an empty string
buffer as the result parameter. |
String |
normalize(String path)
Removes all redundant separators, dot directories (
".") and
dot-dot directories ("..") from the given path name and
returns the result. |
private void |
slashify() |
private final StringBuilder buffer
private String path
private final char separatorChar
private int normalize(int collapse,
int end)
0 as the skip parameter, the length
of the path as the end parameter and an empty string
buffer as the result parameter.collapse - the number of adjacent dir/.. segments in
the path to collapse.
This value must not be negative.end - the current position in path.
Only the string to the left of this index is considered.
If not positive, nothing happens.public String normalize(String path)
".") and
dot-dot directories ("..") from the given path name and
returns the result.
If present, a single trailing separator character is retained,
except after a dot-dot directory which couldn't get erased.
A resulting single dot-directory is truncated to an empty path.
On Windows, a path may be prefixed by a drive letter followed by a colon. On all platforms, a path may be prefixed by two leading separators to indicate a UNC, although this is currently only supported on Windows.
path - the non-null path name to normalize.path if it was already in normalized form.
Otherwise, a new string with the normalized form of the
given path name.private void slashify()
Copyright © 2004-2011 Schlichtherle IT Services. All Rights Reserved.