Class Path
Path of a document. Similar to a file path. The path consists of multiple segments separated by the character '/'.
Examples:
images/christmas/img001.png
documents/sales/axonivy.docx
- API:
- This is a public API.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionExample:
Path path = new Path("documents/sales").append(new Path("January/axonivy.docx"));
Boolean isTrue = path.equals(new Path("documents/sales/January/axonivy.docs");Example:
Path path = new Path("documents/sales").append("January/axonivy.docx");
Boolean isTrue = path.equals(new Path("documents/sales/January/axonivy.docs");asString()
String representation of the pathboolean
Example:
Boolean isTrue = new Path("documents/sales/January").endsWith(new Path("sales/January"));
Example:
String lastSegment = new Path("documents/axonivy.docx").getLastSegment();
Boolean isTrue = lastSegment.equals("axonivy.docx");getSegment
(int index) Example:
String segment = new Path("documents/sales/January/axonivy.docx").getSegment(1);
Boolean isTrue = segment.equals("sales");boolean
isPostfixOf
(Path path) Example:
Boolean isTrue = new Path("sales/January").isPostfixOf(new Path("documents/sales/January"));
boolean
isPrefixOf
(Path path) Example:
Boolean isTrue = new Path("documents/sales").isPrefixOf(new Path("documents/sales/January"));
relativize
(Path parentPath) Example:
Path relativePath = new Path("documents/sales/January/axonivy.docx").relativize(new Path("documents/sales"))
Boolean isTrue = relativePath.equals(new Path("January/axonivy.docx"));int
boolean
startsWith
(Path prefix) Example:
Boolean isTrue = new Path("documents/sales/January").startsWith(new Path("documents/sales"));
-
Constructor Details
-
Path
Creates a path with the given string representation of the path.
Example:
Path path = new Path("documents/sales/axonivy.docx");
- Parameters:
path
- string path- API:
- This public API is available in Java.
-
Path
Creates a path with the given path segments.
Example:
Path path = new Path("documents", "sales", "axonivy.docx");
- Parameters:
pathSegments
-- API:
- This public API is available in Java.
-
Path
Creates a path with the given path segments.
Example:
Path path = new Path(["documents", "sales", "axonivy.docx"]);
- Parameters:
segments
-- API:
- This public API is available in Java.
-
-
Method Details
-
asString
String representation of the path- Returns:
- string representation of the path
- API:
- This public API is available in Java.
-
isPrefixOf
Example:
Boolean isTrue = new Path("documents/sales").isPrefixOf(new Path("documents/sales/January"));
- Parameters:
path
-- Returns:
- true if this path is a prefix of the given path, otherwise false
- API:
- This public API is available in Java.
-
startsWith
Example:
Boolean isTrue = new Path("documents/sales/January").startsWith(new Path("documents/sales"));
- Parameters:
prefix
-- Returns:
- true if this path starts with the given prefix path, otherwise false
- API:
- This public API is available in Java.
-
isPostfixOf
Example:
Boolean isTrue = new Path("sales/January").isPostfixOf(new Path("documents/sales/January"));
- Parameters:
path
-- Returns:
- true if this path is a postfix of the given path, otherwise false
- API:
- This public API is available in Java.
-
endsWith
Example:
Boolean isTrue = new Path("documents/sales/January").endsWith(new Path("sales/January"));
- Parameters:
postfix
-- Returns:
- true if this path ends with the given postfix path, otherwise false
- API:
- This public API is available in Java.
-
append
Example:
Path path = new Path("documents/sales").append(new Path("January/axonivy.docx"));
Boolean isTrue = path.equals(new Path("documents/sales/January/axonivy.docs");- Parameters:
path
-- Returns:
- a new path that starts with this path and ends with the given path
- API:
- This public API is available in Java.
-
append
Example:
Path path = new Path("documents/sales").append("January/axonivy.docx");
Boolean isTrue = path.equals(new Path("documents/sales/January/axonivy.docs");- Parameters:
path
-- Returns:
- a new path that starts with this path and ends with the given path
- API:
- This public API is available in Java.
-
getLastSegment
Example:
String lastSegment = new Path("documents/axonivy.docx").getLastSegment();
Boolean isTrue = lastSegment.equals("axonivy.docx");- Returns:
- the last segment of the path. Empty string if path has no segments
- API:
- This public API is available in Java.
-
relativize
Example:
Path relativePath = new Path("documents/sales/January/axonivy.docx").relativize(new Path("documents/sales"))
Boolean isTrue = relativePath.equals(new Path("January/axonivy.docx"));- Parameters:
parentPath
-- Returns:
- relative path of the end of this path with the given parent path removed
- API:
- This public API is available in Java.
-
segmentCount
public int segmentCount()- Returns:
- number of segments this path consists of
- API:
- This public API is available in Java.
-
getSegment
Example:
String segment = new Path("documents/sales/January/axonivy.docx").getSegment(1);
Boolean isTrue = segment.equals("sales");- Parameters:
index
- segment index [0..segmentCount()-1]- Returns:
- segment at given index
- API:
- This public API is available in Java.
-