Nuxeo ECM Projects 5.4.3-SNAPSHOT

org.nuxeo.common.utils
Class Path

java.lang.Object
  extended by org.nuxeo.common.utils.Path
All Implemented Interfaces:
Serializable

public class Path
extends Object
implements Serializable

Author:
Bogdan Stefanescu
See Also:
Serialized Form

Constructor Summary
Path(String fullPath)
          Constructs a new path from the given string path.
 
Method Summary
 Path addFileExtension(String extension)
           
 Path addTrailingSeparator()
           
 Path append(Path tail)
           
 Path append(String tail)
           
static Path createFromAbsolutePath(String path)
          Creates a path object from an absolute and canonical path.
static Path createFromSegments(String[] segments)
           
 boolean equals(Object obj)
           
 String getFileExtension()
           
static String getFileNameFromPath(String iconPath)
          Gets the name of the icon file so that it can be displayed as alt text.
 int hashCode()
           
 boolean hasTrailingSeparator()
           
 boolean isAbsolute()
           
 boolean isEmpty()
           
 boolean isPrefixOf(Path anotherPath)
           
 boolean isRoot()
           
static boolean isValidPath(String path)
           
 String lastSegment()
           
 Path makeAbsolute()
           
 Path makeRelative()
           
 int matchingFirstSegments(Path anotherPath)
           
 Path removeFileExtension()
           
 Path removeFirstSegments(int count)
           
 Path removeLastSegments(int count)
           
 Path removeTrailingSeparator()
           
 String segment(int index)
           
 int segmentCount()
           
 String[] segments()
           
 String toString()
           
 Path uptoSegment(int count)
           
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

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

createFromSegments

public static Path createFromSegments(String[] segments)

addFileExtension

public Path addFileExtension(String extension)

addTrailingSeparator

public Path addTrailingSeparator()

append

public Path append(Path tail)

append

public Path append(String tail)

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

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()

toString

public String toString()
Overrides:
toString in class Object

uptoSegment

public Path uptoSegment(int count)

getFileNameFromPath

public static String getFileNameFromPath(String iconPath)
Gets the name of the icon file so that it can be displayed as alt text.


Nuxeo ECM Projects 5.4.3-SNAPSHOT

Copyright © 2011 Nuxeo SAS. All Rights Reserved.