# Class StiltsCommand

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

Direct Known Subclasses:
  `PlotStiltsCommand`

public class StiltsCommand extends Object
Represents an abstract model of a STILTS command line. A list of parameter-value pairs along with basic parameter grouping information is represented. There is no guarantee that the contents of this object will correspond to a STILTS command that can actually be executed, so care must be taken in assembling it.

Use a `CommandFormatter` instance to export this object into a useful external form, such as a shell command line.

Since:
  17 Sep 2024
Author:
  Mark Taylor

## Constructor Summary

Constructors
Constructor
Description
`StiltsCommand(uk.ac.starlink.task.Task task, String taskName, SettingGroup[] groups)`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`static StiltsCommand`
`createCommand(uk.ac.starlink.task.Task task, SettingGroup[] groups)`
Creates an instance of this class with an automatically determined task name.
`static Setting`
`createDefaultParamSetting(uk.ac.starlink.task.Parameter<?> param)`
Creates a Setting corresponding to a given task parameter, set to its default value.
`static List<Setting>`
`createInputTableSettings(AbstractInputTableParameter<?> inParam, uk.ac.starlink.table.StarTable table, TableNamer namer, FilterParameter filterParam, CredibleString selection)`
Returns settings associated with an InputTableParameter and table.
`static <T> Setting`
`createParamSetting(uk.ac.starlink.task.Parameter<T> param, T tval)`
Creates a Setting corresponding to a given task parameter.
`static Setting`
`createProgressSetting(FilterParameter filterParam)`
Returns a setting that corresponds to adding a progress filter to a filter parameter.
`SettingGroup[]`
`getGroups()`
Returns an array of objects that together contain all the parameter settings required to specify this task to stilts.
`static <T> uk.ac.starlink.task.Parameter<T>`
`getParameterByType(uk.ac.starlink.task.Task task, Class<T> ptype)`
Returns unique parameter of given type.
`uk.ac.starlink.task.Task`
`getTask()`
Returns the task corresponding to this object.
`String`
`getTaskName()`
Returns the name of this object's task, as used by the stilts command line.
`static List<SettingGroup>`
`toGroups(int level, List<Setting> settings)`
Groups a list of settings into zero or more SettingGroups.
`String`
`toString()`

### Methods inherited from class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

## Constructor Details

### StiltsCommand

public StiltsCommand(uk.ac.starlink.task.Task task, String taskName, SettingGroup[] groups)
Constructor.

Parameters:
  `task` - task
  `taskName` - name of the task as used by stilts command line
  `groups` - all name-value pairs specifying the configuration of the task, grouped for cosmetic purposes

## Method Details

### getTask

public uk.ac.starlink.task.Task getTask()
Returns the task corresponding to this object.

Returns:
  task object

### getTaskName

public String getTaskName()
Returns the name of this object's task, as used by the stilts command line.

Returns:
  task name

### getGroups

public SettingGroup[] getGroups()
Returns an array of objects that together contain all the parameter settings required to specify this task to stilts. They are grouped for cosmetic purposes.

Returns:
  settings

### toString

public String toString()

Overrides:
  `toString` in class `Object`

### createCommand

public static StiltsCommand createCommand(uk.ac.starlink.task.Task task, SettingGroup[] groups)
Creates an instance of this class with an automatically determined task name.

Parameters:
  `task` - task
  `groups` - all name-value pairs specifying the configuration of the task, grouped for cosmetic purposes

### createInputTableSettings

public static List<Setting> createInputTableSettings(AbstractInputTableParameter<?> inParam, uk.ac.starlink.table.StarTable table, TableNamer namer, FilterParameter filterParam, CredibleString selection)
Returns settings associated with an InputTableParameter and table.

Parameters:
  `inParam` - input table parameter
  `table` - table associated with this parameter
  `namer` - table namer capable of naming the supplied table
  `selection` - row selection expression, or null
Returns:
  list of settings associated with table input

### createParamSetting

public static <T> Setting createParamSetting(uk.ac.starlink.task.Parameter<T> param, T tval)
Creates a Setting corresponding to a given task parameter.

Parameters:
  `param` - task parameter
  `tval` - typed value for parameter
Returns:
  setting object

### createDefaultParamSetting

public static Setting createDefaultParamSetting(uk.ac.starlink.task.Parameter<?> param)
Creates a Setting corresponding to a given task parameter, set to its default value.

Parameters:
  `param` - task parameter
Returns:
  setting object

### createProgressSetting

public static Setting createProgressSetting(FilterParameter filterParam)
Returns a setting that corresponds to adding a progress filter to a filter parameter.

Parameters:
  `filterParam` - filter parameter
Returns:
  setting that adds this parameter-less filter

### getParameterByType

public static <T> uk.ac.starlink.task.Parameter<T> getParameterByType(uk.ac.starlink.task.Task task, Class<T> ptype)
Returns unique parameter of given type.

### toGroups

public static List<SettingGroup> toGroups(int level, List<Setting> settings)
Groups a list of settings into zero or more SettingGroups. A group is created for each non-empty run of Settings in the input list that does not contain a null value; nulls are effectively recognised as group terminators.

Parameters:
  `level` - level for all returned groups
  `settings` - input list of settings
Returns:
  list of groups containing all the input settings