## install4j API documentation

## com.install4j.api.screens
Interface Console

All Superinterfaces:
  ProgressInterface

    public interface Console

extends ProgressInterface

A `Console` object allows you to display information to the user and request input when the installer or uninstaller is running in console mode. Installers or uninstallers must be started with the "-c" argument in order to run in console mode. A console object is passed to the `handleConsole` methods of screens and form components.

Author:
  ej-technologies GmbH
See Also:
  `Screen.handleConsole(Console)`, `FormComponent.handleConsole(Console)`

Field Summary

Fields inherited from interface com.install4j.api.context.ProgressInterface
`OVERWRITE_ALL, OVERWRITE_NEVER, OVERWRITE_NO, OVERWRITE_YES, RETRY_CANCEL, RETRY_NO, RETRY_YES`

Method Summary
`int[]` | `askMultipleSelection(java.lang.String message, java.lang.String[] descriptions, java.lang.String[] keys, int[] defaultValues, boolean oneLinePerOption)` Ask the user to select multiple elements from a list of options.
`boolean` | `askOkCancel(java.lang.String message)` Ask the user a question that has to be answered with "OK" or "Cancel".
`boolean` | `askOkCancel(java.lang.String message, boolean defaultValue)` Ask the user a question that has to be answered with "OK" or "Cancel".
`int` | `askOption(java.lang.String message, java.lang.String[] descriptions, java.lang.String[] keys)` Ask the user a question with a fixed set of answers.
`int` | `askOption(java.lang.String message, java.lang.String[] descriptions, java.lang.String[] keys, int defaultValue)` Ask the user a question with a fixed set of answers.
`int` | `askOption(java.lang.String message, java.lang.String[] descriptions, java.lang.String[] keys, int defaultValue, boolean allowNoSelection, boolean oneLinePerOption)` Ask the user a question with a fixed set of answers.
`java.lang.String` | `askPassword(java.lang.String message, java.lang.String defaultValue)` Ask the user to enter a password.
`java.lang.String` | `askString(java.lang.String message, java.lang.String defaultValue)` Ask the user to enter a string with a default string that can be accepted by the user.
`boolean` | `askYesNo(java.lang.String message)` Ask the user a question that has to be answered with "Yes" or "No".
`boolean` | `askYesNo(java.lang.String message, boolean defaultValue)` Ask the user a question that has to be answered with "Yes" or "No".
`void` | `more(java.lang.String text)` Print a long text to the console and partition it into pages.
`void` | `print(java.lang.Object val)` Print an object to the console by invoking its `toString()` method.
`void` | `println()` Print a line feed to the console.
`void` | `println(java.lang.Object val)` Print an object to the console by invoking its `toString()` method and append a line feed.
`java.lang.String` | `readLine()` Read input from the console.
`void` | `waitForEnter()` Print [Enter] to the console and wait for the user to hit the Enter key.

Methods inherited from interface com.install4j.api.context.ProgressInterface
`askContinue, askOverwrite, askRetry, getPercentCompleted, setDetailMessage, setIndeterminateProgress, setPercentCompleted, setStatusMessage, showFailure`

Method Detail

### print

    void print(java.lang.Object val)

  Print an object to the console by invoking its `toString()` method.

  Parameters:
    `val` - the object to be printed

### println

    void println(java.lang.Object val)

  Print an object to the console by invoking its `toString()` method and append a line feed.

  Parameters:
    `val` - the object to be printed

### println

    void println()

  Print a line feed to the console.

### more

    void more(java.lang.String text)
              throws UserCanceledException

  Print a long text to the console and partition it into pages. Line breaks are introduced after 75 characters and a "more" notice is printed every 25 lines.

  Parameters:
    `text` -
  Throws:
    `UserCanceledException` - if the user cancels the "more" notice, typically with CTRL-C

### readLine

    java.lang.String readLine()
                              throws UserCanceledException

  Read input from the console.

  Returns:
    the string that was entered by the user.
  Throws:
    `UserCanceledException` - if the user cancels the prompt, typically with CTRL-C

### askYesNo

    boolean askYesNo(java.lang.String message)
                     throws UserCanceledException

  Ask the user a question that has to be answered with "Yes" or "No". There is no default value.

  Parameters:
    `message` - the question
  Returns:
    whether the user answered "Yes"
  Throws:
    `UserCanceledException` - if the user cancels the question, typically with CTRL-C

### askYesNo

    boolean askYesNo(java.lang.String message,
                     boolean defaultValue)
                     throws UserCanceledException

  Ask the user a question that has to be answered with "Yes" or "No". The default value is configurable.

  Parameters:
    `message` - the question
    `defaultValue` - whether "Yes" is the default value
  Returns:
    whether the user answered "Yes"
  Throws:
    `UserCanceledException` - if the user cancels the question, typically with CTRL-C

