Package uk.ac.starlink.ttools.task
Class Setting
java.lang.Object
uk.ac.starlink.ttools.task.Setting
Defines a key-value pair for use in a stilts command line.
This representation focuses on the text values; there is not
much in the way of type safety, which should be enforced if
possible by earlier processing.
The equality constraint is required to aid factorisation.
- Since:
- 15 Sep 2017
- Author:
- Mark Taylor
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionappendSuffix
(String suffix) Creates a new setting object which resembles this one, but whose parameter name is modified by addition of a given trailing string.boolean
Returns the credibility of this setting.getKey()
Returns this setting's parameter name.Returns the typed value for this setting, if known.Returns the string representation of the default value for this setting.Returns the string representation of this setting's value.int
hashCode()
boolean
Indicates whether this setting's value is the same as the default value.resetDefault
(String strDflt) Creates a new setting object which resembles this one, except it has a different default value.void
setCredibility
(Credibility cred) Sets the credibility of this setting.void
setObjectValue
(Object objValue) Sets the typed value associated with this setting.static String
shellQuote
(String txt) Quotes a string as required for use on a shell command line.toString()
-
Constructor Details
-
Setting
Constructs a setting. The attributes set here are immutable and constitute the items used to assess equality.- Parameters:
key
- stilts parameter namestrValue
- string representation of stilts parameter value; corresponds to actual valuestrDflt
- string representation of stilts parameter default
-
-
Method Details
-
getKey
Returns this setting's parameter name.- Returns:
- key string
-
getStringValue
Returns the string representation of this setting's value.- Returns:
- string value
-
getStringDefault
Returns the string representation of the default value for this setting.- Returns:
- default value
-
isDefaultValue
public boolean isDefaultValue()Indicates whether this setting's value is the same as the default value. If so, for most purposes, specifying it has no effect.- Returns:
- true iff this setting's value and default are equivalent
-
setObjectValue
Sets the typed value associated with this setting. This is optional, but if present gives to the typed value that the parameter would assume, corresponding to the string value.- Parameters:
objValue
- typed value for setting
-
getObjectValue
Returns the typed value for this setting, if known.- Returns:
- setting value as a typed object, or null if not known
-
setCredibility
Sets the credibility of this setting. The default value isCredibility.YES
.- Parameters:
cred
- credibility level
-
getCredibility
Returns the credibility of this setting. The default value isCredibility.YES
.- Returns:
- credibility level
-
appendSuffix
Creates a new setting object which resembles this one, but whose parameter name is modified by addition of a given trailing string.- Parameters:
suffix
- string to append to parameter name- Returns:
- new setting object with suffix
-
resetDefault
Creates a new setting object which resembles this one, except it has a different default value.- Parameters:
strDflt
- new default string- Returns:
- new setting object with adjusted default
-
hashCode
public int hashCode() -
equals
-
toString
-
shellQuote
Quotes a string as required for use on a shell command line. I'm thinking of bash, but hopefully the rules will work reasonably well for any not-too-weird Un*x shell, and ideally other things like whatever MS Windows uses for a command line too.- Parameters:
txt
- string to quote- Returns:
- text suitable for use on the command line; some quoting may have been added if required
-