Class PathFence

java.lang.Object
org.apache.commons.text.lookup.PathFence

final class PathFence extends Object
A Path fence guards against using paths outside of a "fence" of made of root paths. Keep package-private.
  • Field Details

    • roots

      private final List<Path> roots
      A fence is made of Paths guarding Path resolution.
  • Constructor Details

    • PathFence

      private PathFence(PathFence.Builder builder)
      Constructs a new instance.
      Parameters:
      builder - A builder.
  • Method Details

    • builder

      static PathFence.Builder builder()
      Creates a new builder.
      Returns:
      a new builder.
    • apply

      Path apply(String fileName)
      Gets a Path for the given file name checking that it resolves within our fence.
      Parameters:
      fileName - the file name to resolve.
      Returns:
      a fenced Path.
      Throws:
      IllegalArgumentException - if the file name is not without our fence.