Class NodeFileSeparator
- java.lang.Object
-
- hudson.plugins.project_inheritance.util.NodeFileSeparator
-
public class NodeFileSeparator extends Object
This class implements the ability to efficiently look up the file separator used for each Node.This is relevant for determining the correct path to the workspace and avoids using "/" on Windows or "\" on Unix.
It is a singleton, because there's no point to individual instances.
- Author:
- mhschroe
-
-
Field Summary
Fields Modifier and Type Field Description static NodeFileSeparator
instance
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
ensurePathCorrect(Node n, String path)
Ensures that the given path uses the right file separator for the given node.String
getSepFor(Node n)
Returns the separator for that node -- if possible to be retrieved.
-
-
-
Field Detail
-
instance
public static final NodeFileSeparator instance
-
-
Method Detail
-
ensurePathCorrect
public String ensurePathCorrect(Node n, String path)
Ensures that the given path uses the right file separator for the given node.If the separator can't be determined, is invalid, or the node is null, the path is returned unmodified.
- Parameters:
n
- the nodepath
- the path to ensure correctness for- Returns:
- a path with correct separators, or the original, if the separator could not be determined.
-
getSepFor
public String getSepFor(Node n)
Returns the separator for that node -- if possible to be retrieved.Guaranteed to always be either "/", "\\" or null.
The result is cached, so that repeated lookups are sped-up and random node offlining does not affect the separator calculation as much.
- Parameters:
n
- the node to check.- Returns:
- the separator, one of "/", "\\" or null.
-
-