### askOkCancel

    boolean askOkCancel(java.lang.String message)
                        throws UserCanceledException

  Ask the user a question that has to be answered with "OK" or "Cancel". There is no default value.

  Parameters:
    `message` - the question
  Returns:
    whether the user answered "OK"
  Throws:
    `UserCanceledException` - if the user cancels the question, typically with CTRL-C. Note that this is different from a "Cancel" answer.

### askOkCancel

    boolean askOkCancel(java.lang.String message,
                        boolean defaultValue)
                        throws UserCanceledException

  Ask the user a question that has to be answered with "OK" or "Cancel". The default value is configurable.

  Parameters:
    `message` - the question
    `defaultValue` - whether "OK" is the default value
  Returns:
    whether the user answered "OK"
  Throws:
    `UserCanceledException` - if the user cancels the question, typically with CTRL-C. Note that this is different from a "Cancel" answer.

### askOption

    int askOption(java.lang.String message,
                  java.lang.String[] descriptions,
                  java.lang.String[] keys)
                  throws UserCanceledException

  Ask the user a question with a fixed set of answers. There is no default value.

  Parameters:
    `message` - the question
    `descriptions` - an array with a textual description for each option
    `keys` - an array with a short key for each option. Keys are what the user enters to select the desired option.
  Returns:
    the selected index of the option
  Throws:
    `UserCanceledException` - if the user cancels the question, typically with CTRL-C.

### askOption

    int askOption(java.lang.String message,
                  java.lang.String[] descriptions,
                  java.lang.String[] keys,
                  int defaultValue)
                  throws UserCanceledException

  Ask the user a question with a fixed set of answers. The default value is configurable.

  Parameters:
    `message` - the question
    `descriptions` - an array with a textual description for each option
    `keys` - an array with a short key for each option. Keys are what the user enters to select the desired option.
    `defaultValue` - the index of the default option
  Returns:
    the selected index of the option
  Throws:
    `UserCanceledException` - if the user cancels the question, typically with CTRL-C.

### askOption

    int askOption(java.lang.String message,
                  java.lang.String[] descriptions,
                  java.lang.String[] keys,
                  int defaultValue,
                  boolean allowNoSelection,
                  boolean oneLinePerOption)
                  throws UserCanceledException

  Ask the user a question with a fixed set of answers. The default value, the no-selection policy as well as the presentation of the options are configurable.

  Parameters:
    `message` - the question
    `descriptions` - an array with a textual description for each option
    `keys` - an array with a short key for each option. Keys are what the user enters to select the desired option.
    `defaultValue` - the index of the default option
    `allowNoSelection` - if the question should allow an empty answer, the return value is -1 in that case.
    `oneLinePerOption` - if the options should be presented on option per line. By default, all options are presented on the same line.
  Returns:
    the index of the selected option or -1 if no answer is given.
  Throws:
    `UserCanceledException` - if the user cancels the question, typically with CTRL-C.

### askMultipleSelection

    int[] askMultipleSelection(java.lang.String message,
                               java.lang.String[] descriptions,
                               java.lang.String[] keys,
                               int[] defaultValues,
                               boolean oneLinePerOption)
                               throws UserCanceledException

  Ask the user to select multiple elements from a list of options. The default selection, and the presentation of the options are configurable.

  Parameters:
    `message` - the question
    `descriptions` - an array with a textual description for each option
    `keys` - an array with a short key for each option. Keys are what the user enters to select the desired options.
    `defaultValues` - an array with the the indices of the options that are selected by default
    `oneLinePerOption` - if the options should be presented on option per line. By default, all options are presented on the same line.
  Returns:
    an array with the indices of the selected options. The length of the array can be 0 if no options were selected.
  Throws:
    `UserCanceledException` - if the user cancels the question, typically with CTRL-C.

### askString

    java.lang.String askString(java.lang.String message,
                               java.lang.String defaultValue)
                               throws UserCanceledException

  Ask the user to enter a string with a default string that can be accepted by the user.

  Parameters:
    `message` - the prompt before the input
    `defaultValue` - the default string
  Returns:
    the string entered by the user or the default value if the user hits the Enter key.
  Throws:
    `UserCanceledException` - if the user cancels the question, typically with CTRL-C.

### askPassword

    java.lang.String askPassword(java.lang.String message,
                                 java.lang.String defaultValue)
                                 throws UserCanceledException

  Ask the user to enter a password.

  Parameters:
    `message` - the prompt before the input
    `defaultValue` - the default string
  Returns:
    the string entered by the user or the default value if the user hits the Enter key.
  Throws:
    `UserCanceledException` - if the user cancels the question, typically with CTRL-C.

### waitForEnter

    void waitForEnter()
                      throws UserCanceledException

  Print [Enter] to the console and wait for the user to hit the Enter key.

  Throws:
    `UserCanceledException` - if the user cancels the notice, typically with CTRL-C.