# Class QCommandContext

java.lang.Object
com.io7m.quarrel.core.internal.QCommandContext

All Implemented Interfaces:
  `QCommandContextType`, `QLocalizationType`

public final class QCommandContext extends Object implements QCommandContextType
A basic command context implementation.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `QCommandContext(SortedMap<String,QCommandOrGroupType> inTree, QValueConverterDirectoryType inConverters, PrintWriter inOutput, QCommandType inCommand, QLocalizationType inLocalization, Map<QParameterNamedType<?>,List<Object>> inParsedNamedValues, QParametersPositionalType inPositionalParameters, List<Object> inParsedPositionalValues, List<String> inRawPositionalValues)`
  A basic command context implementation.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `QCommandType`
  `command()`
  `SortedMap<String,QCommandOrGroupType>`
  `commandTree()`
  `QCommandStatus`
  `execute()`
  Execute the command.
  `String`
  `format(QStringType string, Object... arguments)`
  Localize and format the given string.
  `String`
  `localize(QStringType string)`
  Localize the given string.
  `PrintWriter`
  `output()`
  `List<String>`
  `parametersPositionalRaw()`
  `<T> Optional<T>`
  `parameterValue(QParameterNamed01<T> parameter)`
  `<T> T`
  `parameterValue(QParameterNamed1<T> parameter)`
  `<T> T`
  `parameterValue(QParameterPositional<T> parameter)`
  `<T> T`
  `parameterValueRequireNow(QParameterNamed01<T> parameter)`
  `<T> List<T>`
  `parameterValues(QParameterNamed0N<T> parameter)`
  `<T> List<T>`
  `parameterValues(QParameterNamed1N<T> parameter)`
  `QValueConverterDirectoryType`
  `valueConverters()`
  The value converters used to produce this context.

  ### Methods inherited from class java.lang.Object

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

- ## Constructor Details

  - ### QCommandContext

    public QCommandContext(SortedMap<String,QCommandOrGroupType> inTree, QValueConverterDirectoryType inConverters, PrintWriter inOutput, QCommandType inCommand, QLocalizationType inLocalization, Map<QParameterNamedType<?>,List<Object>> inParsedNamedValues, QParametersPositionalType inPositionalParameters, List<Object> inParsedPositionalValues, List<String> inRawPositionalValues)
    A basic command context implementation.
    Parameters:
      `inTree` - The command tree
      `inConverters` - The value converters
      `inOutput` - The output
      `inCommand` - The command
      `inLocalization` - A localizer
      `inParsedNamedValues` - The parsed named values
      `inPositionalParameters` - The positional parameters
      `inParsedPositionalValues` - The parsed positional values
      `inRawPositionalValues` - The raw positional values

- ## Method Details

  - ### commandTree

    public SortedMap<String,QCommandOrGroupType> commandTree()
    Specified by:
      `commandTree` in interface `QCommandContextType`
    Returns:
      Access to the command tree

  - ### output

    public PrintWriter output()
    Specified by:
      `output` in interface `QCommandContextType`
    Returns:
      The output writer

  - ### valueConverters

    public QValueConverterDirectoryType valueConverters()
    Description copied from interface: `QCommandContextType`
    The value converters used to produce this context.
    Specified by:
      `valueConverters` in interface `QCommandContextType`
    Returns:
      The value converters

  - ### command

    public QCommandType command()
    Specified by:
      `command` in interface `QCommandContextType`
    Returns:
      The command to which this context belongs

  - ### parametersPositionalRaw

    public List<String> parametersPositionalRaw()
    Specified by:
      `parametersPositionalRaw` in interface `QCommandContextType`
    Returns:
      The raw positional parameters, if any

  - ### parameterValue

    public <T> T parameterValue(QParameterPositional<T> parameter)
    Specified by:
      `parameterValue` in interface `QCommandContextType`
    Type Parameters:
      `T` - The parameter type
    Parameters:
      `parameter` - The parameter
    Returns:
      The value for the parameter

  - ### parameterValue

    public <T> T parameterValue(QParameterNamed1<T> parameter)
    Specified by:
      `parameterValue` in interface `QCommandContextType`
    Type Parameters:
      `T` - The parameter type
    Parameters:
      `parameter` - The parameter
    Returns:
      The value for the parameter

  - ### parameterValue

    public <T> Optional<T> parameterValue(QParameterNamed01<T> parameter)
    Specified by:
      `parameterValue` in interface `QCommandContextType`
    Type Parameters:
      `T` - The parameter type
    Parameters:
      `parameter` - The parameter
    Returns:
      The value for the parameter, if one was provided

  - ### parameterValues

    public <T> List<T> parameterValues(QParameterNamed1N<T> parameter)
    Specified by:
      `parameterValues` in interface `QCommandContextType`
    Type Parameters:
      `T` - The parameter type
    Parameters:
      `parameter` - The parameter
    Returns:
      The values for the parameter

  - ### parameterValues

    public <T> List<T> parameterValues(QParameterNamed0N<T> parameter)
    Specified by:
      `parameterValues` in interface `QCommandContextType`
    Type Parameters:
      `T` - The parameter type
    Parameters:
      `parameter` - The parameter
    Returns:
      The values for the parameter

  - ### execute

    public QCommandStatus execute() throws Exception
    Description copied from interface: `QCommandContextType`
    Execute the command.
    Specified by:
      `execute` in interface `QCommandContextType`
    Returns:
      The result of execution
    Throws:
      `Exception` - On errors

  - ### parameterValueRequireNow

    public <T> T parameterValueRequireNow(QParameterNamed01<T> parameter) throws QException
    Specified by:
      `parameterValueRequireNow` in interface `QCommandContextType`
    Type Parameters:
      `T` - The parameter type
    Parameters:
      `parameter` - The parameter
    Returns:
      The value for the parameter
    Throws:
      `QException` - On errors

  - ### localize

    public String localize(QStringType string)
    Description copied from interface: `QLocalizationType`
    Localize the given string.
    Specified by:
      `localize` in interface `QLocalizationType`
    Parameters:
      `string` - The string
    Returns:
      The string

  - ### format

    public String format(QStringType string, Object... arguments)
    Description copied from interface: `QLocalizationType`
    Localize and format the given string. The localized string is treated as a format string, and formatted using `MessageFormat`.
    Specified by:
      `format` in interface `QLocalizationType`
    Parameters:
      `string` - The string
      `arguments` - The arguments
    Returns:
      The string