Package org.nuxeo.common.utils
Class Path
- java.lang.Object
-
- org.nuxeo.common.utils.Path
-
- All Implemented Interfaces:
Serializable
public class Path extends Object implements Serializable
Contains code from Eclipse org.eclipse.core.runtime.Path class- Author:
- Bogdan Stefanescu
- See Also:
- Serialized Form
-
-
Method Summary
-
-
-
Constructor Detail
-
Path
public Path(String fullPath)
Constructs a new path from the given string path.The string path must represent a valid file system path on the local file system.
The path is canonicalized and double slashes are removed except at the beginning. (to handle UNC paths). All forward slashes ('/') are treated as segment delimiters, and any segment and device delimiters for the local file system are also respected (such as colon (':') and backslash ('\') on some file systems).
- Parameters:
fullPath
- the string path- See Also:
isValidPath(String)
-
-
Method Detail
-
createFromAbsolutePath
public static Path createFromAbsolutePath(String path)
Creates a path object from an absolute and canonical path.This method does not check the given path - it assumes the path has a valid format of the form "/a/b/c" without duplicate slashes or dots.
- Returns:
- the path
-
addTrailingSeparator
public Path addTrailingSeparator()
-
getFileExtension
public String getFileExtension()
-
hasTrailingSeparator
public boolean hasTrailingSeparator()
-
isAbsolute
public boolean isAbsolute()
-
isEmpty
public boolean isEmpty()
-
isPrefixOf
public boolean isPrefixOf(Path anotherPath)
-
isRoot
public boolean isRoot()
-
isValidPath
public static boolean isValidPath(String path)
-
lastSegment
public String lastSegment()
-
makeAbsolute
public Path makeAbsolute()
-
makeRelative
public Path makeRelative()
-
matchingFirstSegments
public int matchingFirstSegments(Path anotherPath)
-
removeFileExtension
public Path removeFileExtension()
-
removeFirstSegments
public Path removeFirstSegments(int count)
-
removeLastSegments
public Path removeLastSegments(int count)
-
removeTrailingSeparator
public Path removeTrailingSeparator()
-
segment
public String segment(int index)
-
segmentCount
public int segmentCount()
-
segments
public String[] segments()
-
uptoSegment
public Path uptoSegment(int count)
-
-