Class Path

java.lang.Object
ch.ivyteam.ivy.workflow.document.Path

public class Path extends Object

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

    Constructors
    Constructor
    Description
    Path(String path)
    Creates a path with the given string representation of the path.
    Path(String... pathSegments)
    Creates a path with the given path segments.
    Path(List<String> segments)
    Creates a path with the given path segments.
  • Method Summary

    Modifier and Type
    Method
    Description
    append(Path path)
    Example:
    Path path = new Path("documents/sales").append(new Path("January/axonivy.docx"));
    Boolean isTrue = path.equals(new Path("documents/sales/January/axonivy.docs");
    append(String path)
    Example:
    Path path = new Path("documents/sales").append("January/axonivy.docx");
    Boolean isTrue = path.equals(new Path("documents/sales/January/axonivy.docs");
    String representation of the path
    boolean
    endsWith(Path postfix)
    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
    Example:
    Boolean isTrue = new Path("sales/January").isPostfixOf(new Path("documents/sales/January"));
    boolean
    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

      public Path(String 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 IvyScript and Java. It has the visibility NOVICE.
    • Path

      public Path(String... pathSegments)

      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 IvyScript and Java. It has the visibility NOVICE.
    • Path

      public Path(List<String> segments)

      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 IvyScript and Java. It has the visibility NOVICE.
  • Method Details

    • asString

      public String asString()
      String representation of the path
      Returns:
      string representation of the path
      API:
      This public API is available in IvyScript and Java. It has the visibility NOVICE.
    • isPrefixOf

      public boolean isPrefixOf(Path path)

      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 IvyScript and Java. It has the visibility ADVANCED.
    • startsWith

      public boolean startsWith(Path prefix)

      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 IvyScript and Java. It has the visibility NOVICE.
    • isPostfixOf

      public boolean isPostfixOf(Path path)

      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 IvyScript and Java. It has the visibility ADVANCED.
    • endsWith

      public boolean endsWith(Path postfix)

      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 IvyScript and Java. It has the visibility NOVICE.
    • append

      public Path append(Path path)

      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 IvyScript and Java. It has the visibility NOVICE.
    • append

      public Path append(String path)

      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 IvyScript and Java. It has the visibility NOVICE.
    • getLastSegment

      public String 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 IvyScript and Java. It has the visibility NOVICE.
    • relativize

      public Path 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"));

      Parameters:
      parentPath -
      Returns:
      relative path of the end of this path with the given parent path removed
      API:
      This public API is available in IvyScript and Java. It has the visibility ADVANCED.
    • segmentCount

      public int segmentCount()
      Returns:
      number of segments this path consists of
      API:
      This public API is available in IvyScript and Java. It has the visibility ADVANCED.
    • getSegment

      public String getSegment(int index)

      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 IvyScript and Java. It has the visibility ADVANCED.