Package tv.hd3g.processlauncher.cmdline
Class SimpleParameters
- java.lang.Object
-
- tv.hd3g.processlauncher.cmdline.SimpleParameters
-
- Direct Known Subclasses:
Parameters
public class SimpleParameters extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static List<Character>MUST_ESCAPEstatic List<Character>MUST_SURROUND_QUOTE
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAllFrom(SimpleParameters source)Don't touch to actual parameters, and clone from source.SimpleParametersaddBulkParameters(String params)SimpleParametersaddParameters(String... params)SimpleParametersaddParameters(Collection<String> params)booleanalterParameter(String parameterKey, String newValue, int paramAsThisKeyPos)SimpleParametersclear()voidcompareAndAlter(SimpleParameters toCompare, ArgValueChoice argValueChoice, boolean removeActualMissing, boolean addComparedMissing)protected StringconformParameterKey(String parameterKey)intcount()StringexportToExternalCommandLine(String processExecFile)Mostly in Linux/Bash mode.Map<String,List<String>>getAllArgKeyValues()List<String>getParameters()StringgetParametersKeysStartsWith()List<String>getValues(String parameterKey)booleanhasParameters(String... params)SimpleParametersifHasNotParameter(Runnable toDoIfMissing, String... inParameters)See SimpleParameters#hasParameters()SimpleParametersimportParametersFrom(SimpleParameters previousInstance)Transfer (clone) current parameters and parameterKeysStartsWithbooleanisEmpty()SimpleParametersprependBulkParameters(String params)SimpleParametersprependParameters(String... params)SimpleParametersprependParameters(Collection<String> params)booleanremoveParameter(String parametersKey, int paramAsThisKeyPos)Search a remove all parameters with paramKey as name, even associated values.SimpleParametersreplaceParameters(Collection<? extends String> newParameters)SimpleParameterssetParametersKeysStartsWith(String parameterKeysStartsWith)StringtoString()SimpleParameterstransfertThisConfigurationTo(SimpleParameters newInstance)Don't touch to current parameters, only parameterKeysStartsWith
-
-
-
Method Detail
-
transfertThisConfigurationTo
public SimpleParameters transfertThisConfigurationTo(SimpleParameters newInstance)
Don't touch to current parameters, only parameterKeysStartsWith
-
importParametersFrom
public SimpleParameters importParametersFrom(SimpleParameters previousInstance)
Transfer (clone) current parameters and parameterKeysStartsWith
-
addAllFrom
public void addAllFrom(SimpleParameters source)
Don't touch to actual parameters, and clone from source.
-
clear
public SimpleParameters clear()
-
hasParameters
public boolean hasParameters(String... params)
- Parameters:
params- (anyMatch) ; params can have "-" or not (it will be added).
-
ifHasNotParameter
public SimpleParameters ifHasNotParameter(Runnable toDoIfMissing, String... inParameters)
See SimpleParameters#hasParameters()
-
replaceParameters
public SimpleParameters replaceParameters(Collection<? extends String> newParameters)
-
addParameters
public SimpleParameters addParameters(String... params)
- Parameters:
params- don't alter params Remove null and empty
-
addParameters
public SimpleParameters addParameters(Collection<String> params)
- Parameters:
params- don't alter params Remove null and empty
-
addBulkParameters
public SimpleParameters addBulkParameters(String params)
- Parameters:
params- transform spaces in each param to new params: "a b c d" -> ["a", "b", "c", "d"], and it manage " but not tabs. Remove empty
-
prependParameters
public SimpleParameters prependParameters(Collection<String> params)
- Parameters:
params- don't alter params
-
prependParameters
public SimpleParameters prependParameters(String... params)
- Parameters:
params- add all in front of command line, don't alter params
-
prependBulkParameters
public SimpleParameters prependBulkParameters(String params)
- Parameters:
params- params add all in front of command line, transform spaces in each param to new params: "a b c d" -> ["a", "b", "c", "d"], and it manage " but not tabs.
-
exportToExternalCommandLine
public String exportToExternalCommandLine(String processExecFile)
Mostly in Linux/Bash mode.- Returns:
- with automatic escape
-
setParametersKeysStartsWith
public SimpleParameters setParametersKeysStartsWith(String parameterKeysStartsWith)
- Parameters:
parameterKeysStartsWith- "-" by default
-
getParametersKeysStartsWith
public String getParametersKeysStartsWith()
- Returns:
- "-" by default
-
conformParameterKey
protected String conformParameterKey(String parameterKey)
- Parameters:
parameterKey- add "-" in front of paramKey if needed
-
getValues
public List<String> getValues(String parameterKey)
- Parameters:
parameterKey- can have "-" or not (it will be added).- Returns:
- For "-param val1 -param val2 -param val3" -> val1, val2, val3 ; null if parameterKey can't be found, empty if not values for param
-
removeParameter
public boolean removeParameter(String parametersKey, int paramAsThisKeyPos)
Search a remove all parameters with paramKey as name, even associated values.- Parameters:
parametersKey- can have "-" or not (it will be added).
-
alterParameter
public boolean alterParameter(String parameterKey, String newValue, int paramAsThisKeyPos)
- Parameters:
parameterKey- can have "-" or not (it will be added).- Returns:
- true if done
-
count
public int count()
-
isEmpty
public boolean isEmpty()
-
compareAndAlter
public void compareAndAlter(SimpleParameters toCompare, ArgValueChoice argValueChoice, boolean removeActualMissing, boolean addComparedMissing)
- Parameters:
argValueChoice- policy to apply if some args keys a in common with actual and toCompareremoveActualMissing- remove all current args not founded in toCompare args listaddComparedMissing- add all args from toCompare args list for some not found in actual args list- See Also:
getAllArgKeyValues()
-
-