Class PathProcessor

java.lang.Object
com.pnfsoftware.jeb.util.base.PathProcessor

public class PathProcessor extends Object
The path processor class is used to resolve flexible paths (flexi-paths) and lists of multiple flexi-paths (multi-flexi-paths are flexi-paths separated by semicolons).

A flexible path can contain environment variables, Windows-style (%xxx%) or Linux-style ($xxx). It may also contain alternatives, separated by pipes and enclosed in parenthesis.

Example: /root/($FOO|user)/$BAR/dir1

When alternatives are present, the first plausible one is used.

  • Field Details

  • Constructor Details

    • PathProcessor

      public PathProcessor()
      Standard constructor.
    • PathProcessor

      public PathProcessor(Map<String,String> smap)
      Construct a processor with a custom environment map. Usage is discouraged.
      Parameters:
      smap -
  • Method Details

    • decodeFlexiMultiPath

      public List<String> decodeFlexiMultiPath(String mp)
      Decode multiple flexi-paths, composed of one or more flexi-paths separated by semi-columns.
      Parameters:
      mp - a multi-path
      Returns:
      a list of resolved paths, possibly empty
    • decodeFlexiPath

      public String decodeFlexiPath(String p)
      Decode a single flexi-path. A flexible path can contain environment variables; it may also contain alternatives, separated by pipes and enclosed in parenthesis. Example: /root/($FOO|user)/$BAR/dir1. If alternatives are present, the first plausible one is returned.
      Parameters:
      p - a flexi-path
      Returns:
      the resolved flexi-path, null on error
    • decodeSinglePath

      public String decodeSinglePath(String p)
      Decode a simple path (no flexi path), by injecting environment variable into it. In addition to substituteEnvironmentVariables(String), it consider the path as a full one, allowing to replace the first ~ by user.home. Note that it only manage the homepath of current user (~/xxx), not the one from a different user (~user)
      Parameters:
      p - path with environment variables
      Returns:
      the resulting real path
    • substituteEnvironmentVariables

      public String substituteEnvironmentVariables(String p)
      Inject Environment variables into a String using $var or %var%.
      Parameters:
      p - path with environment variables
      Returns:
      the resulting real path