Package com.yahoo.path
Class Path
java.lang.Object
com.yahoo.path.Path
Represents a path as a list of elements. Immutable.
- Author:
- Ulf Lilleengen, bratseth
-
Method Summary
Modifier and TypeMethodDescriptionAppends a path to another path, thereby creating a new path with the provided path appended to this.Append an element to the path.static Path
Create an empty root path with '/' delimiter.static Path
createRoot
(String delimiter) Create an empty root path with delimiter.elements()
Returns an immutable list of the elements of this path in orderboolean
static Path
Creates a new path with the given segments.static Path
fromString
(String path) Creates a path from a string.static Path
fromString
(String path, String delimiter) Create a path from a string.Returns a string representation of this path where the delimiter is prependedReturns the child path: A path containing all elements of this except the firstgetName()
Returns the name of this path element, typically the last element in the path stringReturns the parent path: A path containing all elements of this except the lastReturns a string representation of the path represented by thisint
hashCode()
boolean
Returns whether this path is an immediate child of the given pathboolean
isRoot()
iterator()
last()
Returns the last element in this, or the empty string if this path is emptytoFile()
toString()
Returns this as a stringReturns a new path with the last element replaced by the given element.
-
Method Details
-
from
Creates a new path with the given segments. -
isChildOf
Returns whether this path is an immediate child of the given path -
append
Append an element to the path. Returns a new path with the given path appended.- Parameters:
path
- the path to append to this- Returns:
- the new path
-
append
Appends a path to another path, thereby creating a new path with the provided path appended to this.- Parameters:
path
- the path to append- Returns:
- a new path with argument appended to it
-
getName
Returns the name of this path element, typically the last element in the path string -
getRelative
Returns a string representation of the path represented by this -
getParentPath
Returns the parent path: A path containing all elements of this except the last -
getChildPath
Returns the child path: A path containing all elements of this except the first -
last
Returns the last element in this, or the empty string if this path is empty -
withLast
Returns a new path with the last element replaced by the given element.- Throws:
IllegalStateException
- if this path is empty
-
getAbsolute
Returns a string representation of this path where the delimiter is prepended -
isRoot
public boolean isRoot() -
iterator
-
elements
Returns an immutable list of the elements of this path in order -
toString
Returns this as a string -
fromString
Creates a path from a string. The string is treated as a relative path, and all redundant '/'-characters are stripped.- Parameters:
path
- the relative path that this path should represent- Returns:
- a path object that may be used with the application package
-
fromString
Create a path from a string. The string is treated as a relative path, and all redundant delimiter-characters are stripped.- Parameters:
path
- the relative path that this path should represent- Returns:
- a path object that may be used with the application package
-
createRoot
Create an empty root path with '/' delimiter.- Returns:
- an empty root path that can be appended
-
createRoot
Create an empty root path with delimiter.- Returns:
- an empty root path that can be appended
-
toFile
-
hashCode
public int hashCode() -
equals
-