Package org.eclipse.cdt.utils.envvar
Class EnvVarOperationProcessor
java.lang.Object
org.eclipse.cdt.utils.envvar.EnvVarOperationProcessor
This is an utility class that implements environment variable operations
functionality: append, prepend, replace and remove
- Since:
- 3.0
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionconvertToList
(String value, String delimiter) Converts a given value to string using a delimiter passed to this methodstatic String
convertToString
(List<String> list, String delimiter) Converts list to a single String using a given delimiter to separate the list value in the resulting Stringstatic IEnvironmentVariable[]
filterVariables
(IEnvironmentVariable[] variables, String[] remove) static String
normalizeName
(String name) normalizes the variable name.static String
performAppend
(String initialValue, String addValue, String delimiter) performs append given an initial String, a string to be appended and a delimiter Returns a String representing the result of the operationstatic String
performAppendPrepend
(String initialValue, String addValue, String delimiter, boolean prepend) performs append or prepend given an initial String, a string to be appended/prepended and a delimiter Returns a String representing the result of the operationstatic String
performOperation
(String initialValue, String newValue, String delimiter, int op) performs an environment variable operation Returns String representing the result of the operationstatic IEnvironmentVariable
performOperation
(IEnvironmentVariable initial, IEnvironmentVariable added) performs the environment variable operation given an initial variable and a variable representing an operation to be performed Returns a new variable the represents the result of a performed operationstatic String
performPrepend
(String initialValue, String addValue, String delimiter) performs prepend given an initial String, a string to be prepended and a delimiter Returns a String representing the result of the operationremoveDuplicates
(List<String> value, List<String> duplicates) removes duplicates
-
Constructor Details
-
EnvVarOperationProcessor
public EnvVarOperationProcessor()
-
-
Method Details
-
performOperation
public static IEnvironmentVariable performOperation(IEnvironmentVariable initial, IEnvironmentVariable added) performs the environment variable operation given an initial variable and a variable representing an operation to be performed Returns a new variable the represents the result of a performed operation- Parameters:
initial
- the initial variableadded
- the variable that specifies an operation to be performed on the initial variable value- Returns:
- the new variable the represents the result of a performed operation
-
performAppendPrepend
public static String performAppendPrepend(String initialValue, String addValue, String delimiter, boolean prepend) performs append or prepend given an initial String, a string to be appended/prepended and a delimiter Returns a String representing the result of the operation- Parameters:
initialValue
-addValue
-delimiter
-prepend
-- Returns:
- String
-
performAppend
performs append given an initial String, a string to be appended and a delimiter Returns a String representing the result of the operation- Parameters:
initialValue
-addValue
-delimiter
-- Returns:
- String
-
performPrepend
performs prepend given an initial String, a string to be prepended and a delimiter Returns a String representing the result of the operation- Parameters:
initialValue
-addValue
-delimiter
-- Returns:
- String
-
performOperation
public static String performOperation(String initialValue, String newValue, String delimiter, int op) performs an environment variable operation Returns String representing the result of the operation- Parameters:
initialValue
-newValue
-delimiter
-op
-- Returns:
- String
-
convertToList
Converts a given value to string using a delimiter passed to this method- Parameters:
value
-delimiter
-
-
removeDuplicates
removes duplicates -
convertToString
Converts list to a single String using a given delimiter to separate the list value in the resulting String- Parameters:
list
-delimiter
-- Returns:
- String
-
normalizeName
normalizes the variable name. That is: removes prepended and appended spaces- Returns:
- the normalized name or
null
in case the name is not valid
-
filterVariables
public static IEnvironmentVariable[] filterVariables(IEnvironmentVariable[] variables, String[] remove)
-