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.
- Since:
- 0.8
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionRelativePath(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.charcharAt(int index) intbooleanReturns the file.Returns the last name.@Nullable RelativePathReturns the parent of this path.Returns the path string.String[]Returns the segments.inthashCode()booleanisFile()Returns whether file is set.intlength()static RelativePathParse.static RelativePathparse(boolean isFile, @Nullable RelativePath parent, String path) Parse.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.Segment iterator.subSequence(int start, int end) toString()Methods inherited from interface CharSequence
chars, codePoints, getChars, isEmpty
-
Field Details
-
EMPTY_ROOT
-
-
Constructor Details
-
RelativePath
Creates aRelativePath.- Parameters:
endsWithFile- - if true, the path ends with a file, otherwise a directory- Since:
- 0.8
-
-
Method Details
-
getSegments
-
segmentIterator
-
isFile
public boolean isFile()Returns whether file is set.- Since:
- 0.8
-
getPathString
-
length
public int length()- Specified by:
lengthin interfaceCharSequence
-
charAt
public char charAt(int index) - Specified by:
charAtin interfaceCharSequence
-
subSequence
- Specified by:
subSequencein interfaceCharSequence
-
getFile
-
getLastName
-
equals
-
hashCode
-
toString
- Specified by:
toStringin interfaceCharSequence- Overrides:
toStringin classObject
-
getParent
Returns the parent of this path.- Returns:
- The parent of this path, or null if this is the root path.
- Since:
- 0.8
-
parse
-
parse
Parse.- Since:
- 0.9
-
replaceLastName
Returns a copy of this path, with the last name replaced with the given name.
- Parameters:
name- The name.- Returns:
- The path.
- Since:
- 0.9
-
append
Appends the given path to the end of this path.
- Parameters:
other- The path to append- Returns:
- The new path
- Since:
- 0.9
-
plus
Appends the given path to the end of this path.
- Parameters:
other- The path to append- Returns:
- The new path
- Since:
- 0.9
-
append
Appends the given names to the end of this path.- Parameters:
endsWithFile- when true, the new path refers to a file.segments- The names to append.- Returns:
- The new path.
- Since:
- 0.9
-
prepend
Prepends the given names to the start of this path.- Parameters:
segments- The names to prepend- Returns:
- The new path.
- Since:
- 0.9
-
compareTo
- Specified by:
compareToin interfaceComparable<RelativePath>
-