Class Setting

java.lang.Object
uk.ac.starlink.ttools.task.Setting

@Equality public class Setting extends Object
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 Details

    • Setting

      public Setting(String key, String strValue, String strDflt)
      Constructs a setting. The attributes set here are immutable and constitute the items used to assess equality.
      Parameters:
      key - stilts parameter name
      strValue - string representation of stilts parameter value; corresponds to actual value
      strDflt - string representation of stilts parameter default
  • Method Details

    • getKey

      public String getKey()
      Returns this setting's parameter name.
      Returns:
      key string
    • getStringValue

      public String getStringValue()
      Returns the string representation of this setting's value.
      Returns:
      string value
    • getStringDefault

      public String 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

      public void setObjectValue(Object objValue)
      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

      public Object getObjectValue()
      Returns the typed value for this setting, if known.
      Returns:
      setting value as a typed object, or null if not known
    • setCredibility

      public void setCredibility(Credibility cred)
      Sets the credibility of this setting. The default value is Credibility.YES.
      Parameters:
      cred - credibility level
    • getCredibility

      public Credibility getCredibility()
      Returns the credibility of this setting. The default value is Credibility.YES.
      Returns:
      credibility level
    • appendSuffix

      public Setting appendSuffix(String suffix)
      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

      public Setting resetDefault(String strDflt)
      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()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • shellQuote

      public static String shellQuote(String txt)
      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