Class InputHelper

java.lang.Object
org.daisy.braille.ui.InputHelper

public class InputHelper extends Object
Provides a command line input helper for setting arguments interactively and storing them in the users preferences.
Author:
Joel HÃ¥kansson
  • Constructor Details

    • InputHelper

      public InputHelper(Class c)
      Creates a new InputHelper for the specified class. The package name for the specified class will be used to locate an appropriate storage location in the user preferences.
      Parameters:
      c - the class to create a InputHelper for
    • InputHelper

      public InputHelper()
      Creates a new InputHelper with the default storage location (determined by the calling class's package name)
  • Method Details

    • select

      public String select(String key, String[] select, String name, boolean verify)
      Selects the value for a key.
      Parameters:
      key - the key to select a value for
      select - the list of available values
      name - a display name for the key
      verify - if true, and no value is found, lets user select a value
      Returns:
      returns the value for the key.
    • select

      public String select(String key, List<Factory> select, String name, boolean verify)
      Selects the value for a key.
      Parameters:
      key - the key to get a value for
      select - the list of available values
      name - the display name for the key
      verify - if true, and no value is found, lets user select a value
      Returns:
      returns the value for the key.
    • getKey

      public String getKey(String key)
      Gets the value for a key.
      Parameters:
      key - the key to get a value for
      Returns:
      returns the value for the key
    • getInput

      public int getInput(boolean allowEnter) throws IOException
      Gets a integer from user. The assumption is that this value should be a non-zero positive integer, that is the user selects a value from a list starting with one. If the input is an empty string, 0 is returned. If an IO error occurs, -1 is returned.
      Returns:
      returns the integer value suppled by the user on the command line.
      Throws:
      IOException - if IO fails.
    • getDouble

      public double getDouble(String msg, String key, boolean verify) throws IOException
      Throws:
      IOException
    • getBoolean

      public boolean getBoolean(String msg, String key, boolean verify) throws IOException
      Throws:
      IOException
    • clearSettings

      public void clearSettings() throws BackingStoreException
      Clears the settings associated with this object from storage.
      Throws:
      BackingStoreException - if this operation cannot be completed due to a failure in the backing store, or inability to communicate with it.
      IllegalStateException - if the associated node (or an ancestor) has been removed with the removeNode() method.