Package com.pnfsoftware.jeb.util.base
Class PathProcessor
java.lang.Object
com.pnfsoftware.jeb.util.base.PathProcessor
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 Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionStandard constructor.PathProcessor
(Map<String, String> smap) Construct a processor with a custom environment map. -
Method Summary
Modifier and TypeMethodDescriptionDecode multiple flexi-paths, composed of one or more flexi-paths separated by semi-columns.Decode a single flexi-path.Decode a simple path (no flexi path), by injecting environment variable into it.Inject Environment variables into a String using $var or %var%.
-
Field Details
-
ENV
-
-
Constructor Details
-
PathProcessor
public PathProcessor()Standard constructor. -
PathProcessor
Construct a processor with a custom environment map. Usage is discouraged.- Parameters:
smap
-
-
-
Method Details
-
decodeFlexiMultiPath
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
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
Decode a simple path (no flexi path), by injecting environment variable into it. In addition tosubstituteEnvironmentVariables(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
Inject Environment variables into a String using $var or %var%.- Parameters:
p
- path with environment variables- Returns:
- the resulting real path
-