public class

PathProcessor

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

Class Overview

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.

Summary

Fields
public static final PathProcessor ENV
Public Constructors
PathProcessor()
Standard constructor.
PathProcessor(Map<String, String> smap)
Construct a processor with a custom environment map.
Public Methods
List<String> decodeFlexiMultiPath(String mp)
Decode multiple flexi-paths, composed of one or more flexi-paths separated by semi-columns.
String decodeFlexiPath(String p)
Decode a single flexi-path.
String decodeSinglePath(String p)
Decode a simple path (no flexi path), by injecting environment variable into it.
String substituteEnvironmentVariables(String p)
Inject Environment variables into a String using $var or %var%.
[Expand]
Inherited Methods
From class java.lang.Object

Fields

public static final PathProcessor ENV

Public Constructors

public PathProcessor ()

Standard constructor.

public PathProcessor (Map<String, String> smap)

Construct a processor with a custom environment map. Usage is discouraged.

Public Methods

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

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

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

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