Package org.gradle.api.file
Class RelativePath
java.lang.Object
org.gradle.api.file.RelativePath
- All Implemented Interfaces:
Serializable
,CharSequence
,Comparable<RelativePath>
public class RelativePath
extends Object
implements Serializable, Comparable<RelativePath>, CharSequence
Represents a relative path from some base directory to a file. Used in file copying to represent both a source and target file path when copying files.
RelativePath
instances are immutable.
- See Also:
-
Field Summary
-
Constructor Summary
ConstructorDescriptionRelativePath
(boolean endsWithFile, String... segments) Creates aRelativePath
. -
Method Summary
Modifier and TypeMethodDescriptionAppends the given names to the end of this path.append
(RelativePath other) Appends the given path to the end of this path.char
charAt
(int index) int
boolean
Returns the parent of this path.String[]
int
hashCode()
boolean
isFile()
int
length()
static RelativePath
static RelativePath
parse
(boolean isFile, RelativePath parent, String path) plus
(RelativePath other) Appends the given path to the end of this path.Prepends the given names to the start of this path.replaceLastName
(String name) Returns a copy of this path, with the last name replaced with the given name.subSequence
(int start, int end) toString()
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.CharSequence
chars, codePoints, isEmpty
-
Field Details
-
EMPTY_ROOT
-
-
Constructor Details
-
RelativePath
Creates aRelativePath
.- Parameters:
endsWithFile
- - if true, the path ends with a file, otherwise a directory
-
-
Method Details
-
getSegments
-
segmentIterator
-
isFile
public boolean isFile() -
getPathString
-
length
public int length()- Specified by:
length
in interfaceCharSequence
-
charAt
public char charAt(int index) - Specified by:
charAt
in interfaceCharSequence
-
subSequence
- Specified by:
subSequence
in interfaceCharSequence
-
getFile
-
getLastName
-
equals
-
hashCode
public int hashCode() -
toString
- Specified by:
toString
in interfaceCharSequence
- Overrides:
toString
in classObject
-
getParent
Returns the parent of this path.- Returns:
- The parent of this path, or null if this is the root path.
-
parse
-
parse
-
replaceLastName
Returns a copy of this path, with the last name replaced with the given name.
- Parameters:
name
- The name.- Returns:
- The path.
-
append
Appends the given path to the end of this path.
- Parameters:
other
- The path to append- Returns:
- The new path
-
plus
Appends the given path to the end of this path.
- Parameters:
other
- The path to append- Returns:
- The new path
-
append
Appends the given names to the end of this path.- Parameters:
segments
- The names to append.endsWithFile
- when true, the new path refers to a file.- Returns:
- The new path.
-
prepend
Prepends the given names to the start of this path.- Parameters:
segments
- The names to prepend- Returns:
- The new path.
-
compareTo
- Specified by:
compareTo
in interfaceComparable<RelativePath>
-