public class PathNormalizer extends Object
Modifier and Type | Method and Description |
---|---|
static PathNormalizer |
createNormalizer()
Creates
PathNormalizer that uses filesystem I/O calls (i.e. |
static PathNormalizer |
createNormalizer(Path basedir)
Creates
PathNormalizer optimized for use with PathMatcher . |
static PathNormalizer |
createNormalizer(String memento)
Creates
PathNormalizer using value returned by getMemento() |
static Path |
getCanonicalPath(Path file) |
String |
getMemento()
Returns memento string which can be passed to
createNormalizer(String) . |
String |
normalize(Path path)
File path normalization implementation optimized for use with
PathMatcher . |
String |
normalize(String file)
File path normalization implementation optimized for use with
PathMatcher . |
static String |
normalize0(Path file)
Returns canonical normalized file path, which on all platforms means:
the path is resolved similarly to
File.getCanonicalPath()
the path starts with '/'
the path uses '/' file separator char
|
static String |
normalize0(String file) |
static Path |
toPath(String file) |
public static PathNormalizer createNormalizer(Path basedir)
PathNormalizer
optimized for use with PathMatcher
.
Paths under the provided basedir
are not normalized using filesystem I/O calls (i.e.
File.getCanonicalFile()
or similar) and may contain '../' and './' special directories
after normalization.public static PathNormalizer createNormalizer(String memento)
PathNormalizer
using value returned by getMemento()
public static PathNormalizer createNormalizer()
PathNormalizer
that uses filesystem I/O calls (i.e.
File.getCanonicalFile()
or similar) to normalize all paths.public String getMemento()
createNormalizer(String)
. The main
usecase is to recreate PathNormalizer
in another JVM running on the same system.public String normalize(String file)
PathMatcher
.
Normalized path may include '../' and './' special directory names, which are resolved by
PathMatcher
.public String normalize(Path path)
PathMatcher
.
Normalized path may include '../' and './' special directory names, which are resolved by
PathMatcher
.public static String normalize0(Path file)
File.getCanonicalPath()
Copyright © 2021. All rights reserved.