Package com.mastfrog.util.path
Interface UnixPath
- All Known Implementing Classes:
ComponentUPath
Platform-independent implementation of java.nio.file.Path allowing for
consistency across Unix and Windows; useful for doing path transforms and as
keys where it is imperative that the path separator be '/'
no matter what. Has some caveats - particularly cannot be mixed with
system path instances in a collection which will be sorted, because UnixPath
assumes all paths are UnixPaths; may fail or do the wrong thing if passed
directly to java.nio.Files. Used in particular as path keys in the JFS
filesystem for NetBeans antlr support.
The behavior of instances retrieved from the factory methods should be identical with sun.nio.UnixPath, which is not public in the JDK.
Note the iterator will contain instances of UnixPath, though the API does not allow them to be typed as such.- Author:
- Tim Boudreau
-
Method Summary
Modifier and TypeMethodDescriptiondefault intProvides consistent, platform-indepenedent ordering: absolute is greater than non-absolute; greater name count is greater than lesser name count; if same name count, name elements are compared as case-sensitive strings.static UnixPathempty()static UnixPathdefault Stringstatic UnixPathstatic UnixPathstatic UnixPathstatic UnixPathgetName(int index) getRoot()default booleanisEmpty()default booleanisExtension(String ext) default booleanDetermine if this path contains no "." or ".." elements.default StringrawName()relativize(Path other) resolveSibling(String other) resolveSibling(Path other) subpath(int beginIndex, int endIndex) default PathConvert this path to the native equivalent retrieved from Paths.get() (if this involves Windows drive letters, all bets are off).default StringtoString(char separator) default intvisitNames(Consumer<String> consumer) Methods inherited from interface java.lang.Iterable
forEach, spliteratorMethods inherited from interface java.nio.file.Path
endsWith, endsWith, equals, getFileSystem, getNameCount, hashCode, isAbsolute, iterator, register, register, startsWith, startsWith, toFile, toRealPath, toString, toUri
-
Method Details
-
empty
-
emptyAbsolute
-
get
-
get
-
get
-
get
-
toRelativePath
UnixPath toRelativePath() -
toAbsolutePath
UnixPath toAbsolutePath()- Specified by:
toAbsolutePathin interfacePath
-
relativize
- Specified by:
relativizein interfacePath
-
resolveSibling
- Specified by:
resolveSiblingin interfacePath
-
resolveSibling
- Specified by:
resolveSiblingin interfacePath
-
resolve
-
resolve
-
normalize
UnixPath normalize() -
subpath
-
getName
-
getParent
UnixPath getParent() -
getRoot
UnixPath getRoot() -
getFileName
UnixPath getFileName()- Specified by:
getFileNamein interfacePath
-
toNativePath
Convert this path to the native equivalent retrieved from Paths.get() (if this involves Windows drive letters, all bets are off).- Returns:
- A native path suitable for use with Files
-
isNormalized
default boolean isNormalized()Determine if this path contains no "." or ".." elements.- Returns:
- True if the path is normalized
-
visitNames
-
extension
-
rawName
-
isExtension
-
toString
-
isEmpty
default boolean isEmpty() -
compareTo
Provides consistent, platform-indepenedent ordering: absolute is greater than non-absolute; greater name count is greater than lesser name count; if same name count, name elements are compared as case-sensitive strings.- Specified by:
compareToin interfaceComparable<Path>- Specified by:
compareToin interfacePath- Parameters:
other- The other path- Returns:
-